-
Notifications
You must be signed in to change notification settings - Fork 0
465 lines (393 loc) · 13.3 KB
/
Copy pathci.yml
File metadata and controls
465 lines (393 loc) · 13.3 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
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
name: ${{ matrix.os }} / ${{ matrix.compiler }} / C++${{ matrix.std }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
compiler: clang-14
std: 17
cc: clang-14
cxx: clang++-14
- os: ubuntu-22.04
compiler: gcc-12
std: 17
cc: gcc-12
cxx: g++-12
- os: ubuntu-22.04
compiler: gcc-12
std: 20
cc: gcc-12
cxx: g++-12
- os: macos-14
compiler: clang
std: 17
cc: clang
cxx: clang++
- os: windows-2022
compiler: msvc
std: 17
cc: cl
cxx: cl
steps:
- uses: actions/checkout@v4
- name: Install tools (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build
- name: Set up MSVC environment (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Configure
shell: bash
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=${{ matrix.std }} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-G Ninja
- name: Build
run: cmake --build build --parallel
- name: Test (single-threaded to avoid TempDir races)
run: ctest --test-dir build --output-on-failure -j1
coverage:
name: Coverage (LCOV)
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get update -qq && sudo apt-get install -y cmake ninja-build lcov
- name: Configure (coverage build)
run: |
cmake -B build-cov \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -O0" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \
-G Ninja
- name: Build
run: cmake --build build-cov --parallel
- name: Test
run: ctest --test-dir build-cov --output-on-failure -j1
- name: Collect LCOV data
run: |
lcov --capture \
--directory build-cov \
--output-file coverage.info
lcov --remove coverage.info \
'*/tests/*' '*/catch2/*' '*/FetchContent/*' '*/_deps/*' \
'/usr/include/*' '/usr/lib/*' \
--output-file coverage.info
- name: Enforce 70% line coverage gate
run: |
COVERAGE=$(lcov --summary coverage.info 2>&1 | awk '/lines/ {gsub(/%/,""); print $2}')
echo "Line coverage: ${COVERAGE}%"
if ! awk "BEGIN {exit (${COVERAGE} + 0 >= 70) ? 0 : 1}"; then
echo "::error::Line coverage ${COVERAGE}% is below the required 70%"
exit 1
fi
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.info
relay-conform:
name: RELAY conformance (relay conform)
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get update -qq && sudo apt-get install -y cmake ninja-build
- name: Build CLI
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-G Ninja
cmake --build build --parallel --target cpp-lin-cli
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Install relay tool
run: go install github.com/SoundMatt/RELAY/cmd/relay@latest
- name: RELAY conformance gate
run: relay conform ./build/cli/cpp-lin-cli --strict
- name: RELAY interop gate (§20 Continuous Conformance)
run: relay interop --protocol LIN ./build/cli/cpp-lin-cli
sanitizers:
name: ASan + UBSan (IEC 61508 SIL-2 dynamic analysis)
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Install tools
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build gcc-12 g++-12
- name: Configure (ASan + UBSan)
env:
CC: gcc-12
CXX: g++-12
run: |
cmake -B build-san \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -O1" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined" \
-G Ninja
- name: Build
run: cmake --build build-san --parallel
- name: Test with sanitizers
env:
ASAN_OPTIONS: "halt_on_error=1:detect_stack_use_after_return=1"
UBSAN_OPTIONS: "halt_on_error=1:print_stacktrace=1"
run: ctest --test-dir build-san --output-on-failure -j1
tsan:
name: ThreadSanitizer (REQ-VIRT-018 concurrent access)
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Install tools
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build gcc-12 g++-12
- name: Configure (ThreadSanitizer)
env:
CC: gcc-12
CXX: g++-12
run: |
cmake -B build-tsan \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer -O1" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread" \
-G Ninja
- name: Build
run: cmake --build build-tsan --parallel
- name: Test with ThreadSanitizer
env:
TSAN_OPTIONS: "halt_on_error=1:second_deadlock_stack=1"
run: ctest --test-dir build-tsan --output-on-failure -j1
fusa-asil-b:
name: cpp-FuSa ASIL-B qualification
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- name: Check out cpp-LIN
uses: actions/checkout@v4
with:
path: cpp-LIN
- name: Check out cpp-FuSa
uses: actions/checkout@v4
with:
repository: SoundMatt/cpp-FuSa
path: cpp-FuSa
- name: Install tools
run: sudo apt-get update -qq && sudo apt-get install -y cmake ninja-build zip
- name: Build cpfusa
run: |
cmake -B cpp-FuSa/build \
-S cpp-FuSa \
-DCMAKE_BUILD_TYPE=Release \
-G Ninja
cmake --build cpp-FuSa/build --parallel
- name: cpfusa init
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa init --name cpp-LIN --standard iso26262 --asil ASIL-B --project-version 0.1.0 --force || true
- name: cpfusa check
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa check --dir .
- name: cpfusa lint
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa lint --dir .
- name: cpfusa trace (requirements traceability)
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa trace --dir .
- name: cpfusa cyber
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa cyber --write --dir .
- name: cpfusa qualify (ASIL-B gate)
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa qualify --dir .
- name: cpfusa hara init
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa hara init --project cpp-LIN --dir . || true
- name: cpfusa iso26262 (ASIL-B)
working-directory: cpp-LIN
run: |
../cpp-FuSa/build/cpfusa iso26262 \
--asil ASIL-B \
--output iso26262-gap-report.json \
--dir . || true
- name: cpfusa iec61508 (SIL-2)
working-directory: cpp-LIN
run: |
../cpp-FuSa/build/cpfusa iec61508 \
--sil SIL-2 \
--output iec61508-gap-report.json \
--dir . || true
- name: cpfusa boundary
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa boundary --dir .
- name: cpfusa tara
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa tara --dir .
- name: cpfusa fmea
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa fmea --dir .
- name: cpfusa safety-case
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa safety-case --dir .
- name: cpfusa sas
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa sas --dir .
- name: cpfusa sci
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa sci --dir .
- name: cpfusa badge
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa badge --dir .
- name: cpfusa vuln
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa vuln --dir .
- name: cpfusa metrics record
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa metrics record --dir .
- name: cpfusa report (JSON)
working-directory: cpp-LIN
run: |
../cpp-FuSa/build/cpfusa report \
--format json \
--output check-report.json \
--dir .
- name: Upload ASIL-B evidence artifacts
uses: actions/upload-artifact@v4
with:
name: asil-b-evidence
path: |
cpp-LIN/check-report.json
cpp-LIN/qualify-report.json
cpp-LIN/cyber-report.json
cpp-LIN/tara.json
cpp-LIN/tara.md
cpp-LIN/fmea.json
cpp-LIN/fmea.csv
cpp-LIN/safety-case.json
cpp-LIN/safety-case.mermaid
cpp-LIN/safety-case.md
cpp-LIN/sbom.json
cpp-LIN/provenance.json
cpp-LIN/artifact-manifest.json
cpp-LIN/fusa-badge.svg
cpp-LIN/iso26262-gap-report.json
cpp-LIN/iec61508-gap-report.json
cpp-LIN/sas.json
cpp-LIN/sas.md
cpp-LIN/sci.json
cpp-LIN/vuln.json
cpp-LIN/boundary.mermaid
cpp-LIN/boundary.dot
cpp-LIN/.fusa-hara.json
cpp-LIN/.fusa-metrics.json
cpp-LIN/TARA.md
cpp-LIN/SAFETY_MANUAL.md
cpp-LIN/INCIDENT-RESPONSE.md
cpp-LIN/SECURITY.md
static-analysis:
name: Static analysis (clang-tidy)
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Install tools
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build clang-14 clang-tidy-14
- name: Configure (generate compile_commands.json)
env:
CC: clang-14
CXX: clang++-14
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-G Ninja
- name: clang-tidy
run: |
find src include -name '*.cpp' -o -name '*.hpp' | \
xargs clang-tidy-14 \
-p build \
--checks='-*,clang-analyzer-*,bugprone-*,modernize-use-override,modernize-use-nullptr,cppcoreguidelines-no-malloc' \
2>&1 | tee clang-tidy.log || true
if grep -q "error:" clang-tidy.log; then
echo "::error::clang-tidy reported errors"
grep "error:" clang-tidy.log
exit 1
fi
docker-build:
name: Docker build (smoke test)
runs-on: ubuntu-22.04
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -f docker/Dockerfile --target test -t cpp-lin-test .
- name: Smoke test - run all tests in container
run: docker run --rm cpp-lin-test
sarif:
name: SARIF upload
runs-on: ubuntu-22.04
needs: build-and-test
permissions:
security-events: write
steps:
- name: Check out cpp-LIN
uses: actions/checkout@v4
with:
path: cpp-LIN
- name: Check out cpp-FuSa
uses: actions/checkout@v4
with:
repository: SoundMatt/cpp-FuSa
path: cpp-FuSa
- name: Install tools
run: sudo apt-get update -qq && sudo apt-get install -y cmake ninja-build
- name: Build cpfusa
run: |
cmake -B cpp-FuSa/build \
-S cpp-FuSa \
-DCMAKE_BUILD_TYPE=Release \
-G Ninja
cmake --build cpp-FuSa/build --parallel
- name: cpfusa init
working-directory: cpp-LIN
run: ../cpp-FuSa/build/cpfusa init --name cpp-LIN --standard iso26262 --asil ASIL-B --project-version 0.1.0 --force || true
- name: Generate SARIF report
working-directory: cpp-LIN
run: |
../cpp-FuSa/build/cpfusa check \
--format sarif \
--output cpfusa.sarif \
--dir . || true
- name: Upload SARIF to GitHub Security tab
if: hashFiles('cpp-LIN/cpfusa.sarif') != ''
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: cpp-LIN/cpfusa.sarif