Skip to content

Commit 15fa83f

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

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ 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: Check clang-format
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y clang-format
31+
32+
failed_files=$(find src -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "src/lib/fb-api/*" -exec sh -c 'for f; do [ "$(clang-format "$f")" != "$(cat "$f")" ] && echo "$f"; done' _ {} +)
33+
34+
if [ -n "$failed_files" ]; then
35+
echo "The following files are not properly formatted:"
36+
echo "$failed_files"
37+
exit 1
38+
fi
39+
1840
build-linux:
1941
runs-on: ubuntu-latest
2042
steps:
@@ -195,6 +217,7 @@ jobs:
195217
deploy-docs:
196218
runs-on: ubuntu-latest
197219
needs:
220+
- clang-format-check
198221
- build-linux
199222
- build-windows
200223
- build-macos

.github/workflows/pull-request.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ 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: Check clang-format
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y clang-format
22+
23+
failed_files=$(find src -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "src/lib/fb-api/*" -exec sh -c 'for f; do [ "$(clang-format "$f")" != "$(cat "$f")" ] && echo "$f"; done' _ {} +)
24+
25+
if [ -n "$failed_files" ]; then
26+
echo "The following files are not properly formatted:"
27+
echo "$failed_files"
28+
exit 1
29+
fi
30+
931
build-linux:
1032
runs-on: ubuntu-latest
1133
steps:

0 commit comments

Comments
 (0)