Fix CodeScene CLI install and preserve line records in coverage exports - #333
Conversation
Two defects surfaced while wiring coverage upload in leynos/mxd#362: - `upload-codescene-coverage` extracted the CLI version by grepping a `version="x.y.z"` literal out of the downloaded installer script. CodeScene rewrote the installer to take the version as its first positional argument (`version="${1:-latest}"`), so the grep matches nothing and, under `pipefail`, every upload now fails at the "Download installer" step. Replace the extraction with a `cli-version` input (default `latest`) passed to the installer; the CLI cache participates only when a concrete version is pinned so `latest` can never be frozen by a stale cache entry. - `generate-coverage` passed `--summary-only` to `cargo llvm-cov` unconditionally. For file outputs this strips per-line execution records (LCOV `DA` lines, Cobertura `<line>` elements), leaving changed-line coverage gates such as CodeScene's with nothing to evaluate. Omit the flag for `lcov` and `cobertura`; streamed formats keep it so stdout remains parseable. The reported percentage is unaffected because file formats compute it from the report itself.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 44 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph. If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced. .github/actions/generate-coverage/tests/test_scripts.py Comment on file "--manifest-path",
"Cargo.toml",
"--workspace",
"--summary-only",❌ Getting worse: Code Duplication |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4af2e69196
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This comment was marked as resolved.
This comment was marked as resolved.
Merge the two single-case tests into `test_get_cargo_coverage_cmd_summary_only_by_format`, parametrised over (output_format, out_name, expect_summary_only), matching the parametrize style already used in this module.
Ruff FBT001 forbids boolean positional parameters; pytest passes parametrised arguments by name, so the keyword-only marker costs nothing.
Pick up leynos/shared-actions#333: `generate-coverage` now preserves per-line records in lcov output, and `upload-codescene-coverage` survives the rewritten CodeScene installer by passing the CLI version as an argument. The `setup-rust` pins are unchanged.
* Upload coverage to CodeScene from the coverage job The CodeScene app posts a "Code Coverage" check on every pull request head and waits for a coverage upload for that commit. The coverage job generated and merged `lcov.info` but never uploaded it, so the check timed out on every pull request, driving the status-check rollup to FAILURE and jamming Dependabot automerge (PRs #343 and #341 sat BLOCKED with all required checks green). Switch coverage generation to the shared `leynos/shared-actions` `generate-coverage` action (pinned to the same revision the workflow already uses for `setup-rust`, with `use-cargo-nextest: 'false'` to preserve the existing plain `cargo llvm-cov` runs) and add the shared `upload-codescene-coverage` step, guarded so runs without the `CS_ACCESS_TOKEN` secret skip the upload rather than fail. The now-unused local `generate-coverage` action is removed. `CS_ACCESS_TOKEN` is configured as both an Actions secret and a Dependabot secret so Dependabot-triggered runs can also upload. * Upload coverage from the pull-request head checkout CodeScene records each upload against the commit checked out when the CLI runs, and its pull-request check waits for coverage keyed to the head SHA. The coverage job previously checked out the default `refs/pull/<n>/merge` ref, so uploads were keyed to the synthetic merge commit and the head check could still time out. Check out `github.event.pull_request.head.sha` in the coverage job instead. * Pin the coverage actions to shared-actions 158d04f Pick up leynos/shared-actions#333: `generate-coverage` now preserves per-line records in lcov output, and `upload-codescene-coverage` survives the rewritten CodeScene installer by passing the CLI version as an argument. The `setup-rust` pins are unchanged. * Drive the CodeScene PR gate with cs-coverage check CodeScene accepts `cs-coverage upload` only for analysed branches (main), so the previous upload step could never satisfy the pull-request "Code Coverage" check. Switch the step to the shared action's new `mode: check` (shared-actions#334), which runs `cs-coverage check` against project 68298 to evaluate changed-line coverage. The check diffs the PR against its merge base, so the coverage job now checks out with `fetch-depth: 0` on the default merge ref, matching CodeScene's documented example; the head-SHA checkout from 574325e is superseded. * Upload main-branch coverage and ratchet the sqlite leg Add `coverage-main.yml`, triggered only by pushes to `main`: it regenerates and merges the same coverage as the pull-request job and uploads it with `cs-coverage upload`, which CodeScene accepts solely for analysed branches. This populates the project dashboard and gives analyses coverage for the analysed commit. Enable the coverage ratchet (`with-ratchet`) on the sqlite `generate-coverage` invocation in both workflows. The main run saves the authoritative baseline — caches created on `main` are readable by every pull-request run — while PR runs compare against it and fail if line coverage drops. The ratchet supports one baseline per job, so the sqlite leg (the default feature set and broadest suite) carries it; the postgres leg remains unratcheted. * Run coverage and Makefile tests under nextest Drop the `use-cargo-nextest: 'false'` overrides so the shared `generate-coverage` action runs `cargo llvm-cov nextest` in both the pull-request and main coverage workflows, and adopt the agent-template-rust Makefile convention: a `TEST_CMD` variable that prefers nextest when installed and falls back to `cargo test`. nextest does not execute doctests, so add a `test-doc` target (run under the default sqlite backend) to the `test` aggregate. The suite had never run these doctests before; all five pass. * Pin third-party actions in the main coverage workflow Pin `taiki-e/install-action` and `oven-sh/setup-bun` to commit hashes, resolving the CodeQL unpinned-action findings on the new workflow. The equivalent references in ci.yml predate this branch and are left for a separate pinning pass. --------- Co-authored-by: leynos <leynos@rohga>
Summary
This branch fixes two coverage defects surfaced by review feedback on
leynos/mxd#362.
First,
upload-codescene-coverageis currently broken for everyconsumer: it extracted the CLI version by grepping a
version="x.y.z"literal from the downloaded installer script, but CodeScene rewrote the
installer to take the version as its first positional argument
(
version="${1:-latest}"). The grep now matches nothing and, underpipefail, the "Download installer" step exits 1 before any uploadhappens. A new
cli-versioninput (defaultlatest) is passed to theinstaller via environment indirection; the CLI cache participates only
when a concrete version is pinned, so
latestalways fetches fresh andcan never be frozen by a stale cache entry.
Second,
generate-coveragepassed--summary-onlytocargo llvm-covunconditionally. cargo-llvm-cov documents that this exports only
summary information, so LCOV files lacked
DAline-hit records andCobertura files lacked
<line>elements — changed-line coverage gates(CodeScene's PR gate among them) had nothing to evaluate even when the
upload succeeded. The flag is now omitted for the file formats and kept
for streamed formats, whose stdout must remain parseable. Reported
percentages are unaffected: for
lcovandcoberturathe percentageis computed from the report file, not stdout.
Review walkthrough
— the
cli-versioninput, the rewritten "Download installer" step,and the conditional cache.
—
get_cargo_coverage_cmdappends--summary-onlyonly fornon-file formats, with the rationale in its docstring.
— lcov expectations updated, plus two new format-specific cases
(
--summary-onlykept fortext, omitted forcobertura).Validation
make test: 997 passed, 14 skipped.install-cs-coverage-tool.shand running the removed grep exits 1(no
version="…"literal exists in the current script).