-
Notifications
You must be signed in to change notification settings - Fork 3
319 lines (286 loc) · 10.7 KB
/
test.yml
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
name: 'Action test'
on:
pull_request:
paths-ignore:
- '**.md'
push:
branches:
- master
- 'releases/*'
- 'fix/*'
- 'feat/*'
paths-ignore:
- '**.md'
jobs:
fetch-tests:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
# Install a tag from GitHub.
install-custom: true
version: v6.16.0
llvm-version: '13'
- os: ubuntu-22.04
# Install a specific package from PyPI.
install-custom: false
version: 6.17.0
llvm-version: '14'
- os: ubuntu-22.04
# Install a branch from GitHub.
install-custom: true
version: master
llvm-version: 'latest'
- os: ubuntu-22.04
# Install the latest package from PyPI.
install-custom: false
version: master
llvm-version: 'latest'
name: "Fetch: ${{ matrix.os }}, LLVM ${{ matrix.llvm-version }}, ${{ matrix.install-custom && 'repository' || 'pip' }} ${{ matrix.version }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./
id: codechecker
with:
install-custom: ${{ matrix.install-custom }}
version: ${{ matrix.version }}
llvm-version: ${{ matrix.llvm-version }}
logfile: "test/empty/compile_commands.json"
simple-analysis-tests:
strategy:
fail-fast: false
matrix:
logfile: ['', 'test/simple/compile_commands.json']
build-command: ['', 'cd test/simple; g++ -c main.cpp -o main.o']
analyze-output: ['', 'my-output-dir']
name: "Simple analysis: ${{ matrix.logfile && 'logfile' || 'no logfile' }}, ${{ matrix.build-command && 'build-command' || 'no build-command' }}, ${{ matrix.analyze-output && 'analyze-output' || 'no analyze-output'}}"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: test/fix_compile_json_paths.sh
- uses: ./
id: codechecker
# Allow continuing the build, we check "expected failure" for misconfiguration.
continue-on-error: ${{ (matrix.logfile != '') == (matrix.build-command != '') }}
with:
logfile: ${{ matrix.logfile }}
build-command: ${{ matrix.build-command }}
analyze-output: ${{ matrix.analyze-output }}
- name: "Check and reject job if previous test should have failed, but did not"
if: ${{ steps.codechecker.continue-on-error && steps.codechecker.outcome != 'failure' }}
run: |
echo "::error title=Step with expected failure passed::"
exit 1
analyze-cfg:
name: "Analyze: Custom configuration"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: test/fix_compile_json_paths.sh
- uses: ./
with:
config: 'test/codechecker.verbose.json'
logfile: 'test/simple/compile_commands.json'
analyze-ctu:
name: "Analyze: CTU shortcut"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: test/fix_compile_json_paths.sh
- uses: ./
id: codechecker
with:
logfile: 'test/ctu/compile_commands.json'
ctu: true
- name: "Reject test if previous step did not produce CTU finding"
run: cat ${{ steps.codechecker.outputs.result-log }} | grep "Dereference of null pointer"
report-converter:
name: "Report converter: PyLint"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: "Install PyLint"
run: |
sudo apt-get install -y pylint
- name: "Perform static analysis explicitly with PyLint"
run: |
pylint test/report-converter/testpylint.py \
-f json \
--exit-zero \
> ./pylint_reports.json
- uses: ./
id: codechecker
with:
report-converter: true
original-analyser: 'pylint'
original-analysis-output: './pylint_reports.json'
- name: "Reject test if previous step did not produce findings"
run: cat ${{ steps.codechecker.outputs.result-log }} | grep "Explicit return in __init__"
reports-errors:
name: "Parse: Findings are reported"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: test/fix_compile_json_paths.sh
- uses: ./
id: codechecker
continue-on-error: true
with:
logfile: 'test/simple/compile_commands.json'
- name: "Reject test if output isn't as expected"
if: ${{ steps.codechecker.outputs.warnings != 'true' }}
run: |
echo "::error title=fail-on-error test passed::Expected the 'parse' step to report findings."
exit 1
parse-html:
name: "Parse: Generate and upload report HTML artefact"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: test/fix_compile_json_paths.sh
- uses: ./
id: codechecker
with:
logfile: 'test/simple/compile_commands.json'
- uses: actions/upload-artifact@v3
with:
name: "Parse HTML test results"
path: ${{ steps.codechecker.outputs.result-html-dir }}
if-no-files-found: error
store:
name: "Store: Authenticated local store of single result"
runs-on: ubuntu-22.04
env:
CODECHECKER_VERSION: '6.18.1'
steps:
- uses: actions/checkout@v3
# Need to do this manually because the server for this test has to have
# authentication on, with a known username and password.
- name: "Set up CodeChecker server"
run: |
set -x
echo "::group::Installing dependencies"
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends \
netcat \
wget
echo "::endgroup::"
echo "::group::Setting up server configuration"
mkdir -pv ~/codechecker-server-data
chmod 1777 ~/codechecker-server-data
cp test/codechecker.server.json ~/codechecker-server-data/server_config.json
test/prepare-docker-server.sh
echo "::endgroup::"
echo "::group::Debug show CodeChecker server configuration"
cd ~/codechecker-server-data
chown 950:950 server_config.json && chmod 0600 server_config.json
chown 950:950 root.user && chmod 0600 root.user
ls -alh
cat docker-compose.yml
cat root.user
cat server_config.json
echo "::endgroup::"
docker-compose up -d
wget -qO- http://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for | sh -s -- --timeout=30 http://0.0.0.0:8001/ -- echo "CodeChecker up"
docker ps -a
echo "::group::CodeChecker server initial log output"
docker logs codechecker-server
echo "::endgroup::"
- run: test/fix_compile_json_paths.sh
- uses: ./
id: codechecker
continue-on-error: true
with:
version: "${{ env.CODECHECKER_VERSION }}"
logfile: 'test/simple/compile_commands.json'
store: true
store-url: 'http://0.0.0.0:8001/Default'
store-username: 'root'
store-password: 'root'
- name: "Test if server logged store action"
id: test
continue-on-error: true
run: docker logs codechecker-server | grep "stored results"
- name: "Tear down CodeChecker server"
run: |
echo "::group::CodeChecker server log output"
docker logs codechecker-server
echo "::endgroup::"
cd ~/codechecker-server-data
docker-compose down
docker ps -a
- name: "Fail the build if the test execution failed"
if: ${{ steps.test.outcome == 'failure' || steps.codechecker.outcome == 'failure' || steps.codechecker.outputs.store-successful != 'true' }}
run: exit 1
store-production:
name: "Store: Store to a real server"
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'push' }}
env:
CODECHECKER_VERSION: '6.19.1'
steps:
- uses: actions/checkout@v3
- run: test/fix_compile_json_paths.sh
- uses: ./
id: codechecker
continue-on-error: true
with:
version: "${{ env.CODECHECKER_VERSION }}"
logfile: 'test/simple2/compile_commands.json'
store: true
store-url: ${{ secrets.CODECHECKER_URL }}
store-username: ${{ secrets.CODECHECKER_USERNAME }}
store-password: ${{ secrets.CODECHECKER_PASSWORD }}
diff:
name: "Diff: New findings are discovered and reported"
runs-on: ubuntu-22.04
env:
CODECHECKER_VERSION: '6.19.1'
# This time, we do not need authentication, so test with the official Docker subsystem.
services:
codechecker-server:
image: 'codechecker/codechecker-web:6.19.1'
ports:
- 8001:8001/tcp
steps:
- uses: actions/checkout@v3
# Need to do this manually because the server for this test has to have
# authentication on, with a known username and password.
- name: "Wait for CodeChecker server service to go live"
run: |
set -x
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends \
netcat \
wget
wget -qO- http://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for | sh -s -- --timeout=30 http://0.0.0.0:8001/ -- echo "CodeChecker up"
- run: test/fix_compile_json_paths.sh
- name: "Do the first analysis that stores a result"
uses: ./
id: codechecker-store
continue-on-error: true
with:
install-custom: true
version: "v${{ env.CODECHECKER_VERSION }}"
logfile: 'test/simple/compile_commands.json'
store: true
store-url: 'http://0.0.0.0:8001/Default'
- name: "Do the second analysis that finds a new result"
uses: ./
id: codechecker-diff
with:
version: "v${{ env.CODECHECKER_VERSION }}"
logfile: 'test/simple2/compile_commands.json'
diff: true
diff-url: 'http://0.0.0.0:8001/Default'
- uses: actions/upload-artifact@v3
if: ${{ steps.codechecker-diff.outputs.warnings-in-diff == 'true' }}
with:
name: "Diff HTML test results"
path: ${{ steps.codechecker-diff.outputs.diff-html-dir }}
if-no-files-found: error
- name: "Fail the build if the test execution failed"
if: ${{ steps.codechecker-store.outcome == 'failure' || steps.codechecker-diff.outcome == 'failure' || steps.codechecker-store.outputs.store-successful != 'true' || steps.codechecker-diff.outputs.warnings-in-diff != 'true' }}
run: exit 1