-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (146 loc) · 5.11 KB
/
static-analysis.yml
File metadata and controls
169 lines (146 loc) · 5.11 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
160
161
162
163
164
165
166
167
168
169
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 database_system
uses: actions/checkout@v6
with:
submodules: recursive
- name: Checkout common_system
uses: actions/checkout@v6
with:
repository: kcenon/common_system
path: common_system
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
sudo apt-get update
# Use Clang 18 and clang-tidy-18 for full C++20 std::format support
sudo apt-get install -y cmake ninja-build clang-18 clang-tidy-18 libgtest-dev libgmock-dev
- name: Build and install common_system
run: |
cd common_system
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DUSE_UNIT_TEST=OFF \
-DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18
cmake --build build --config Release
sudo cmake --install build --prefix /usr/local
- name: Configure CMake
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_C_COMPILER=clang-18 \
-DUSE_UNIT_TEST=OFF \
-DBUILD_DATABASE_SAMPLES=OFF \
-DALLOW_BUILD_WITHOUT_NETWORK_SYSTEM=ON \
-DUSE_POSTGRESQL=OFF \
-DUSE_SQLITE=OFF
- name: Run clang-tidy
continue-on-error: true # Phase 0: Allow failures, collect baseline
run: |
# Find all C++ source and header files in database directory
# Use clang-tidy-18 for full C++20 std::format support
find database -name "*.h" -o -name "*.hpp" | while read file; do
echo "Analyzing: $file"
clang-tidy-18 "$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@v7
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@v6
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 database \
database 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@v7
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