-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
2 changed files
with
45 additions
and
0 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,25 @@ | ||
name: Check format of code | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
# Always trigger all Github Actions if an action or something CI related was changed | ||
- ".github/workflows/**" | ||
- "tools/ci/**" | ||
- ".clang-format" | ||
# This workflow should run when a file in a source directory has been modified. | ||
- "src/**" | ||
|
||
jobs: | ||
clang-format: | ||
# Github Actions checks for '[ci skip]', '[skip ci]', '[no ci]', '[skip actions]', or '[actions skip]' but not a hyphenated version. | ||
# It's a catch-all incase a Pull Request has been opened and someone is on auto-pilot. | ||
if: "!contains(github.event.head_commit.message, 'ci-skip')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- name: Check format | ||
run: ./tools/ci/check-format.sh |
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,20 @@ | ||
#!/bin/bash | ||
|
||
SHOULD_EXIT=0 | ||
|
||
# only check files in common for now | ||
for FILE in $(ls src/common/*.hpp src/common/*.cpp) | ||
do | ||
CHANGES=$(diff -u <(cat $FILE) <(clang-format $FILE)) | ||
if [ -n "$CHANGES" ]; then | ||
echo "File $FILE is not formatted correctly" | ||
echo "$CHANGES" | ||
SHOULD_EXIT=1 | ||
fi | ||
done | ||
|
||
if [ $SHOULD_EXIT -eq 1 ]; then | ||
echo "Some files are not formatted correctly, please run clang-format" | ||
exit 1 | ||
fi | ||
echo "All files are formatted correctly" |