Skip to content

Commit d0783c5

Browse files
committed
Parallelize jobs
1 parent 1843a9e commit d0783c5

File tree

3 files changed

+110
-51
lines changed

3 files changed

+110
-51
lines changed

.github/workflows/build-and-test.yml renamed to .github/workflows/verify-and-validate.yml

Lines changed: 108 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,35 @@
11
# TODO: Use Infer
2-
# TODO: Use GCC
32
# TODO: Create commit-hook for auto-formatting
43
# TODO: Add valgrind / etc. style of tools
54
# TODO: Add seahorn (export results as sarif into sonar)
65
# TODO: add frama-c with clang plugin (export results as sarif into sonar)
76
# TODO: introduce msys2 via opam on the windows image as opam is also needed for infer, frama-c, offers GCC
87
# TODO: Add formatting check
9-
name: Build and Test
10-
11-
on:
12-
push:
8+
name: Verify and Validate
9+
on: push
10+
env:
11+
# Needed by vcpkg to find the binary cache and
12+
# restore dependencies like Boost faster.
13+
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
1314

1415
jobs:
15-
build-and-test:
16+
build-with-gcc:
1617
runs-on: windows-latest
17-
env:
18-
# Needed by vcpkg to find the binary cache and
19-
# restore dependencies like Boost faster.
20-
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
2118
steps:
19+
# No need to check out the submodule as Doxygen documentation is not
20+
# built.
2221
- name: Checkout repository
2322
uses: actions/checkout@v4
24-
with:
25-
submodules: recursive
2623

2724
# Rebuilding all vcpkg dependencies at each commit is time consuming,
2825
# in particular when Boost is a dependency. So cache binaries.
29-
# https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache
3026
- name: Export GitHub Actions cache environment variables
3127
uses: actions/github-script@v7
3228
with:
3329
script: |
3430
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
3531
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
3632
37-
- name: Install Doxygen
38-
uses: ssciwr/doxygen-install@v1
39-
40-
- name: Install OpenCppCoverage
41-
uses: KungFuDonkey/Install-OpenCppCoverage@v1
42-
43-
- name: Install cppcheck
44-
run: |
45-
$url = "https://github.com/danmar/cppcheck/releases/download/2.17.1/cppcheck-2.17.1-x64-Setup.msi"
46-
$output = "cppcheck.msi"
47-
Invoke-WebRequest -Uri $url -OutFile $output
48-
Start-Process `
49-
-FilePath msiexec `
50-
-ArgumentList "/package $output /quiet /norestart" `
51-
-NoNewWindow `
52-
-Wait
53-
Start-Process `
54-
-FilePath "C:\Program Files\Cppcheck\cppcheck.exe" `
55-
-ArgumentList "--version" `
56-
-NoNewWindow `
57-
-Wait
58-
59-
- name: Install behave
60-
run: |
61-
pip install behave
62-
behave --version
63-
6433
# Module dependency scanning support in CMake requires GCC 14+
6534
- name: Update GCC
6635
shell: C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 {0}
@@ -71,6 +40,8 @@ jobs:
7140
pacboy -S --noconfirm toolchain:p
7241
gcc --version
7342
43+
# Use full path for MSYS2 to use the CMake of MSVC as MSYS2's CMake
44+
# fails to compile sqlite3.
7445
- name: Build (GCC)
7546
shell: C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 -use-full-path {0}
7647
env:
@@ -79,21 +50,39 @@ jobs:
7950
run: |
8051
cmake --workflow --preset x64-Debug-GCC
8152
82-
- name: Build (MSVC)
83-
uses: lukka/run-cmake@v10
84-
env:
85-
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
53+
build-with-msvc-and-run-tests:
54+
runs-on: windows-latest
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
8658
with:
87-
workflowPreset: x64-Debug-MSVC
59+
submodules: recursive
8860

