Skip to content

feat(ci): add integration-coverage-upload-as to reusable-ci-rust - #443

Merged
BryanFRD merged 2 commits into
mainfrom
feat/rust-integration-coverage
Nov 28, 2026
Merged

BryanFRD merged 2 commits into
mainfrom
feat/rust-integration-coverage

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

DB-backed tests are #[ignore]d, so the llvm-cov coverage job never executes them and SonarQube sees 0% on every route handler they exercise (FerrTrack-Cloud, FerrLabs/FerrTrack-Cloud#954).

New optional input integration-coverage-upload-as. When set, the integration step runs through cargo llvm-cov instead of cargo test, and its lcov is rebased to the repo root and uploaded as an artifact with that name. SonarQube merges it with the unit-test report. Default empty: behaviour unchanged.

@BryanFRD
BryanFRD enabled auto-merge (squash) November 28, 2026 15:09

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: coverage mode skips the pre-compile step, which reopens the idle-DB GC race.

Blocking

  • .github/workflows/reusable-ci-rust.yml:453: Coverage mode reintroduces the idle-DB GC race. With integration-coverage-upload-as set, Pre-compile integration test binaries is skipped. Create per-run database then runs before any build. The first cargo llvm-cov attempt compiles the whole instrumented test tree (about 10-15 min, per the comment at L441-449) while the fresh ci_* DB has zero connections. The hourly postgres-ci GC can drop it mid-build, which is the failure the pre-compile step exists to prevent.
    • Fix: keep one pre-compile step for both modes by using llvm-cov's env-export flow. In coverage mode, run source <(cargo llvm-cov show-env --export-prefix) and cargo llvm-cov clean --workspace. Then run cargo test --locked --no-run ${INTEGRATION_ARGS%% -- *} before the DB is created. Re-source the env in the test step and keep cargo test --locked $INTEGRATION_ARGS as the runner in the retry loop. Run cargo llvm-cov report --lcov --output-path lcov.info after it. Retries then stop rebuilding too. Alternatively, write the show-env output to $GITHUB_ENV once so later steps inherit it.

Minor

  • .github/workflows/reusable-ci-rust.yml:496: Third copy of the lcov rebase awk. The SF: rebase awk and the upload step are now pasted verbatim in the test, coverage and integration jobs. The repo already ships composite actions under .github/actions (e.g. setup-sccache), so a fix to the rebase logic now has to be made in three places. Consider a .github/actions/rebase-upload-lcov composite action (inputs: lcov path, base dir, artifact name), in this PR or a follow-up.

The rest of the wiring (components, install, rebase, upload) mirrors the unit-coverage path and looks correct.

@BryanFRD

Copy link
Copy Markdown
Contributor Author

Coverage mode now pre-compiles through llvm-cov's show-env flow before the DB is created, runs cargo test in the retry loop, and generates the lcov with llvm-cov report afterwards.

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Integration coverage follows the job's existing llvm-cov, rebase and upload pattern. cargo llvm-cov show-env is sourced in both the pre-compile step and the test step, so the instrumented binaries are reused and not rebuilt. I found one minor issue and two suggestions. None of them blocks the merge.

Minor

  • .github/workflows/reusable-ci-rust.yml:499: a failed cargo llvm-cov report is swallowed, and the job then fails in the next step. The test step runs under set -uo pipefail without -e, so a failing report command still reaches exit 0. The "Rebase integration lcov to repo root" step has no continue-on-error, so it then fails on the missing lcov.info. The gate goes red with a misleading error, even though the upload is meant to be a side output that must not fail the gate. Fix: use cargo llvm-cov report --lcov --output-path lcov.info || echo "::warning::integration coverage report failed" and guard the rebase step with [ -f lcov.info ] || exit 0. Or mark the rebase step continue-on-error, as the upload step already is.

Suggestions

  • .github/workflows/reusable-ci-rust.yml:514: the lcov rebase awk is now copied in two places. It is identical to the program in the test job's "Rebase lcov to repo root" step (line 329), so a fix to one copy can miss the other. Optionally move it into a small script or a local composite action and call it from both jobs.
  • .github/workflows/reusable-ci-rust.yml:529: nothing stops the two coverage artifacts from sharing a name. If a caller sets coverage-upload-as and integration-coverage-upload-as to the same value, upload-artifact v4+ rejects the second upload. continue-on-error then hides the failure and one lcov is silently lost. Say in the input description that the name must differ from coverage-upload-as.

@BryanFRD
BryanFRD merged commit 1462513 into main Nov 28, 2026
13 checks passed
@BryanFRD
BryanFRD deleted the feat/rust-integration-coverage branch November 28, 2026 15:21
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.

2 participants