Skip to content

Commit deb342e

Browse files
committed
Add clang-format checks
1 parent 95e839a commit deb342e

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ concurrency:
1515
group: main
1616

1717
jobs:
18+
clang-format-check:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: recursive
25+
fetch-depth: 0
26+
27+
- name: Install clang-format
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y clang-format
31+
32+
- name: Check clang-format
33+
run: |
34+
./check-format.sh
35+
1836
build-linux:
1937
runs-on: ubuntu-latest
2038
steps:
@@ -195,6 +213,7 @@ jobs:
195213
deploy-docs:
196214
runs-on: ubuntu-latest
197215
needs:
216+
- clang-format-check
198217
- build-linux
199218
- build-windows
200219
- build-macos

.github/workflows/pull-request.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ on:
66
- main
77

88
jobs:
9+
clang-format-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
submodules: recursive
16+
fetch-depth: 0
17+
18+
- name: Install clang-format
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y clang-format
22+
23+
- name: Check clang-format
24+
run: |
25+
./check-format.sh
26+
927
build-linux:
1028
runs-on: ubuntu-latest
1129
steps:

check-format.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
failed_files=$( \
4+
find src -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "src/lib/fb-api/*" \
5+
-exec sh -c 'for f; do [ "$(clang-format "$f")" != "$(cat "$f")" ] && echo "$f"; done' _ {} +)
6+
7+
if [ -n "$failed_files" ]; then
8+
echo "The following files are not properly formatted:"
9+
echo "$failed_files"
10+
exit 1
11+
fi

0 commit comments

Comments
 (0)