1- name : clang-tidy
1+ name : style-check
22
33on :
4- push :
54 pull_request :
5+ workflow_dispatch :
6+
7+ env :
8+ LLVM_VERSION : 22.1.4
69
710jobs :
811 clang-tidy :
9- name : Run clang-tidy and upload report
10- runs-on : ubuntu-22.04
12+ runs-on : ubuntu-24.04
1113 steps :
1214 - name : Checkout repository
1315 uses : actions/checkout@v6.0.0
@@ -20,95 +22,90 @@ jobs:
2022 with :
2123 python-version : ' 3.x'
2224
23- - name : Install LLVM (clang/clang-tidy) with cache
24- uses : KyleMayes/install-llvm-action@v2.0.9
25+ - name : Cache LLVM
26+ id : cache-llvm
27+ uses : actions/cache@v5
2528 with :
26- version : " 21"
29+ path : LLVM-${{ env.LLVM_VERSION }}-Linux-X64.tar.xz
30+ key : ${{ runner.os }}-llvm-${{ env.LLVM_VERSION }}
2731
28- - name : Generate CMakeLists.txt via helper script
32+ - name : Install LLVM (clang/clang-tidy/clang-format) and dependencies
2933 run : |
30- # Run from ci/docker so the script writes to ../../CMakeLists.txt (project root)
31- sudo chmod +x ./ci/generate_cmakelists.sh
32- cd ci/
33- ./generate_cmakelists.sh
34+ sudo apt update
35+ sudo add-apt-repository universe
36+ sudo apt update
37+ sudo apt install libncurses5-dev ripgrep
38+ if [ "${{ steps.cache-llvm.outputs.cache-hit }}" != "true" ]; then
39+ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.LLVM_VERSION }}/LLVM-${{ env.LLVM_VERSION }}-Linux-X64.tar.xz
40+ fi
41+ sudo tar -xf LLVM-${{ env.LLVM_VERSION }}-Linux-X64.tar.xz
42+ sudo mv LLVM-${{ env.LLVM_VERSION }}-Linux-X64 /usr/local/llvm-${{ env.LLVM_VERSION }}
43+ sudo ln -s /usr/local/llvm-${{ env.LLVM_VERSION }}/bin/clang-tidy /usr/local/bin/clang-tidy
44+ sudo ln -s /usr/local/llvm-${{ env.LLVM_VERSION }}/bin/run-clang-tidy /usr/local/bin/run-clang-tidy
45+ sudo ln -s /usr/local/llvm-${{ env.LLVM_VERSION }}/bin/clang-format /usr/local/bin/clang-format
3446
35- - name : Configure CMake and generate compile_commands.json
36- run : |
37- cmake -S . -B build -DCODECHECK_BUILD=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
38- python ci/filter-cc.py
39- - name : Run clang-tidy
47+ - name : Run style-check
4048 id : run
4149 shell : bash
4250 run : |
43- sudo apt update
44- sudo add-apt-repository universe
45- sudo apt update
46- sudo apt install libncurses5-dev libtinfo5
4751 set -o pipefail
48- # Collect sources (mirror Makefile exclusions)
49- mapfile -t FILES < <(find src/ \( -name "*.cpp" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" -o -name "*.c" -o -name "*.h" \) \
50- -not -path "src/maszyna/*" -not -path "src/gen/*" -not -path "godot-cpp")
51-
52- echo "Running clang-tidy on ${#FILES[@]} files"
52+ : > style-check.log
53+
54+ # make style-check handles CMake configuration if needed
55+ make style-check 2>&1 | tee style-check.log
5356
54- : > clang-tidy.log
55- : > clang-tidy-errors.log
56-
57- # Run clang-tidy for each file, appending to a single log
58- for f in "${FILES[@]}"; do
59- echo "=== ${f} ===" | tee -a clang-tidy.log
60- # Use project-local .clang-tidy implicitly
61- if ! sudo clang-tidy -p build -extra-arg=-std=c++17 --quiet --fix-notes -header-filter=^src/ "$f" 2>>clang-tidy-errors.log | tee -a clang-tidy.log; then
62- echo "clang-tidy reported non-zero status for $f" >> clang-tidy-errors.log
63- fi
64- done
65-
66- # Save a simple status for later steps
67- issues=$(grep -E "^[^=][^=]*:[0-9]+:[0-9]+: (warning|error): .* \[[^]]+\]" clang-tidy.log | grep -v -E "godot[-_]?cpp" | wc -l || true)
57+ issues=$(grep -E "^[^=][^=]*:[0-9]+:[0-9]+: (warning|error): .* \[[^]]+\]" style-check.log | grep -v -E "godot[-_]?cpp" | wc -l || true)
6858 echo "issues=$issues" >> $GITHUB_OUTPUT
6959
7060 - name : Build Markdown table report
61+ if : always()
7162 run : |
7263 {
73- echo "# Clang-Tidy Report"
64+ echo "# Style Check Report"
7465 echo
7566 echo "Generated on: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
7667 echo
77- echo "Configuration: .clang-tidy"
78- echo
79- echo "Total issues: ${{ steps.run.outputs.issues }}"
68+ echo "Total issues found: ${{ steps.run.outputs.issues }}"
8069 echo
70+
71+ if grep -q "clang-format" style-check.log; then
72+ echo "## Clang-Format Issues"
73+ echo '```'
74+ grep "clang-format" style-check.log || echo "No clang-format issues"
75+ echo '```'
76+ echo
77+ fi
78+
79+ echo "## Clang-Tidy Issues"
8180 echo "| File | Line | Column | Severity | Check | Message |"
8281 echo "|------|------|--------|----------|-------|---------|"
8382 # Parse lines like: path:line:col: severity: message [check]
84- # Exclude any header lines (like === file ===)
85- grep -E "^[^=][^=]*:[0-9]+:[0-9]+: (warning|error): .* \[[^]]+\]" clang-tidy.log | \
83+ grep -E "^[^=][^=]*:[0-9]+:[0-9]+: (warning|error): .* \[[^]]+\]" style-check.log | \
8684 grep -v -E "godot[-_]?cpp" | \
8785 awk '
8886 function html_escape(s){gsub(/\|/ ,"\\|", s); gsub(/\\\\/ ,"\\\\\\\\", s); return s}
8987 {
9088 match($0, /^([^:]+):([0-9]+):([0-9]+): ([a-z]+): (.*) \[([^\]]+)\]$/, m)
9189 if (m[0] != "") {
9290 file=m[1]; line=m[2]; col=m[3]; sev=m[4]; msg=m[5]; chk=m[6]
93- # Escape vertical bars to keep markdown table intact
9491 gsub(/\|/, "\\|", file)
9592 gsub(/\|/, "\\|", msg)
9693 printf("| %s | %s | %s | %s | %s | %s |\n", file, line, col, sev, chk, msg)
9794 }
9895 }
9996 '
10097 echo
101- echo "\n<details><summary>Raw clang-tidy log</summary>\n\n\n``` `\n"
102- sed 's/`/\x60/g' clang-tidy .log
103- echo "\n``` `\n\n</details>"
104- } > clang-tidy -report.md
98+ echo -e "\n<details><summary>Raw style-check log</summary>\n\n\n\`\`\ `\n"
99+ sed 's/`/\x60/g' style-check .log
100+ echo -e "\n\`\`\ `\n\n</details>"
101+ } > style-check -report.md
105102
106103 - name : Post annotations to GitHub
107104 if : always()
108105 run : |
109106 # Parse clang-tidy log and create GitHub annotations
110- grep -E "^[^=][^=]*:[0-9]+:[0-9]+: (warning|error): .* \[[^]]+\]" clang-tidy .log | \
111- grep -v -E "godot[-_]?cpp" | \
107+ grep -E ": (warning|error): .* \[[^]]+\]" style-check .log | \
108+ grep -v -E "godot[-_]?cpp|src/maszyna|src/gen " | \
112109 awk '
113110 function esc(s) {
114111 gsub(/%/, "%25", s); gsub(/\r/, "%0D", s); gsub(/\n/, "%0A", s);
@@ -119,23 +116,24 @@ jobs:
119116 if (m[0] != "") {
120117 file=m[1]; line=m[2]; col=m[3]; sev=m[4]; msg=m[5]; chk=m[6]
121118 level="warning"
119+ if (sev == "error") level="error"
122120 printf("::%s file=%s,line=%s,col=%s,title=clang-tidy (%s)::%s\n",
123121 level, file, line, col, chk, esc(msg))
124122 }
125123 }'
126124
127125 - name : Upload artifact
126+ if : always()
128127 uses : actions/upload-artifact@v7.0.0
129128 with :
130- name : clang-tidy -report
129+ name : style-check -report
131130 path : |
132- clang-tidy.log
133- clang-tidy-errors.log
134- clang-tidy-report.md
131+ style-check.log
132+ style-check-report.md
135133 if-no-files-found : warn
136134
137135 - name : Fail on issues
138136 if : ${{ steps.run.outputs.issues != '0' }}
139137 run : |
140- echo "clang-tidy found ${{ steps.run.outputs.issues }} issue(s). See artifact for details." >&2
138+ echo "Style check found ${{ steps.run.outputs.issues }} issue(s). See artifact for details." >&2
141139 exit 1
0 commit comments