-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github workflow for checking code formatting
.github/workflows/format.yml: Add github workflow for checking code formatting, which runs clang-format in a container.
- Loading branch information
Showing
1 changed file
with
29 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,29 @@ | ||
--- | ||
|
||
name: Check for correct formatting | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
check_formatting: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: archlinux:latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: pacman --noconfirm -Syu findutils git clang | ||
- name: Run clang-format on all C and C++ sources | ||
run: | | ||
find . -type f -iname "*.c" -or -iname "*.cc" -or -iname "*.cpp" -or -iname "*.h" | ||
find . -type f -iname "*.c" -or -iname "*.cc" -or -iname "*.cpp" -or -iname "*.h" -exec clang-format -i {} \; | ||
- name: Check whether there are differences | ||
run: | | ||
if [[ -z "$(git status -s)" ]]; then | ||
printf "Files are not properly formatted!\n" | ||
git diff | ||
fi |