Skip to content

Commit 2d22b66

Browse files
committed
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.
1 parent b0b16ca commit 2d22b66

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/format.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
3+
name: Check for correct formatting
4+
5+
on:
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
11+
jobs:
12+
check_formatting:
13+
runs-on: ubuntu-latest
14+
container:
15+
image: archlinux:latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Install dependencies
19+
run: pacman --noconfirm -Syu diffutils findutils clang
20+
- name: Run clang-format on all C and C++ sources
21+
run: |
22+
cp -av ../jack-example-tools ../jack-example-tools.orig
23+
find . -type f -iname "*.c" -or -iname "*.cc" -or -iname "*.cpp" -or -iname "*.h" -exec clang-format -i {} \;
24+
- name: Check whether there are differences
25+
run: |
26+
if test -n "$(diff -ruN ../jack-example-tools.orig ../jack-example-tools)"; then
27+
diff -ruN ../jack-example-tools.orig ../jack-example-tools
28+
exit 1
29+
fi

0 commit comments

Comments
 (0)