Skip to content

Add a coverage build option and CI job - #266

Open
mmelnich wants to merge 2 commits into
mainfrom
sweep/coverage
Open

mmelnich wants to merge 2 commits into
mainfrom
sweep/coverage

Conversation

@mmelnich

@mmelnich mmelnich commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds code coverage measurement for the library: a GCC build option that instruments the test suite, an instantiation file so template code no test instantiates is counted instead of invisible, and a coverage CI job that reports through gcovr and Codecov. Coverage is reported, not enforced: the job is not a required check and the Codecov statuses are informational.

Changes

  • RandLAPACK_ENABLE_COVERAGE (CMake option, GCC only, default OFF): test/CMakeLists.txt adds --coverage -O0 -g -fprofile-abs-path -fprofile-update=prefer-atomic to the C++ test translation units, which is where a header-only library's code is compiled, and warns if the build type is not Debug. CUDA sources are not instrumented.
  • test/misc/test_instantiations.cc: explicit float and double instantiations, in headers no open PR touches, of class templates and of the member and function templates the tests miss (BK's sparse-matrix call, the sparse-matrix and sketching-operator applies of SparseLinOp and CompositeOperator, and standardize_dataset, which no test calls). gcov sees a template's lines only once something instantiates it; the file also compiles the float versions no test builds. test/drivers/test_instantiations_gpu.cu does the same for BQRRP_GPU and CQRRPT_GPU in the CUDA test executable.
  • .github/workflows/coverage.yaml: a Debug build with the option, the core test suite, then gcovr filtered to RandLAPACK/. Outputs: an HTML report as the coverage-report artifact, a summary on the job page, and Cobertura XML uploaded to Codecov through OpenID Connect (no stored token; the action is pinned to a commit).
  • codecov.yml: informational project and patch statuses; tests, benchmarks, extras and the RandBLAS submodule ignored.
  • Docs: docs/CI.md (the job, what its numbers count, the local recipe), CONTRIBUTING.md (a note for contributors), docs/INSTALL_MANUAL.md (the option).

Lines are merged across template instantiations, so a line counts as covered if any instantiation ran it; functions are counted per instantiation, and branches merge only where the instantiations' control flow matches, so untested float versions can lower those two numbers. On main at 18ddcedb with this PR the report reads lines 4484/5258 (85.3%), branches 3413/6878, functions 521/728. Measured on c9706937, the instantiation file takes the line count from 4326/5058 to 4326/5094.

Codecov is already active for this repository: the first run of the job uploaded its report, and Codecov commented on this PR.

Fixes #127.

RandLAPACK had no coverage measurement. This adds one, as a signal rather
than a gate.

- RandLAPACK_ENABLE_COVERAGE (GCC only): test/CMakeLists.txt instruments
  the C++ test translation units with --coverage at -O0, which is where a
  header-only library's code is compiled, and warns if the build type is
  not Debug.
- test/misc/test_instantiations.cc explicitly instantiates, for float and
  double and in headers no open PR touches, class templates and the member
  and function templates the tests miss (BK's sparse-matrix call, the sparse-matrix and sketching-operator
  applies of SparseLinOp and CompositeOperator, standardize_dataset). An
  uninstantiated template contributes no lines to gcov, so it was
  invisible rather than uncovered. test/drivers/test_instantiations_gpu.cu
  does the same for the two GPU drivers in the CUDA test executable.
- The coverage workflow builds and runs the core suite that way, reports
  with gcovr (HTML artifact, summary on the job page, Cobertura XML) and
  uploads to Codecov through OpenID Connect with informational statuses
  (codecov.yml), so nothing is blocked on a percentage. Lines are merged
  across template instantiations; functions are counted per
  instantiation, and branches merge only where the instantiations' control
  flow matches, so untested float versions can lower those two numbers.
- docs/CI.md (the job, what its numbers count, a local recipe),
  CONTRIBUTING.md and docs/INSTALL_MANUAL.md describe the option.

Verified locally (GCC 15.2, oneMKL ILP64, RTX 5070 Ti), on 18ddced:
- Debug build with the option, reported with the local recipe in
  docs/CI.md: 531 of 533 tests passed, 2 skipped (thread-cap tests); lines
  4484/5258 (85.3%), branches 3413/6878, functions 521/728.
- Release build with CUDA: 587 of 589 tests passed (CPU and GPU, ctest -LE
  exclusive), the same 2 skipped; every float instantiation compiles.
- On c970693, before this commit the report read lines 4326/5058,
  branches 3232/6109, functions 470/552; with it, lines 4326/5094.

Fixes #127.
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

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.

Code coverege for testing

2 participants