-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (137 loc) · 4.69 KB
/
static-analysis.yml
File metadata and controls
159 lines (137 loc) · 4.69 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Static Analysis
on:
push:
branches: [ main, phase-* ]
pull_request:
branches: [ main ]
jobs:
clang-tidy:
name: Clang-Tidy Analysis
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
# Clang with libc++ for std::format support
sudo apt-get install -y cmake ninja-build clang clang-tidy libgtest-dev libgmock-dev libc++-dev libc++abi-dev
- name: Checkout common_system (required dependency)
run: |
cd ..
if [ ! -d "common_system" ]; then
git clone https://github.com/kcenon/common_system.git
fi
- name: Configure CMake
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi" \
-DBUILD_WITH_COMMON_SYSTEM=ON \
-DBUILD_DOCUMENTATION=OFF
- name: Run clang-tidy
continue-on-error: true # Phase 0: Allow failures, collect baseline
run: |
# Find all C++ source and header files
find include -name "*.h" -o -name "*.hpp" | while read file; do
echo "Analyzing: $file"
clang-tidy "$file" -p=build -- -std=c++20 || true
done > clang-tidy-results.txt 2>&1
- name: Count warnings by category
if: always()
run: |
echo "## Clang-Tidy Warning Summary" > clang-tidy-summary.md
echo "" >> clang-tidy-summary.md
echo "Phase 0 Baseline - $(date +%Y-%m-%d)" >> clang-tidy-summary.md
echo "" >> clang-tidy-summary.md
if [ -f clang-tidy-results.txt ]; then
# Count total warnings
TOTAL=$(grep -c "warning:" clang-tidy-results.txt || echo "0")
echo "Total warnings: $TOTAL" >> clang-tidy-summary.md
echo "" >> clang-tidy-summary.md
# Count by category
echo "### Warnings by Category" >> clang-tidy-summary.md
grep "warning:" clang-tidy-results.txt | \
sed 's/.*\[\(.*\)\]/\1/' | \
sort | uniq -c | sort -rn >> clang-tidy-summary.md || true
else
echo "No warnings file generated" >> clang-tidy-summary.md
fi
cat clang-tidy-summary.md
- name: Upload analysis results
if: always()
uses: actions/upload-artifact@v4
with:
name: clang-tidy-baseline
path: |
clang-tidy-results.txt
clang-tidy-summary.md
retention-days: 90 # Keep baseline for reference
- name: Add summary to job
if: always()
run: |
if [ -f clang-tidy-summary.md ]; then
cat clang-tidy-summary.md >> $GITHUB_STEP_SUMMARY
fi
cppcheck:
name: Cppcheck Analysis
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Run cppcheck
continue-on-error: true # Phase 0: Allow failures, collect baseline
run: |
cppcheck --enable=all \
--std=c++20 \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--inline-suppr \
--xml \
--xml-version=2 \
-I include \
include 2> cppcheck-results.xml || true
- name: Generate cppcheck report
if: always()
run: |
echo "## Cppcheck Analysis Summary" > cppcheck-summary.md
echo "" >> cppcheck-summary.md
echo "Phase 0 Baseline - $(date +%Y-%m-%d)" >> cppcheck-summary.md
echo "" >> cppcheck-summary.md
if [ -f cppcheck-results.xml ]; then
# Count errors by severity
echo "### Issues by Severity" >> cppcheck-summary.md
grep -oP 'severity="\K[^"]+' cppcheck-results.xml | \
sort | uniq -c | sort -rn >> cppcheck-summary.md || true
else
echo "No cppcheck results generated" >> cppcheck-summary.md
fi
cat cppcheck-summary.md
- name: Upload cppcheck results
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-baseline
path: |
cppcheck-results.xml
cppcheck-summary.md
retention-days: 90
- name: Add summary to job
if: always()
run: |
if [ -f cppcheck-summary.md ]; then
cat cppcheck-summary.md >> $GITHUB_STEP_SUMMARY
fi