forked from LoneGazebo/Community-Patch-DLL
-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (190 loc) · 6.39 KB
/
cppcheck.yml
File metadata and controls
217 lines (190 loc) · 6.39 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: cppcheck
on:
workflow_dispatch:
env:
CPPCHECK_VERSION: "2.18.0"
jobs:
detect-changes:
name: Detect File Changes
runs-on: ubuntu-22.04
timeout-minutes: 5
outputs:
cpp-files: ${{ steps.filter.outputs.cpp-files }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Filter Changed Paths
uses: dorny/paths-filter@v3
id: filter
with:
token: ''
filters: |
cpp-files:
- 'CvGameCoreDLL_Expansion2/**'
- 'CvGameCoreDLLUtil/**'
- 'CvGameDatabase/**'
- 'CvLocalization/**'
- 'CvWorldBuilderMap/**'
- 'FirePlace/**'
- 'ThirdPartyLibs/**'
- '*.cpp'
- '*.h'
- '*.sln'
- '*.vcxproj'
- '.github/workflows/cppcheck.yml'
- name: Changes Summary
run: |
echo "### 🔍 File Changes Summary" >> $GITHUB_STEP_SUMMARY
echo "- C++ Files: ${{ steps.filter.outputs.cpp-files == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
build_cppcheck:
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.cpp-files == 'true' }}
runs-on: ubuntu-22.04
steps:
- name: Restore cached cppcheck
id: cache-cppcheck
uses: actions/cache@v4
with:
path: /tmp/cppcheck-build
key: cppcheck-${{ env.CPPCHECK_VERSION }}
- name: Build cppcheck
if: steps.cache-cppcheck.outputs.cache-hit != 'true'
run: |
cd /tmp
git clone https://github.com/danmar/cppcheck.git
cd cppcheck
git checkout ${{ env.CPPCHECK_VERSION }}
make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"
mkdir -p ../cppcheck-build
cp cppcheck ../cppcheck-build/
cp -r cfg ../cppcheck-build/
chmod +x ../cppcheck-build/cppcheck
../cppcheck-build/cppcheck --version
- name: Upload cppcheck build
uses: actions/upload-artifact@v4
with:
name: cppcheck-build
path: /tmp/cppcheck-build/
retention-days: 1
analysis:
needs: [detect-changes, build_cppcheck]
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.cpp-files == 'true' }}
runs-on: ubuntu-22.04
continue-on-error: true
outputs:
timed_out: ${{ steps.check-timeout.outputs.timed_out }}
env:
TIMEOUT_EXIT_CODE: 124
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download cppcheck build
uses: actions/download-artifact@v4
with:
name: cppcheck-build
path: ./cppcheck-build
- name: Setup cppcheck
run: |
chmod +x ./cppcheck-build/cppcheck
echo "$PWD/cppcheck-build" >> $GITHUB_PATH
- name: Verify cppcheck
run: cppcheck --version
- name: Make build-dir
run: mkdir build-dir
- uses: actions/cache@v4
id: cache-build-dir
with:
path: ./build-dir/
key: build-dir-${{ hashFiles('**/*.*') }}
restore-keys: |
build-dir-
- name: Determine number of CPU threads
id: cpu-info
run: echo "cpu_count=$(nproc)" >> $GITHUB_OUTPUT
- name: Run cppcheck analysis
id: cppcheck
run: |
timeout --signal=SIGTERM 350m cppcheck -j ${{ steps.cpu-info.outputs.cpu_count }} \
--project=VoxPopuli_vs2013.sln \
--check-level=exhaustive \
--max-ctu-depth=10 \
--cppcheck-build-dir=build-dir \
--enable=all \
--std=c++03 \
--verbose \
--check-library \
--inline-suppr \
--platform=win32W \
--xml 2> cppcheck.xml || exit_code=$?
echo "exit_code=${exit_code:-0}" >> $GITHUB_ENV
- name: Check timeout status
id: check-timeout
if: always()
run: |
if [ "${exit_code:-0}" = "$TIMEOUT_EXIT_CODE" ]; then
echo "timed_out=true" >> $GITHUB_OUTPUT
else
echo "timed_out=false" >> $GITHUB_OUTPUT
fi
- name: Upload analysis artifacts
if: success() && steps.check-timeout.outputs.timed_out != 'true'
uses: actions/upload-artifact@v4
with:
name: cppcheck-xml
path: |
cppcheck.xml
retention-days: 90
retry_analysis:
needs: [detect-changes, build_cppcheck, analysis]
runs-on: ubuntu-22.04
if: ${{ needs.analysis.outputs.timed_out == 'true' && (github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.cpp-files == 'true') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download cppcheck build
uses: actions/download-artifact@v4
with:
name: cppcheck-build
path: ./cppcheck-build
- name: Setup cppcheck
run: |
chmod +x ./cppcheck-build/cppcheck
echo "$PWD/cppcheck-build" >> $GITHUB_PATH
- name: Verify cppcheck
run: cppcheck --version
- name: Make build-dir
run: mkdir build-dir
- uses: actions/cache@v4
id: cache-build-dir
with:
path: ./build-dir/
key: build-dir-${{ hashFiles('**/*.*') }}
restore-keys: |
build-dir-
- name: Determine number of CPU threads
id: cpu-info
run: echo "cpu_count=$(nproc)" >> $GITHUB_OUTPUT
- name: Run cppcheck analysis
id: cppcheck
continue-on-error: true
run: |
timeout --signal=SIGTERM 350m cppcheck -j ${{ steps.cpu-info.outputs.cpu_count }} \
--project=VoxPopuli_vs2013.sln \
--check-level=exhaustive \
--max-ctu-depth=10 \
--cppcheck-build-dir=build-dir \
--enable=all \
--std=c++03 \
--verbose \
--check-library \
--inline-suppr \
--platform=win32W \
--xml 2> cppcheck.xml || echo "cppcheck exit code: $?"
- name: Upload analysis artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-xml
path: |
cppcheck.xml
retention-days: 90