Skip to content

Commit a239ca7

Browse files
committed
Build Windows and MacOS with two-pass to match Linux
1 parent d228a02 commit a239ca7

File tree

1 file changed

+69
-7
lines changed

1 file changed

+69
-7
lines changed

.github/workflows/code-coverage.yml

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
- 'src/**'
2828
- 'include/**'
2929
- '.github/workflows/code-coverage.yml'
30+
pull_request:
31+
branches:
32+
- master
33+
- develop
3034
workflow_dispatch:
3135

3236
concurrency:
@@ -242,24 +246,53 @@ jobs:
242246
module=$(basename ${GITHUB_REPOSITORY})
243247
mkdir -p gcovr
244248
249+
# First pass: collect raw coverage data into JSON
245250
gcovr \
246251
--root boost-root \
247252
--gcov-executable "xcrun llvm-cov gcov" \
248253
--merge-mode-functions separate \
249254
--sort uncovered-percent \
250-
--html-nested \
251-
--html-template-dir=ci-automation/gcovr-templates/html \
252255
--html-title "${module}" \
256+
--merge-lines \
253257
--exclude-unreachable-branches \
254258
--exclude-throw-branches \
255259
--exclude '.*/extra/.*' \
256260
--exclude '.*/example/.*' \
257261
--exclude '.*/examples/.*' \
258262
--filter ".*/${module}/.*" \
259-
--json-summary gcovr/summary.json \
260263
--html --output gcovr/index.html \
264+
--json-summary-pretty --json-summary gcovr/summary.json \
265+
--json gcovr/coverage-raw.json \
261266
boost-root/__build_cmake_test__
262267
268+
# Fix paths for repo-relative display
269+
python3 ci-automation/scripts/fix_paths.py \
270+
gcovr/coverage-raw.json \
271+
gcovr/coverage-fixed.json \
272+
--repo "${module}"
273+
274+
# Create symlinks so gcovr can find source files at repo-relative paths
275+
ln -sfn "boost-root/libs/${module}/include" include 2>/dev/null || true
276+
ln -sfn "boost-root/libs/${module}/src" src 2>/dev/null || true
277+
278+
# Second pass: generate nested HTML from fixed JSON with custom templates
279+
gcovr \
280+
-a gcovr/coverage-fixed.json \
281+
--merge-mode-functions separate \
282+
--sort uncovered-percent \
283+
--html-nested \
284+
--html-template-dir=ci-automation/gcovr-templates/html \
285+
--html-title "${module}" \
286+
--merge-lines \
287+
--exclude-unreachable-branches \
288+
--exclude-throw-branches \
289+
--exclude '(^|.*/)test/.*' \
290+
--exclude '.*/extra/.*' \
291+
--exclude '.*/example/.*' \
292+
--exclude '.*/examples/.*' \
293+
--html --output gcovr/index.html \
294+
--json-summary-pretty --json-summary gcovr/summary.json
295+
263296
- name: Generate sidebar navigation
264297
run: python3 ci-automation/scripts/gcovr_build_tree.py gcovr
265298

@@ -438,23 +471,52 @@ jobs:
438471
module=$(basename ${GITHUB_REPOSITORY})
439472
mkdir -p gcovr
440473
474+
# First pass: collect raw coverage data into JSON
441475
gcovr \
442476
--root boost-root \
443477
--merge-mode-functions separate \
444478
--sort uncovered-percent \
445-
--html-nested \
446-
--html-template-dir=ci-automation/gcovr-templates/html \
447479
--html-title "${module}" \
480+
--merge-lines \
448481
--exclude-unreachable-branches \
449482
--exclude-throw-branches \
450483
--exclude '.*/extra/.*' \
451484
--exclude '.*/example/.*' \
452485
--exclude '.*/examples/.*' \
453486
--filter ".*/${module}/.*" \
454-
--json-summary gcovr/summary.json \
455487
--html --output gcovr/index.html \
488+
--json-summary-pretty --json-summary gcovr/summary.json \
489+
--json gcovr/coverage-raw.json \
456490
boost-root/__build_cmake_test__
457491
492+
# Fix paths for repo-relative display
493+
python3 ci-automation/scripts/fix_paths.py \
494+
gcovr/coverage-raw.json \
495+
gcovr/coverage-fixed.json \
496+
--repo "${module}"
497+
498+
# Create symlinks so gcovr can find source files at repo-relative paths
499+
ln -sfn "boost-root/libs/${module}/include" include 2>/dev/null || true
500+
ln -sfn "boost-root/libs/${module}/src" src 2>/dev/null || true
501+
502+
# Second pass: generate nested HTML from fixed JSON with custom templates
503+
gcovr \
504+
-a gcovr/coverage-fixed.json \
505+
--merge-mode-functions separate \
506+
--sort uncovered-percent \
507+
--html-nested \
508+
--html-template-dir=ci-automation/gcovr-templates/html \
509+
--html-title "${module}" \
510+
--merge-lines \
511+
--exclude-unreachable-branches \
512+
--exclude-throw-branches \
513+
--exclude '(^|.*/)test/.*' \
514+
--exclude '.*/extra/.*' \
515+
--exclude '.*/example/.*' \
516+
--exclude '.*/examples/.*' \
517+
--html --output gcovr/index.html \
518+
--json-summary-pretty --json-summary gcovr/summary.json
519+
458520
- name: Generate sidebar navigation
459521
run: python3 ci-automation/scripts/gcovr_build_tree.py gcovr
460522

@@ -469,7 +531,7 @@ jobs:
469531

470532
deploy:
471533
needs: [build-linux, build-macos, build-windows]
472-
if: ${{ !cancelled() }}
534+
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
473535
defaults:
474536
run:
475537
shell: bash

0 commit comments

Comments
 (0)