Skip to content

Commit 1450d23

Browse files
committed
[ci] Add win32 coverage job
1 parent 5a93397 commit 1450d23

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

‎.github/workflows/coverage.yml‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,122 @@ jobs:
220220
name: coverage-report-gcov
221221
path: build/coverage-gcc/html/
222222
retention-days: 7
223+
224+
coverage-win32:
225+
name: windows-2025-vs2026 / clang-cl / llvm-cov
226+
runs-on: windows-2025-vs2026
227+
timeout-minutes: 20
228+
229+
steps:
230+
- uses: actions/checkout@v5
231+
232+
- name: Install CMake
233+
uses: lukka/get-cmake@latest
234+
with:
235+
cmakeVersion: "4.4.0"
236+
237+
- name: Set up MSVC environment
238+
shell: pwsh
239+
run: |
240+
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
241+
-latest -property installationPath
242+
$vcvars = "$vsPath\VC\Auxiliary\Build\vcvars64.bat"
243+
cmd /c "`"$vcvars`" && set" | ForEach-Object {
244+
if ($_ -match '^([^=]+)=(.*)$') {
245+
"$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
246+
}
247+
}
248+
249+
- name: Locate LLVM coverage tools
250+
shell: pwsh
251+
run: |
252+
$clangPath = (Get-Command clang-cl).Source
253+
$llvmBin = Split-Path $clangPath
254+
$llvmRoot = Split-Path $llvmBin
255+
"LLVM_PROFDATA=$llvmBin\llvm-profdata.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
256+
"LLVM_COV=$llvmBin\llvm-cov.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
257+
258+
$profileLib = Get-ChildItem -Path "$llvmRoot\lib\clang" -Recurse `
259+
-Filter "clang_rt.profile-x86_64.lib" -ErrorAction SilentlyContinue |
260+
Select-Object -First 1 -ExpandProperty FullName
261+
if (-not $profileLib) {
262+
throw "Could not locate clang_rt.profile-x86_64.lib under $llvmRoot"
263+
}
264+
# Use forward slashes: CMake's -D argument parsing treats a bare
265+
# backslash as an escape character and silently drops it.
266+
$profileLib = $profileLib -replace '\\', '/'
267+
"LLVM_PROFILE_LIB=$profileLib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
268+
269+
- name: Configure (coverage)
270+
shell: pwsh
271+
run: |
272+
cmake --preset dev-clang-cl -B build/coverage-win32 `
273+
-DCMAKE_CXX_FLAGS_INIT="-fprofile-instr-generate -fcoverage-mapping" `
274+
"-DCMAKE_EXE_LINKER_FLAGS_INIT=`"$env:LLVM_PROFILE_LIB`""
275+
276+
- name: Build
277+
shell: pwsh
278+
run: cmake --build build/coverage-win32 --config Debug
279+
280+
- name: Test
281+
shell: pwsh
282+
run: |
283+
$env:LLVM_PROFILE_FILE = "$PWD\build\coverage-win32\cov-%p.profraw"
284+
ctest --test-dir build/coverage-win32 --build-config Debug --output-on-failure --no-compress-output
285+
286+
- name: Merge profile data
287+
shell: pwsh
288+
run: |
289+
$profraws = Get-ChildItem -Recurse build/coverage-win32 -Filter *.profraw |
290+
Select-Object -ExpandProperty FullName
291+
& "$env:LLVM_PROFDATA" merge -sparse $profraws -o build/coverage-win32/coverage.profdata
292+
293+
- name: Coverage report
294+
shell: pwsh
295+
run: |
296+
$objects = Get-ChildItem -Recurse build/coverage-win32 -Include *.exe,*.dll |
297+
Where-Object { $_.FullName -match '\\Debug\\' } |
298+
Select-Object -ExpandProperty FullName
299+
$first = $objects[0]
300+
$objArgs = @()
301+
if ($objects.Length -gt 1) {
302+
$objArgs = $objects[1..($objects.Length - 1)] | ForEach-Object { "-object=$_" }
303+
}
304+
$report = & "$env:LLVM_COV" report $first @objArgs `
305+
"-instr-profile=build/coverage-win32/coverage.profdata" `
306+
"-path-equivalence=.,$PWD" `
307+
-use-color=false src include/eggs
308+
$report
309+
if ($env:GITHUB_STEP_SUMMARY) {
310+
"## Coverage report (llvm-cov, win32)" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
311+
"" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
312+
'```' | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
313+
$report | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
314+
'```' | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
315+
}
316+
317+
- name: Generate HTML report
318+
shell: pwsh
319+
run: |
320+
$objects = Get-ChildItem -Recurse build/coverage-win32 -Include *.exe,*.dll |
321+
Where-Object { $_.FullName -match '\\Debug\\' } |
322+
Select-Object -ExpandProperty FullName
323+
$first = $objects[0]
324+
$objArgs = @()
325+
if ($objects.Length -gt 1) {
326+
$objArgs = $objects[1..($objects.Length - 1)] | ForEach-Object { "-object=$_" }
327+
}
328+
& "$env:LLVM_COV" show $first @objArgs `
329+
"-instr-profile=build/coverage-win32/coverage.profdata" `
330+
"-path-equivalence=.,$PWD" `
331+
-format=html `
332+
-output-dir=build/coverage-win32/html `
333+
-show-line-counts-or-regions `
334+
src include/eggs
335+
336+
- name: Upload coverage report
337+
uses: actions/upload-artifact@v6
338+
with:
339+
name: coverage-report-win32-llvm-cov
340+
path: build/coverage-win32/html/
341+
retention-days: 7

0 commit comments

Comments
 (0)