-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Thin wrapper around clang-format for easier to parse output from the | ||
# pre-commit hook. | ||
# | ||
# Needs to work with multiple input files as pre-commit passes multiple files to | ||
# the "executables" | ||
|
||
# Make sure that diff is actually recent enough (diffutils >= 3.4) to support | ||
# colored output | ||
COLOR_OUTPUT=$(diff --color=always <(echo) <(echo) > /dev/null 2>&1 && echo "--color=always") | ||
|
||
success=0 | ||
for file in ${@}; do | ||
if ! $(clang-format --style=file --Werror --dry-run ${file} > /dev/null 2>&1); then | ||
echo "Necessary changes for: '${file}' (run 'clang-format --style=file -i ${file}' to fix it)" | ||
diff ${COLOR_OUTPUT} -u ${file} <(clang-format --style=file ${file}) | tail -n +3 | ||
success=1 | ||
fi | ||
done | ||
exit ${success} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Copyright (c) ${years} ${owner}. | ||
|
||
This file is part of ${projectname}. | ||
See ${projecturl} for further info. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: pre-commit | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cvmfs-contrib/[email protected] | ||
- uses: aidasoft/run-lcg-view@v4 | ||
with: | ||
release-platform: LCG_101/x86_64-centos7-clang12-opt | ||
run: | | ||
export PYTHONPATH=$(python -m site --user-site):$PYTHONPATH | ||
export PATH=/root/.local/bin:$PATH | ||
pip install --upgrade --user pip | ||
pip install pre-commit --user | ||
# Use virtualenv from the LCG release | ||
pip uninstall --yes virtualenv | ||
pre-commit run --show-diff-on-failure \ | ||
--color=always \ | ||
--all-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
exclude: (doc/ReleaseNotes.md) | ||
- repo: local | ||
hooks: | ||
- id: clang-format | ||
name: clang-format | ||
entry: .github/scripts/clang-format-hook | ||
types: [c++] | ||
language: system | ||
- repo: https://github.com/johann-petrak/licenseheaders.git | ||
rev: 'v0.8.8' | ||
hooks: | ||
- id: licenseheaders | ||
args: ["-t", ".github/templates/apache-2.tmpl", "-y2014-2023", | ||
"-o", "Key4hep-Project", | ||
"-n", "Key4hep", | ||
"-u", "https://key4hep.github.io/key4hep-doc/", | ||
"-x", ".github/*", ".pre-commit-config.yaml", "README.md", | ||
"doc/ReleaseNotes.md", | ||
"-f"] |
This file was deleted.
Oops, something went wrong.