89-
- name: Build (Clang)
61+
- name: Export GitHub Actions cache environment variables
62+
uses: actions/github-script@v7
63+
with:
64+
script: |
65+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
66+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
67+
68+
- name: Install Doxygen
69+
uses: ssciwr/doxygen-install@v1
70+
71+
- name: Install OpenCppCoverage
72+
uses: KungFuDonkey/Install-OpenCppCoverage@v1
73+
74+
- name: Install behave
75+
run: |
76+
pip install behave
77+
behave --version
78+
79+
- name: Build (MSVC)
9080
uses: lukka/run-cmake@v10
9181
env:
9282
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
93-
LLVM_PATH: C:/Program Files/LLVM/bin/
9483
with:
95-
workflowPreset: x64-Debug-Clang
96-
84+
workflowPreset: x64-Debug-MSVC
85+
9786
- name: Run unit tests
9887
run: |
9988
$dir = "${{ github.workspace }}\out\x64-Debug-MSVC"
@@ -147,6 +136,54 @@ jobs:
147136
$outputWriter.Close()
148137
}
149138
139+
- name: Save test, coverage and analysis results
140+
uses: actions/upload-artifact@v4
141+
with:
142+
name: test-coverage-and-analysis-results
143+
retention-days: 1
144+
path: |
145+
${{ github.workspace }}\out\x64-Debug-MSVC\reports\TESTS-*.xml
146+
${{ github.workspace }}\out\x64-Debug-MSVC\unit-test-coverage.xml
147+
${{ github.workspace }}\out\x64-Debug-MSVC\system-test-coverage.xml
148+
${{ github.workspace }}\out\x64-Debug-MSVC\msvc.sarif
149+
150+
build-with-clang-and-analyze:
151+
runs-on: windows-latest
152+
steps:
153+
- name: Checkout repository
154+
uses: actions/checkout@v4
155+
156+
- name: Export GitHub Actions cache environment variables
157+
uses: actions/github-script@v7
158+
with:
159+
script: |
160+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
161+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
162+
163+
- name: Install cppcheck
164+
run: |
165+
$url = "https://github.com/danmar/cppcheck/releases/download/2.17.1/cppcheck-2.17.1-x64-Setup.msi"
166+
$output = "cppcheck.msi"
167+
Invoke-WebRequest -Uri $url -OutFile $output
168+
Start-Process `
169+
-FilePath msiexec `
170+
-ArgumentList "/package $output /quiet /norestart" `
171+
-NoNewWindow `
172+
-Wait
173+
Start-Process `
174+
-FilePath "C:\Program Files\Cppcheck\cppcheck.exe" `
175+
-ArgumentList "--version" `
176+
-NoNewWindow `
177+
-Wait
178+
179+
- name: Build (Clang)
180+
uses: lukka/run-cmake@v10
181+
env:
182+
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
183+
LLVM_PATH: C:/Program Files/LLVM/bin/
184+
with:
185+
workflowPreset: x64-Debug-Clang
186+
150187
# This step depends on the compile commands database created by CMake for
151188
# the Clang build.
152189
- name: Analyze (cppcheck)
@@ -159,6 +196,28 @@ jobs:
159196
"--output-format=sarif" `
160197
-NoNewWindow `
161198
-Wait
199+
200+
- name: Save compile commands database and analysis results
201+
uses: actions/upload-artifact@v4
202+
with:
203+
name: compile-command-database-and-analysis-results
204+
retention-days: 1
205+
path: |
206+
${{ github.workspace }}\out\x64-Debug-Clang\compile_commands.json
207+
${{ github.workspace }}\out\x64-Debug-Clang\cppcheck.sarif
208+
209+
quality-gate:
210+
runs-on: windows-latest
211+
needs:
212+
- build-with-gcc
213+
- build-with-msvc-and-run-tests
214+
- build-with-clang-and-analyze
215+
steps:
216+
- name: Checkout repository
217+
uses: actions/checkout@v4
218+
219+
- name: Restore compile commands database, test, coverage and analysis results
220+
uses: actions/download-artifact@v4
162221

163222
# This step depends on the compile commands database created by CMake for
164223
# the Clang build.

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"esp.extensions": "cppcorecheck.dll"
3535
},
3636
"cacheVariables": {
37-
"CMAKE_CXX_FLAGS": "/WX /W4 /EHsc /bigobj /external:anglebrackets /analyze /analyze:pluginEspXEngine.dll /analyze:log \"${sourceDir}/out/${presetName}/analysis.sarif\" /analyze:external- /DEBUG"
37+
"CMAKE_CXX_FLAGS": "/WX /W4 /EHsc /bigobj /external:anglebrackets /analyze /analyze:pluginEspXEngine.dll /analyze:log \"${sourceDir}/out/${presetName}/msvc.sarif\" /analyze:external- /DEBUG"
3838
}
3939
},
4040
{

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ sonar.cfamily.compile-commands=out/x64-Debug-Clang/compile_commands.json
1515
sonar.cfamily.cobertura.reportPaths=out/x64-Debug-MSVC/unit-test-coverage.xml,out/x64-Debug-MSVC/system-test-coverage.xml
1616
sonar.cfamily.cppunit.reportsPath=out/x64-Debug-MSVC/reports/
1717

18-
sonar.sarifReportPaths=out/x64-Debug-Clang/cppcheck.sarif,out/x64-Debug-MSVC/analysis.sarif
18+
sonar.sarifReportPaths=out/x64-Debug-Clang/cppcheck.sarif,out/x64-Debug-MSVC/msvc.sarif

0 commit comments

Comments
 (0)