Skip to content

ci: add Rust code coverage with Codecov#3189

Merged
QuantumExplorer merged 2 commits into
v3.1-devfrom
ci/rust-code-coverage
Mar 5, 2026
Merged

ci: add Rust code coverage with Codecov#3189
QuantumExplorer merged 2 commits into
v3.1-devfrom
ci/rust-code-coverage

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Mar 5, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Adds code coverage reporting for all Rust crates, matching the pattern used in grovedb.

What was done?

Coverage Instrumentation

  • Modified tests-rs-package.yml to use cargo llvm-cov test instead of cargo test
  • Installs llvm-tools component and cargo-llvm-cov via taiki-e/install-action
  • Generates LCOV output per package and uploads to Codecov with per-package flags

Codecov Configuration (.codecov.yml)

  • Project coverage: auto target with 2% threshold (won't fail on small regressions)
  • Patch coverage: 50% target for new code
  • Ignores test files, FFI crates (rs-sdk-ffi, rs-platform-wallet-ffi), and WASM bindings
  • Defines components for key crates: dpp, drive, drive-abci, sdk, dapi-client, platform-version, platform-value, platform-wallet, drive-proof-verifier

README

  • Added Codecov badge next to CI badge
  • Added collapsible per-crate coverage table

How Has This Been Tested?

The workflow change is additive — cargo llvm-cov test runs the same tests as cargo test but with coverage instrumentation.

Breaking Changes

None. Coverage upload uses fail_ci_if_error: false so missing token (fork PRs) won't break CI.

Setup Required

  • Add CODECOV_TOKEN secret to repo settings (get from https://codecov.io after enabling the repo)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional tests
  • I have made corresponding changes to the documentation

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • CI now collects and reports test coverage per crate, enforces coverage thresholds, and uploads coverage results as part of test runs.
    • Test workflow updated to produce coverage data and integrate with the coverage reporting service.
  • Documentation

    • Added overall and per-crate code coverage badges and a new "Per-Crate Coverage" section to the README.

@github-actions github-actions Bot added this to the v3.1.0 milestone Mar 5, 2026
@coderabbitai

coderabbitai Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da5b59e4-7047-462d-9a15-6c17c55959eb

📥 Commits

Reviewing files that changed from the base of the PR and between fabe080 and 1e4b551.

📒 Files selected for processing (3)
  • .codecov.yml
  • .github/workflows/tests-rs-package.yml
  • README.md
📝 Walkthrough

Walkthrough

Adds code coverage tooling: a new Codecov configuration, CI workflow changes to collect and upload coverage via cargo llvm-cov, and README additions showing overall and per-crate Codecov badges.

Changes

Cohort / File(s) Summary
Codecov config
.codecov.yml
New Codecov configuration: CI gating, ignore patterns, project and patch coverage thresholds, comment layout/behavior, and component-based management listing rs-packages and paths.
CI workflow
.github/workflows/tests-rs-package.yml
Test workflow now installs llvm-tools, adds taiki-e/install-action@cargo-llvm-cov, runs cargo llvm-cov test to produce lcov.info, and uploads coverage with codecov/codecov-action@v5 (per-package flags, token, always-run).
Documentation
README.md
Added Codecov badge to header and a collapsible "Per-Crate Coverage" section with a table of per-crate Codecov badges/links.

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Actions
    participant Runner as CI Runner
    participant Rust as Rust Toolchain
    participant LLVM as LLVM Tools
    participant Codecov as Codecov Service

    GH->>Runner: trigger tests job
    Runner->>Rust: setup Rust (with components)
    Rust->>LLVM: ensure llvm-tools installed
    Runner->>Runner: run `cargo llvm-cov test` → generate `lcov.info`
    Runner->>Codecov: upload `lcov.info` (per-package flag)
    Codecov-->>Codecov: process coverage metrics
    Codecov-->>GH: report completed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through CI with tools in tow,
LLVM warmed up, coverage aglow,
Lcov spilled secrets of lines once hidden,
Codecov tallied what tests had bidden,
Badges now sparkle where rabbits once hid.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ci: add Rust code coverage with Codecov' directly and clearly summarizes the main change: adding Rust code coverage integration with Codecov to the CI workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci/rust-code-coverage

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.

❤️ Share

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.codecov.yml (1)

32-69: Component coverage currently tracks only a subset of workspace crates.

This list covers key crates, but many workspace Rust crates remain outside component-level reporting/badges. Consider either adding components for all Rust crates or narrowing wording/docs to “selected/key crates” to avoid expectation drift.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.codecov.yml around lines 32 - 69, The component list under
component_management -> individual_components in .codecov.yml only includes a
subset of Rust workspace crates (entries like component_id: dpp, drive,
drive-abci, sdk, etc.); either add missing crates by creating corresponding
component entries (component_id, name, paths pointing to each
packages/rs-<crate>/ directory) for every workspace Rust crate you want covered,
or update any documentation/labels that reference this list to say “selected/key
crates” to avoid implying full coverage—make the change by editing .codecov.yml
and/or the docs where the component list is described.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.codecov.yml:
- Line 9: Remove the global ignore pattern "**/mod.rs" from .codecov.yml and
instead ignore only test-only mod.rs files (for example change the pattern to
target test directories like "tests/**/mod.rs" or "**/tests/**/mod.rs" or other
repo-specific test paths); update the ignore list so production module files
named mod.rs are not excluded, ensuring only test-only paths are scoped for
exclusion.

---

Nitpick comments:
In @.codecov.yml:
- Around line 32-69: The component list under component_management ->
individual_components in .codecov.yml only includes a subset of Rust workspace
crates (entries like component_id: dpp, drive, drive-abci, sdk, etc.); either
add missing crates by creating corresponding component entries (component_id,
name, paths pointing to each packages/rs-<crate>/ directory) for every workspace
Rust crate you want covered, or update any documentation/labels that reference
this list to say “selected/key crates” to avoid implying full coverage—make the
change by editing .codecov.yml and/or the docs where the component list is
described.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c1e1598b-f11f-4d44-9779-739ad3017f7b

📥 Commits

Reviewing files that changed from the base of the PR and between a669991 and a83824d.

📒 Files selected for processing (3)
  • .codecov.yml
  • .github/workflows/tests-rs-package.yml
  • README.md

Comment thread .codecov.yml Outdated
QuantumExplorer and others added 2 commits March 5, 2026 19:23
Add llvm-cov instrumentation to Rust package tests and upload
coverage reports to Codecov with per-package flags.

- Replace `cargo test` with `cargo llvm-cov test` in tests-rs-package.yml
- Add .codecov.yml with component definitions for key crates
- Add coverage badge and per-crate table to README.md
- Ignore test files, FFI crates, and WASM bindings from coverage

Requires CODECOV_TOKEN secret to be configured in repo settings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `**/mod.rs` glob was excluding 528 production module files from
coverage reporting. Test mod.rs files are already covered by `**/tests/**`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@QuantumExplorer QuantumExplorer force-pushed the ci/rust-code-coverage branch from fabe080 to 1e4b551 Compare March 5, 2026 12:23

@lklimek lklimek 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.

I assume you tested codecov config locally, so I approve

@QuantumExplorer QuantumExplorer merged commit 7cac120 into v3.1-dev Mar 5, 2026
25 checks passed
@QuantumExplorer QuantumExplorer deleted the ci/rust-code-coverage branch March 5, 2026 12:37
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