-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (33 loc) · 1.04 KB
/
clang-format-check.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
name: Clang Format Check
on:
pull_request:
push:
branches:
- main
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code from the repository
- name: Checkout the code
uses: actions/checkout@v3
# Step 2: Install clang-format
- name: Install clang-format
run: sudo apt-get install -y clang-format
# Step 3: Find .c and .h files that need formatting
- name: Check if files are properly formatted
run: |
FILES_TO_CHECK=$(find . -name "*.c" -o -name "*.h")
for file in $FILES_TO_CHECK; do
clang-format --style=file -i $file
done
# Step 4: Check if files match .clang-format style
- name: Validate formatting
run: |
FILES_TO_CHECK=$(find . -name "*.c" -o -name "*.h")
for file in $FILES_TO_CHECK; do
if ! diff -u $file <(clang-format --style=file $file); then
echo "Formatting issues in $file"
exit 1
fi
done