-
Notifications
You must be signed in to change notification settings - Fork 11
51 lines (44 loc) · 1.44 KB
/
clang-format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Clang Format Check
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
jobs:
clang-format-check:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Download Linux kernel .clang-format
run: |
curl -o .clang-format https://raw.githubusercontent.com/torvalds/linux/master/.clang-format
- name: Run clang-format and check code style
run: |
for file in $(ls src/*.[ch]); do
diff=$(clang-format -style=file "$file" | diff "$file" -)
echo "DIFF $diff"
if [ ! -z "$diff" ]; then
echo "Style issues in $file:" >> clang-format-diff.txt
clang-format -style=file "$file" | diff -u "$file" - >> clang-format-diff.txt
fi
done
echo "CIAOOA"
if [ -f clang-format-diff.txt ]; then
echo "ERROR in format"
echo "\nThe following files have style issues:" && cat clang-format-diff.txt
echo "\nRun clang-format -i src/*.[ch] in order to fix" >> $GITHUB_OUTPUT
exit 1
else
echo "NO ERRORS"
fi
- name: Upload clang-format diff artifact
if: failure()
uses: actions/upload-artifact@v3
with:
name: clang-format-diff
path: countdown/clang-format-diff.txt