diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..54a6836 --- /dev/null +++ b/.github/workflows/format.yml @@ -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