File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Clang-Format Check
2+
3+ on :
4+ push :
5+ branches : [master]
6+ pull_request :
7+ paths :
8+ - ' **/*.cpp'
9+ - ' **/*.h'
10+ - ' **/*.hpp'
11+
12+ jobs :
13+ clang-format-check :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v4
19+
20+ - name : Install Clang-Format
21+ run : sudo apt-get install -y clang-format
22+
23+ - name : Run Clang-Format Check
24+ run : |
25+ files=$(find . -name "*.cpp" -o -name "*.hpp" -o -name "*.h")
26+ check_ignore=$(git -c core.excludesFile="format-ignore.txt" check-ignore --stdin --no-index --non-matching --verbose <<< "$files")
27+ files=$(awk '/^::/ {print $2}' <<< "$check_ignore")
28+
29+ echo "Checking $(echo "$files" | wc -l) files"
30+
31+ if [ -n "$files" ]; then
32+ clang-format -style=file -i $files
33+ git diff --exit-code || (echo "Clang-Format check failed!" && exit 1)
34+ else
35+ echo "No files to check."
36+ fi
You can’t perform that action at this time.
0 commit comments