Repository navigation
341 lines (296 loc) · 12.2 KB
/
Copy pathcoverage.yml
File metadata and controls
341 lines (296 loc) · 12.2 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
# Eggs.Stacktrace
#
# Copyright (c) 2026 Agustin Berge
#
name: coverage
on:
push:
branches: [ main, feature/** ]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
coverage:
name: ubuntu-24.04 / llvm-cov
runs-on: ubuntu-24.04
timeout-minutes: 6
steps:
- uses: actions/checkout@v5
- name: Install CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: "4.4.0"
- name: Set up APT package cache
run: |
mkdir -p ~/.cache/apt/archives/partial
echo "Dir::Cache::archives \"$HOME/.cache/apt/archives\";" \
| sudo tee /etc/apt/apt.conf.d/99user-cache
- name: Cache APT packages
uses: actions/cache@v5
with:
path: ~/.cache/apt/archives
key: apt-ubuntu-24.04-clang-22-${{ hashFiles('.github/workflows/coverage.yml') }}
restore-keys: apt-ubuntu-24.04-clang-22-
- name: Install Clang 22
run: |
wget -q https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 22 all
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 200
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 200
- name: Install libstdc++-16
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y g++-16
- name: Fix APT cache permissions
if: always()
run: sudo rm -rf ~/.cache/apt/archives/lock ~/.cache/apt/archives/partial
- name: Configure (coverage)
run: |
cmake --preset dev-clang -B build/coverage \
-DCMAKE_CXX_FLAGS_INIT="--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/16 -fprofile-instr-generate -fcoverage-mapping" \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fprofile-instr-generate"
- name: Build
run: cmake --build build/coverage --config Debug
- name: Test
run: |
LLVM_PROFILE_FILE="${GITHUB_WORKSPACE}/build/coverage/cov-%p.profraw" \
ctest --test-dir build/coverage --build-config Debug \
--output-on-failure --no-compress-output
- name: Merge profile data
run: |
llvm-profdata-22 merge -sparse build/coverage/cov-*.profraw \
-o build/coverage/coverage.profdata
- name: Coverage report
run: |
mapfile -t objects < <(find build/coverage -path "*/Debug/*" -type f -perm /111)
first="${objects[0]}"
obj_args=()
for o in "${objects[@]:1}"; do obj_args+=("-object=$o"); done
report=$(llvm-cov-22 report "$first" "${obj_args[@]}" \
-instr-profile=build/coverage/coverage.profdata \
-path-equivalence=".,${GITHUB_WORKSPACE}" \
-use-color=false src include/eggs 2>/dev/null)
echo "$report"
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
{
echo "## Coverage report (llvm-cov)"
echo
echo '```'
echo "$report"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
fi
- name: Generate HTML report
run: |
mapfile -t objects < <(find build/coverage -path "*/Debug/*" -type f -perm /111)
first="${objects[0]}"
obj_args=()
for o in "${objects[@]:1}"; do obj_args+=("-object=$o"); done
llvm-cov-22 show "$first" "${obj_args[@]}" \
-instr-profile=build/coverage/coverage.profdata \
-path-equivalence=".,${GITHUB_WORKSPACE}" \
-format=html \
-output-dir=build/coverage/html \
-show-line-counts-or-regions \
src include/eggs 2>/dev/null
- name: Upload coverage report
uses: actions/upload-artifact@v6
with:
name: coverage-report-llvm-cov
path: build/coverage/html/
retention-days: 7
coverage-gcov:
name: ubuntu-24.04 / gcov
runs-on: ubuntu-24.04
timeout-minutes: 6
steps:
- uses: actions/checkout@v5
- name: Install CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: "4.4.0"
- name: Set up APT package cache
run: |
mkdir -p ~/.cache/apt/archives/partial
echo "Dir::Cache::archives \"$HOME/.cache/apt/archives\";" \
| sudo tee /etc/apt/apt.conf.d/99user-cache
- name: Cache APT packages
uses: actions/cache@v5
with:
path: ~/.cache/apt/archives
key: apt-ubuntu-24.04-gcc-16-${{ hashFiles('.github/workflows/coverage.yml') }}
restore-keys: apt-ubuntu-24.04-gcc-16-
- name: Install GCC 16
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -q
sudo apt-get install -y gcc-16 g++-16
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-16 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-16
- name: Install lcov
run: |
sudo apt-get install -y libcapture-tiny-perl libdatetime-perl libtimedate-perl
curl -sL https://github.com/linux-test-project/lcov/releases/download/v2.4/lcov-2.4.tar.gz \
| tar xz -C "$HOME"
echo "$HOME/lcov-2.4/bin" >> "$GITHUB_PATH"
- name: Fix APT cache permissions
if: always()
run: sudo rm -rf ~/.cache/apt/archives/lock ~/.cache/apt/archives/partial
- name: Configure (coverage)
run: |
cmake --preset dev-gcc -B build/coverage-gcc \
-DCMAKE_CXX_FLAGS_INIT="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS_INIT="--coverage"
- name: Build
run: cmake --build build/coverage-gcc --config Debug
- name: Test
run: |
find build/coverage-gcc -name "*.gcda" -delete
ctest --test-dir build/coverage-gcc --build-config Debug \
--output-on-failure --no-compress-output
- name: Collect coverage
run: |
lcov --capture \
--gcov-tool gcov-16 \
--rc branch_coverage=1 \
--ignore-errors mismatch,inconsistent \
--base-directory . \
--directory build/coverage-gcc \
--output-file build/coverage-gcc/coverage.info
lcov --extract build/coverage-gcc/coverage.info \
'*/src/*' '*/include/eggs/*' \
--rc branch_coverage=1 \
--ignore-errors unused \
--output-file build/coverage-gcc/coverage.info
- name: Coverage report
run: |
report=$(lcov --list build/coverage-gcc/coverage.info --rc branch_coverage=1)
echo "$report"
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
{
echo "## Coverage report (gcov)"
echo
echo '```'
echo "$report"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
fi
- name: Generate HTML report
run: |
genhtml build/coverage-gcc/coverage.info \
--output-directory build/coverage-gcc/html \
--rc branch_coverage=1 \
--quiet
- name: Upload coverage report
uses: actions/upload-artifact@v6
with:
name: coverage-report-gcov
path: build/coverage-gcc/html/
retention-days: 7
coverage-win32:
name: windows-2025-vs2026 / clang-cl / llvm-cov
runs-on: windows-2025-vs2026
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
- name: Install CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: "4.4.0"
- name: Set up MSVC environment
shell: pwsh
run: |
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
-latest -property installationPath
$vcvars = "$vsPath\VC\Auxiliary\Build\vcvars64.bat"
cmd /c "`"$vcvars`" && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
"$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
}
- name: Locate LLVM coverage tools
shell: pwsh
run: |
$clangPath = (Get-Command clang-cl).Source
$llvmBin = Split-Path $clangPath
$llvmRoot = Split-Path $llvmBin
"LLVM_PROFDATA=$llvmBin\llvm-profdata.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"LLVM_COV=$llvmBin\llvm-cov.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$profileLib = Get-ChildItem -Path "$llvmRoot\lib\clang" -Recurse `
-Filter "clang_rt.profile-x86_64.lib" -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty FullName
if (-not $profileLib) {
throw "Could not locate clang_rt.profile-x86_64.lib under $llvmRoot"
}
# Use forward slashes: CMake's -D argument parsing treats a bare
# backslash as an escape character and silently drops it.
$profileLib = $profileLib -replace '\\', '/'
"LLVM_PROFILE_LIB=$profileLib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Configure (coverage)
shell: pwsh
run: |
cmake --preset dev-clang-cl -B build/coverage-win32 `
-DCMAKE_CXX_FLAGS_INIT="-fprofile-instr-generate -fcoverage-mapping" `
"-DCMAKE_EXE_LINKER_FLAGS_INIT=`"$env:LLVM_PROFILE_LIB`""
- name: Build
shell: pwsh
run: cmake --build build/coverage-win32 --config Debug
- name: Test
shell: pwsh
run: |
$env:LLVM_PROFILE_FILE = "$PWD\build\coverage-win32\cov-%p.profraw"
ctest --test-dir build/coverage-win32 --build-config Debug --output-on-failure --no-compress-output
- name: Merge profile data
shell: pwsh
run: |
$profraws = Get-ChildItem -Recurse build/coverage-win32 -Filter *.profraw |
Select-Object -ExpandProperty FullName
& "$env:LLVM_PROFDATA" merge -sparse $profraws -o build/coverage-win32/coverage.profdata
- name: Coverage report
shell: pwsh
run: |
$objects = Get-ChildItem -Recurse build/coverage-win32 -Include *.exe,*.dll |
Where-Object { $_.FullName -match '\\Debug\\' } |
Select-Object -ExpandProperty FullName
$first = $objects[0]
$objArgs = @()
if ($objects.Length -gt 1) {
$objArgs = $objects[1..($objects.Length - 1)] | ForEach-Object { "-object=$_" }
}
$report = & "$env:LLVM_COV" report $first @objArgs `
"-instr-profile=build/coverage-win32/coverage.profdata" `
"-path-equivalence=.,$PWD" `
-use-color=false src include/eggs
$report
if ($env:GITHUB_STEP_SUMMARY) {
"## Coverage report (llvm-cov, win32)" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
"" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
'```' | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
$report | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
'```' | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
}
- name: Generate HTML report
shell: pwsh
run: |
$objects = Get-ChildItem -Recurse build/coverage-win32 -Include *.exe,*.dll |
Where-Object { $_.FullName -match '\\Debug\\' } |
Select-Object -ExpandProperty FullName
$first = $objects[0]
$objArgs = @()
if ($objects.Length -gt 1) {
$objArgs = $objects[1..($objects.Length - 1)] | ForEach-Object { "-object=$_" }
}
& "$env:LLVM_COV" show $first @objArgs `
"-instr-profile=build/coverage-win32/coverage.profdata" `
"-path-equivalence=.,$PWD" `
-format=html `
-output-dir=build/coverage-win32/html `
-show-line-counts-or-regions `
src include/eggs
- name: Upload coverage report
uses: actions/upload-artifact@v6
with:
name: coverage-report-win32-llvm-cov
path: build/coverage-win32/html/
retention-days: 7