From 7bf926c5a6f34151c7952854f87187f14f7e1205 Mon Sep 17 00:00:00 2001 From: David Runge Date: Tue, 4 Jan 2022 18:40:41 +0100 Subject: [PATCH] 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 and fails if there need to be changes to the formatting. --- .github/workflows/format.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..95c5b80 --- /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 diffutils findutils clang + - name: Run clang-format on all C and C++ sources + run: | + cp -av ../jack-example-tools ../jack-example-tools.orig + 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 test -n "$(diff -ruN ../jack-example-tools.orig ../jack-example-tools)"; then + diff -ruN ../jack-example-tools.orig ../jack-example-tools + exit 1 + fi