Skip to content

Wire the CodeScene coverage gate into CI - #197

Merged
leynos merged 1 commit into
mainfrom
codescene-coverage-gate
Jul 14, 2026
Merged

Wire the CodeScene coverage gate into CI#197
leynos merged 1 commit into
mainfrom
codescene-coverage-gate

Conversation

@leynos

@leynos leynos commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Onboard vk (CodeScene project 70277) to the estate CodeScene coverage-upload pattern. CodeScene already posts a Code Health Review check on vk's pull requests; this PR gets coverage data flowing so the Code Coverage check can eventually be enabled without repeating the netsuke/mxd timed-out-check jam.
  • Bump the leynos/shared-actions pin repo-wide from 69f9c29d to 927edd45ae77be4251a8a18ca9eb5613a2e32cbd (shared-actions #333/#334: fixes the coverage-upload CLI-version bug and adds per-line coverage records plus mode: check support).
  • Enable the coverage ratchet (with-ratchet: 'true') in the PR generation step so the changed baseline gates future PRs once uploads exist.
  • Add .github/workflows/coverage-main.yml: on push to main (and workflow_dispatch, so automerged pushes that skip the push event can be re-triggered manually), it regenerates coverage and uploads it to CodeScene with mode: upload, and writes the authoritative ratchet baseline that PR runs compare against.
  • Deliberately not wired: the pull-request mode: check changed-line gate. A read-only probe of GET /v2/code-coverage/projects/70277/config with the estate PAT returns an empty body, matching the pattern found on ddlint/chutoro — CodeScene has not enabled the coverage-gates configuration for this project yet, and cs-coverage check fails unconditionally without it ("received project-config isn't valid. Lacks the gates configuration."). The deferral is documented inline in coverage.yml. mode: upload is likewise not run from the PR job (CodeScene only accepts uploads for branches it analyses; from a PR head it fails outright) — this is why the existing guarded step had to be removed rather than left in place once secrets go live.

Why the existing step had to change, not just gain new inputs

vk's coverage.yml already had a guarded upload-codescene-coverage step, but it used the action's default mode: upload and CS_ACCESS_TOKEN was unset in both secret stores, so it always skipped silently. Setting the secret without first fixing this would have broken every open pull request the instant the token was set (cs-coverage upload rejects non-analysed branches). This PR removes that step from the PR job entirely; uploads now only happen from coverage-main.yml, which runs on main.

Review walkthrough

  • .github/workflows/coverage.yml — pin bump, fetch-depth: 0 (so a future mode: check step can diff against the merge base without another checkout change), use-cargo-nextest: 'false' (vk's Makefile runs plain cargo test, not nextest, so this preserves existing test behaviour), with-ratchet: 'true', and the guarded upload step replaced with an explanatory comment.
  • .github/workflows/coverage-main.yml — new workflow, modelled on ddlint's, generating and uploading coverage on push to main plus manual dispatch.
  • .github/workflows/release.yml — same pin bump for consistency (single repo-wide shared-actions pin).

Validation

  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/coverage.yml'))" and the same for coverage-main.yml and release.yml — all parse.
  • No workflow-contract tests exist in this repo to update (checked for references to .github/workflows filenames in Rust sources and the Makefile).
  • Full CI run on this PR's own head is the functional validation: coverage generation must succeed under use-cargo-nextest: 'false' and the ratchet-enabled step must not fail on first run (no baseline cached yet).

About the CodeScene checks

The CodeScene Code Health Review check you may see on this PR is unrelated to this change — it runs independently of coverage. There is no branch-protection ruleset on this repository (gh api repos/leynos/vk/rules/branches/main returns []), so no check here is a required check; CodeScene checks (health review or, in future, coverage) affect the status rollup but not mergeability directly.

Secrets: CS_ACCESS_TOKEN will be set in both the Actions and Dependabot secret stores immediately before this PR merges (not before), to avoid breaking the several other open pull requests (#194, #195, #196, #186) whose heads still carry the old, unguarded-by-branch upload step until they rebase onto the new main.

CodeScene (project 70277) already posts a Code Health Review check but
never receives coverage data: the guarded upload step in coverage.yml
defaults to `mode: upload`, which CodeScene only accepts for branches
it analyses, so it would fail outright on pull-request heads the
moment CS_ACCESS_TOKEN is set. Bump the shared-actions pin to
927edd4 (the shared-actions#333/#334 fixes), enable the coverage
ratchet, and add coverage-main.yml so main-branch pushes upload
coverage with `mode: upload` while pull requests only generate
coverage. The changed-line `mode: check` gate is deferred: project
70277 has no coverage-gates configuration yet, which is a
CodeScene-side setting outside CI's control.

@sourcery-ai sourcery-ai 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.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 43 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 28e5385b-9b9a-478e-82e1-c5156b9953fa

📥 Commits

Reviewing files that changed from the base of the PR and between 52f20e8 and 3fdbcae.

📒 Files selected for processing (3)
  • .github/workflows/coverage-main.yml
  • .github/workflows/coverage.yml
  • .github/workflows/release.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codescene-coverage-gate

Comment @coderabbitai help to get the list of available commands.

@leynos
leynos merged commit b06038e into main Jul 14, 2026
6 checks passed
@leynos
leynos deleted the codescene-coverage-gate branch July 14, 2026 00:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fdbcae0a4

ℹ️ 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".

access-token: ${{ env.CS_ACCESS_TOKEN }}
installer-checksum: ${{ vars.CODESCENE_CLI_SHA256 }}
use-cargo-nextest: 'false'
with-ratchet: 'true'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fix the ratchet cache key before relying on it

When a PR runs after coverage-main has uploaded a new baseline, this ratchet still starts from 0: the pinned generate-coverage action restores ratchet-baseline-${{ runner.os }}-${{ github.run_id }} with restore prefix ratchet-baseline-${{ runner.os }}-, but saves the updated baseline as ratchet-baseline-${{ runner.os }}. Since that saved key is not prefixed by either lookup key, the main baseline is never restored here, so coverage drops below the intended baseline will pass silently even with with-ratchet enabled.

Useful? React with 👍 / 👎.

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