Skip to content

Add gcovr-based code coverage: local targets, PR reports, Pages - #2872

Closed
cary-ilm wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
cary-ilm:coverage-gcovr
Closed

cary-ilm wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
cary-ilm:coverage-gcovr

Conversation

@cary-ilm

Copy link
Copy Markdown
Member

Provide one shared way to browse gcov line coverage, locally and in CI, without depending on an external service.

Local: add OPENEXR_ENABLE_COVERAGE, which instruments the build with gcov and adds 'coverage', 'coverage-report' and 'coverage-clean' targets that run the tests and generate an HTML report (plus Cobertura XML and a JSON summary) with gcovr. The measured files are configured in gcovr.cfg.

CI: add coverage.yml, which builds with coverage enabled, runs the full test suite, and produces the same gcovr report:

  • every run uploads the HTML report as an artifact and writes overall line/function/branch percentages to the job summary;
  • pull requests also get a coverage table for the changed lines, via diff-cover (informational, never fails the PR); only artifacts and the job summary are used, so PRs from forks work;
  • pushes to main publish the HTML report to GitHub Pages.

gcovr and diff-cover are installed from a hash-pinned requirements file, share/ci/requirements/coverage.txt, generated from coverage.in.

Assisted-by: Copilot / Claude Opus 4.8

…Pages

Provide one shared way to browse gcov line coverage, locally and in
CI, without depending on an external service (SonarCloud).

Local: add OPENEXR_ENABLE_COVERAGE, which instruments the build with
gcov and adds 'coverage', 'coverage-report' and 'coverage-clean'
targets that run the tests and generate an HTML report (plus Cobertura
XML and a JSON summary) with gcovr. The measured files are configured
in gcovr.cfg.

CI: add coverage.yml, which builds with coverage enabled, runs the full
test suite, and produces the same gcovr report. The instrumented build
and full test run are slow, so the workflow does not run on every pull
request. It runs weekly (Sunday, after the full build), on demand via
workflow_dispatch on any branch, and on a pull request when a
maintainer applies the 'coverage' label. Each run:

- uploads the HTML report as an artifact and writes overall
  line/function/branch percentages to the job summary;
- for a pull request or a manual run on a branch, adds a coverage table
  for the changed lines against the base branch, via diff-cover
  (informational, never fails the run); only artifacts and the job
  summary are used, so PRs from forks work;
- on main, publishes the HTML report to GitHub Pages.

gcovr and diff-cover are installed from a hash-pinned requirements
file, share/ci/requirements/coverage.txt, generated from coverage.in.

Assisted-by: Copilot / Claude Sonnet 5.5

Signed-off-by: Cary Phillips <seabeepea@gmail.com>
@cary-ilm

Copy link
Copy Markdown
Member Author

Closing in favor of #2897

@cary-ilm cary-ilm closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant