Skip to content

Commit 1138cf8

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

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ 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+
failed_files=$( \
35+
find src -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "src/lib/fb-api/*" \
36+
-exec sh -c 'for f; do [ "$(clang-format "$f")" != "$(cat "$f")" ] && echo "$f"; done' _ {} +)
37+
38+
if [ -n "$failed_files" ]; then
39+
echo "The following files are not properly formatted:"
40+
echo "$failed_files"
41+
exit 1
42+
fi
43+
1844
build-linux:
1945
runs-on: ubuntu-latest
2046
steps:
@@ -195,6 +221,7 @@ jobs:
195221
deploy-docs:
196222
runs-on: ubuntu-latest
197223
needs:
224+
- clang-format-check
198225
- build-linux
199226
- build-windows
200227
- build-macos

.github/workflows/pull-request.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ 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+
failed_files=$( \
26+
find src -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "src/lib/fb-api/*" \
27+
-exec sh -c 'for f; do [ "$(clang-format "$f")" != "$(cat "$f")" ] && echo "$f"; done' _ {} +)
28+
29+
if [ -n "$failed_files" ]; then
30+
echo "The following files are not properly formatted:"
31+
echo "$failed_files"
32+
exit 1
33+
fi
34+
935
build-linux:
1036
runs-on: ubuntu-latest
1137
steps:

0 commit comments

Comments
 (0)