-
Notifications
You must be signed in to change notification settings - Fork 21
40 lines (32 loc) · 1.1 KB
/
clang.yml
File metadata and controls
40 lines (32 loc) · 1.1 KB
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
name: Clang-format
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
jobs:
check-formatting:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format-17
- name: Run clang-format style check
run: |
# Find all C/C++ files, excluding include directory
files=$(find . -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.c" \) \
! -path "./include/*" ! -path "./.git/*" | sort)
if [ -z "$files" ]; then
echo "No C/C++ files found"
exit 0
fi
# Check formatting (--dry-run -Werror exits non-zero if changes needed)
echo "$files" | xargs clang-format-17 --verbose --dry-run -Werror --style=file --fallback-style=Microsoft