ci(backend): calculate code coverage baseline in backend checks - #1429
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe backend CI workflow gains concurrency cancellation and minimal token permissions. Rust test execution is replaced with ChangesBackend CI Code Coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6002adc to
33dc427
Compare
Wire coverage into backend-checks.yml as a report-only signal to establish a baseline (no gates, no new required checks): - Rust workspace: cargo-llvm-cov wraps the existing test pass (--all-features --workspace), emitting an HTML report + Cobertura, with a markdown summary rendered via ReportGenerator. - Identity (.NET): dotnet test --collect:"XPlat Code Coverage" on the unit + integration projects, merged into one report. Both publish an HTML artifact and a sticky PR comment. Report-only — the comment step is continue-on-error and nothing fails the job. Thresholds / ratchet and broader surfaces (connectors) are deferred. Adds coverlet.collector (dev-only, PrivateAssets=all; never shipped) to the two Identity test projects so the XPlat Code Coverage collector emits Cobertura. Closes constructorfabric#1384 Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
A rebase/force-push left the prior in-flight run executing in parallel (no concurrency control), double-spending runner minutes on the slow instrumented coverage build. Add a per-ref concurrency group with cancel-in-progress so a new push obsoletes the older run. Refs constructorfabric#1384 Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
Replace the self-contained ReportGenerator/HTML/artifact + sticky-comment pipeline with GitHub's native code coverage (Code Quality): upload the Cobertura report via actions/upload-code-coverage; the github-code-quality bot posts the PR coverage comment. - Rust: cargo-llvm-cov emits one cobertura.xml -> upload (language Rust). - Identity: merge the unit + integration cobertura via dotnet-coverage -> upload (language C#). - Add push:main trigger so the native feature has a default-branch baseline to compare PRs against; check out the PR head so line numbers map. - permissions: code-quality:write (dropped pull-requests:write). Uploads are fail-on-error:false (report-only) and skip fork PRs automatically. NOTE: GitHub Code Quality requires Team/Enterprise Cloud; on the Free plan the upload no-ops (warning only, build stays green). Refs constructorfabric#1384 Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
… plan) GitHub-native code coverage (Code Quality) returns HTTP 403 here: it's a Team/Enterprise-Cloud product (paid at GA, $10/committer/mo), not free for public repos, and the org is on the Free plan. Switch to a self-contained, report-only summary that works on any plan: - Cobertura (already produced) -> markdown via irongut/CodeCoverageSummary (no HTML, no .NET-SDK-in-Rust-job), posted as a sticky PR comment and appended to the GitHub Actions job summary. - Identity: merge unit + integration Cobertura via dotnet-coverage first. - Drop the native upload step, the push:main trigger, and code-quality:write. Refs constructorfabric#1384 Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
33dc427 to
264caf5
Compare
Fork PRs get a read-only GITHUB_TOKEN, so the sticky-comment step 403s
("Resource not accessible by integration"). Remove the comment step from both
jobs and report coverage solely via the GitHub Actions job summary, which
needs no token. Drop the now-unnecessary pull-requests:write permission, and
guard the job-summary step so a skipped merge (after a test failure) doesn't
error on a missing file.
Refs constructorfabric#1384
Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/backend-checks.yml:
- Line 59: The GitHub Actions in the workflow file use floating version
references instead of full commit SHAs, which violates supply-chain integrity
policy. Replace the floating refs for taiki-e/install-action@cargo-llvm-cov and
any other actions pinned to version tags like `@v1.3.0` with their corresponding
full commit SHA hashes. This applies to all instances across the workflow file
where actions use floating refs to ensure all third-party actions are pinned to
immutable commit SHAs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cc4ff2eb-7973-4d3a-9b30-ef37848b1bbf
📒 Files selected for processing (3)
.github/workflows/backend-checks.ymlsrc/backend/services/identity/tests/Insight.Identity.Tests.Integration/Insight.Identity.Tests.Integration.csprojsrc/backend/services/identity/tests/Insight.Identity.Tests.Unit/Insight.Identity.Tests.Unit.csproj
|
|
||
| - name: Run tests | ||
| run: cargo test --all | ||
| - uses: taiki-e/install-action@cargo-llvm-cov |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify no non-SHA action refs remain in this workflow.
# Expected: zero matches for third-party `uses:` refs not pinned to 40-char SHA.
rg -nP '^\s*-\s*uses:\s*[^@\s]+@(?!(?:[0-9a-f]{40})$).+$' .github/workflows/backend-checks.ymlRepository: constructorfabric/insight
Length of output: 327
🏁 Script executed:
# Display the workflow file around the mentioned lines with context
sed -n '55,145p' .github/workflows/backend-checks.yml | cat -nRepository: constructorfabric/insight
Length of output: 4069
🏁 Script executed:
# Display the workflow file around line 139 to verify the third unpinned action
sed -n '135,145p' .github/workflows/backend-checks.yml | cat -nRepository: constructorfabric/insight
Length of output: 569
Pin third-party GitHub Actions to full commit SHAs.
Lines 59, 73, and 139 use floating refs (@cargo-llvm-cov, @v1.3.0), which violates the current policy and weakens supply-chain integrity.
Suggested changes
- - uses: taiki-e/install-action@cargo-llvm-cov
+ - uses: taiki-e/install-action@<FULL_40_CHAR_COMMIT_SHA>
- - name: Coverage summary
- uses: irongut/CodeCoverageSummary@v1.3.0
+ - name: Coverage summary
+ uses: irongut/CodeCoverageSummary@<FULL_40_CHAR_COMMIT_SHA>
- - name: Coverage summary
- uses: irongut/CodeCoverageSummary@v1.3.0
+ - name: Coverage summary
+ uses: irongut/CodeCoverageSummary@<FULL_40_CHAR_COMMIT_SHA>🧰 Tools
🪛 zizmor (1.25.2)
[error] 59-59: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/backend-checks.yml at line 59, The GitHub Actions in the
workflow file use floating version references instead of full commit SHAs, which
violates supply-chain integrity policy. Replace the floating refs for
taiki-e/install-action@cargo-llvm-cov and any other actions pinned to version
tags like `@v1.3.0` with their corresponding full commit SHA hashes. This applies
to all instances across the workflow file where actions use floating refs to
ensure all third-party actions are pinned to immutable commit SHAs.
Source: Linters/SAST tools
Flip CodeCoverageSummary fail_below_min false -> true in both jobs so backend-checks fails when overall line coverage drops below the 60% lower threshold. Coverage is no longer report-only. Current: Rust ~62%, Identity ~87%. Refs constructorfabric#1384 Signed-off-by: Konstantin Tursunov <Konstantin.Tursunov@constructor.tech>
What
Adds report-only, self-contained code-coverage reporting for
src/backendto theBackend Lint & Testworkflow — a coverage summary on every backend PR, with no external service and no plan requirement (works on Free).analytics-api,api-gateway,insight-clickhouse,oidc-authn-plugin):cargo-llvm-covruns the suite under instrumentation (replacing plaincargo test, so tests still run) and emits a single Cobertura report.dotnet test --collect:"XPlat Code Coverage"on the unit + integration projects; the two Cobertura files are merged withdotnet-coverage.irongut/CodeCoverageSummaryand posted as a sticky PR comment + appended to the Actions job summary. No HTML, no artifacts, no Codecov.Adds
coverlet.collector(dev-only,PrivateAssets=all) to the two Identity test projects so theXPlat Code Coveragecollector emits Cobertura.Baseline (from CI, all tests green)
Scope / non-goals
Deliberately thin — only calculates and exposes the baseline. Out of scope (future follow-ups under #1384): coverage gates / ratchet, a shared task-runner so local == CI,
cargo-nextest, connector (Python) coverage.GitHub-native coverage (Code Quality) was evaluated and rejected for now: it's a paid Team/Enterprise-Cloud product (GA 2026-07-20, $10/active-committer/mo), not free for public repos, and this org is on Free — the upload API returns HTTP 403 ("Code quality is not enabled for this repository"). The Cobertura we emit would feed it directly (
actions/upload-code-coverage) if the org ever upgrades.Test plan
backend-checks.ymlruns on this PR (touchessrc/backend/**+ the workflow). Both jobs run the full unit (+ integration) suites and post their coverage comments.Closes #1384
Summary by CodeRabbit