Skip to content

ci(coverage): instrument the PostgreSQL integration tests - #431

Merged
mariusmm merged 1 commit into
mainfrom
ci/instrument-postgres-integration-tests
Oct 29, 2026
Merged

mariusmm merged 1 commit into
mainfrom
ci/instrument-postgres-integration-tests

Conversation

@mariusmm

Copy link
Copy Markdown
Collaborator

Why

The backend coverage report shows the real PostgreSQL layer, repository/diesel_repo, at about 5%, although CI runs integration tests against it.

The seven PostgreSQL integration tests start with #![cfg(not(feature = "test-helpers"))]. The workspace coverage run (cargo cov --workspace) enables test-helpers through marreq-server/marreq-cloud, so they compile out of it. CI ran them earlier with plain cargo test, which is not instrumented, so their coverage was never recorded.

What

In .github/workflows/marreq-ci.yml, job test-and-coverage:

  • Add a Clean coverage data step (cargo cov clean --workspace) before the Postgres tests.
  • Run each of the seven tests as cargo cov --no-report -p marreq-core --test <name> -- --nocapture instead of cargo test. --no-report keeps the profile data, and cargo-llvm-cov merges it with the workspace run in the report.
  • Remove the cargo cov clean --workspace from Generate coverage reports, since it would wipe the data recorded above.
  • Add a comment explaining why these tests need their own instrumented builds.

No test or source code changes. The coverage gate stays at --fail-under-lines 70.

Measured effect

Both numbers come from the same tree, run in Docker against a disposable PostgreSQL, so the only difference is this change:

Lines covered Coverage
Workspace run only (current CI) 46,780 / 58,575 79.86%
Plus the instrumented Postgres tests 48,907 / 58,748 83.25%
  • +3.39 points, 2,127 more lines covered.
  • repository/diesel_repo/: 4.6% → 38.1%.
  • Largest gains: use_cases.rs 0% → 90%, requirements.rs 0% → 48%, idempotency.rs 0% → 92%, rate_limiter/postgres.rs 34% → 93%, verification_control.rs 0% → 100%.
  • All seven Postgres tests pass. The baseline matches the coverage-html artifact of a recent CI run (79.9%).

What to check in this PR's CI

  • Not yet seen on a GitHub runner. The local run used the same commands but not the runner or the ci-coverage cache. The test-and-coverage job and the posted coverage comment are the real check; expect the backend total to move from about 81% to about 84-85%.
  • Run time: the seven tests are now an instrumented build instead of a plain one. Locally this step took about 2 minutes including the compile.
  • The --ignore-filename-regex may not be used together with --no-report warning comes from the existing cov alias and already appears in the workspace run.

Not in this PR

🤖 Generated with Claude Code

The seven PostgreSQL integration tests are gated with
`#![cfg(not(feature = "test-helpers"))]`, and the workspace coverage run
enables `test-helpers` through marreq-server/marreq-cloud, so they compile
out of it. CI ran them earlier with plain `cargo test`, which is not
instrumented, so the real `repository/diesel_repo` layer read as ~5% covered
even though CI exercises it.

Run them as instrumented `cargo cov --no-report -p marreq-core --test ...`
builds after a single `cargo cov clean --workspace`, and drop the clean from
the report step so it no longer wipes what they recorded. `cargo-llvm-cov`
merges the profile data in the report.

Measured on one tree, against a disposable PostgreSQL: line coverage goes
from 79.86% (46780/58575) to 83.25% (48907/58748), and diesel_repo from 4.6%
to 38.1%. All seven tests pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Frontend Code Coverage

Frontend SPA coverage (by module)

Module Line Rate Branch Rate Function Rate Health
api 89.1% (311 / 349) 82.7% 86.0% ✔
components 74.1% (2234 / 3015) 62.6% 70.5% ➖
components/graph 100.0% (9 / 9) 66.7% 100.0% ✔
components/reports 86.1% (87 / 101) 70.6% 74.1% ✔
components/table 100.0% (7 / 7) 80.0% 100.0% ✔
context 77.8% (56 / 72) 40.0% 69.6% ➖
hooks 72.3% (146 / 202) 71.1% 70.0% ➖
lib 100.0% (18 / 18) 100.0% 100.0% ✔
pages 68.7% (2331 / 3392) 55.5% 61.0% ➖
pages/catalog 34.8% (162 / 465) 24.5% 18.3% ❌
pages/groups 0.0% (0 / 219) 0.0% 0.0% ❌
src (root) 33.3% (8 / 24) 38.1% 60.0% ❌
types 100.0% (0 / 0) 100.0% 100.0% ✔
utils 97.2% (620 / 638) 89.1% 98.8% ✔
Summary 70.4% (5989 / 8511) 59.1% 65.1% ➖

Generated from Vitest @vitest/coverage-v8 (frontend/src).

@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
marreq-core.src.use_case_document 94% 0 ✔
marreq-core.src.auth.rate_limiter 96% 0 ✔
marreq-core.src.api 83% 0 ✔
marreq-core.src.auth 91% 0 ✔
marreq-core.src.fairings 90% 0 ✔
marreq-core.src.importers 74% 0 ➖
marreq-cloud.src.api 78% 0 ✔
marreq-core.src 86% 0 ✔
marreq-core.src.reports 95% 0 ✔
marreq-core.src.models 82% 0 ✔
marreq-cloud.src 71% 0 ➖
marreq-core.src.repository.cache 100% 0 ✔
marreq-core.src.repository 88% 0 ✔
marreq-core.src.services.semantic_search 75% 0 ➖
marreq-cloud.src.fairings 100% 0 ✔
marreq-core.src.generators 90% 0 ✔
marreq-core.src.deployment 84% 0 ✔
marreq-cloud.src.services 91% 0 ✔
marreq-core.src.routes 64% 0 ➖
marreq-core.src.storage 93% 0 ✔
marreq-core.src.validation 96% 0 ✔
marreq-server.src 57% 0 ➖
marreq-core.src.reqif 97% 0 ✔
marreq-core.src.diff 100% 0 ✔
marreq-core.src.helper_functions 95% 0 ✔
marreq-core.src.auth.guards 70% 0 ➖
marreq-core.src.repository.diesel_repo 39% 0 ❌
marreq-core.src.services 93% 0 ✔
Summary 84% (47372 / 56377) 0 ✔

@mariusmm
mariusmm merged commit 1703cd7 into main Oct 29, 2026
12 checks passed
@mariusmm
mariusmm deleted the ci/instrument-postgres-integration-tests branch October 29, 2026 14:27
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