-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (131 loc) · 3.85 KB
/
static-analysis.yml
File metadata and controls
153 lines (131 loc) · 3.85 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
name: Static Analysis
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch: # Allow manual trigger
jobs:
cppcheck:
name: CPPCheck Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
cppcheck \
--enable=all \
--std=c++23 \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--inline-suppr \
--error-exitcode=1 \
--xml \
--xml-version=2 \
src/ \
2> cppcheck_report.xml || true
# Generate readable report
cppcheck \
--enable=all \
--std=c++23 \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--inline-suppr \
src/ \
2>&1 | tee cppcheck_report.txt
- name: Upload cppcheck results
uses: actions/upload-artifact@v4
with:
name: cppcheck-report
path: |
cppcheck_report.xml
cppcheck_report.txt
retention-days: 30
clang-tidy:
name: Clang-Tidy Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-15 clang-tidy-15 cmake
- name: Create .clang-tidy config
run: |
cat > .clang-tidy << 'EOF'
---
Checks: >
bugprone-*,
modernize-*,
performance-*,
readability-*,
-modernize-use-trailing-return-type,
-readability-identifier-length,
-readability-magic-numbers,
-readability-function-cognitive-complexity
WarningsAsErrors: ''
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelCase
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ConstantCase
value: UPPER_CASE
EOF
- name: Configure CMake for compile_commands.json
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-15 \
-DCMAKE_CXX_COMPILER=clang++-15 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Run clang-tidy
run: |
# Run on a subset of files (full analysis can be very slow)
find src -name "*.cpp" | head -20 | xargs -I {} \
clang-tidy-15 \
-p build \
{} \
2>&1 | tee clang_tidy_report.txt || true
- name: Upload clang-tidy results
uses: actions/upload-artifact@v4
with:
name: clang-tidy-report
path: clang_tidy_report.txt
retention-days: 30
include-what-you-use:
name: Include-What-You-Use
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y iwyu cmake clang-15
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-15 \
-DCMAKE_CXX_COMPILER=clang++-15 \
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=iwyu
- name: Run IWYU
run: |
cmake --build build 2>&1 | tee iwyu_report.txt || true
- name: Upload IWYU results
uses: actions/upload-artifact@v4
with:
name: iwyu-report
path: iwyu_report.txt
retention-days: 30