Skip to content

chore: add codecov coverage tracking#493

Merged
xdustinface merged 1 commit intov0.42-devfrom
chore/coverage
Mar 4, 2026
Merged

chore: add codecov coverage tracking#493
xdustinface merged 1 commit intov0.42-devfrom
chore/coverage

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Mar 4, 2026

Inspired by #492 but integrated into the existing workflows.

Summary by CodeRabbit

  • Documentation

    • Added per-branch and per-crate coverage badges and a collapsible per-crate coverage section in the README for easier visibility.
  • Chores

    • Added Codecov configuration and ignore patterns.
    • Introduced an optional CI coverage mode with conditional install/steps, report generation, and upload.
    • Added a CLI flag to enable coverage-driven test runs and enabled coverage for the Ubuntu test job.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Adds repository-wide coverage: new Codecov config, CI script flag/logic to run per-crate cargo-llvm-cov, GitHub Actions steps to install llvm tools/generate LCOV and upload to Codecov, and README badges plus a per-crate coverage section.

Changes

Cohort / File(s) Summary
Codecov configuration
./.codecov.yml
New Codecov configuration: project and patch coverage defaults (auto targets, 2% thresholds), comment layout/behavior, flag management with named flags mapped to source paths, and ignore patterns for tests/examples/fuzz/contrib.
CI script updates
./.github/scripts/ci_config.py
Adds --coverage argument to run-group; when enabled emits crate flags, runs cargo llvm-cov clean --workspace, and switches per-crate execution from cargo test to cargo-llvm-cov --no-report -p <crate> --all-features.
Workflow changes
./.github/workflows/build-and-test.yml, ./.github/workflows/rust.yml
Adds optional coverage workflow input; conditionally installs llvm-tools and cargo-llvm-cov, runs tests with --coverage, generates LCOV (lcov.info), and uploads it to Codecov; enables coverage on the test-ubuntu job.
Documentation
README.md
Adds Codecov badges for master/develop and inserts a collapsible "Per-crate coverage" section containing a per-crate coverage table.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Actions
    participant CI as ci_config.py
    participant Cargo as cargo / cargo-llvm-cov
    participant Codecov as Codecov

    Dev->>GH: push or open PR (coverage=true)
    GH->>GH: install llvm-tools & cargo-llvm-cov
    GH->>CI: run run-group with --coverage
    CI->>CI: emit crate_flags
    CI->>Cargo: "cargo llvm-cov clean --workspace"
    loop per crate
      CI->>Cargo: "cargo-llvm-cov --no-report -p <crate> --all-features"
      Cargo-->>CI: produce per-crate coverage artifacts
    end
    CI->>Cargo: "cargo llvm-cov report --lcov"
    Cargo-->>GH: produce lcov.info
    GH->>Codecov: upload lcov.info (codecov-action)
    Codecov-->>GH: update badges & reports
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐇 I hopped through flags and cleaned each crate,
Ran cov per-package, steady and late,
LCOV bundled, badges shining bright,
Codecov sings metrics through the night,
A rabbit cheers — coverage takes flight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Codecov coverage tracking to the repository. It directly corresponds to the primary objective and matches the substantial changes across configuration files, workflow files, and documentation.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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)
.github/scripts/ci_config.py (1)

176-184: Consolidate duplicate coverage checks.

The if coverage: condition is checked twice (lines 178 and 181). These can be combined into a single block.

♻️ Suggested consolidation
     coverage = getattr(args, "coverage", False)

     if coverage:
         github_output("crate_flags", ",".join(crates))
-
-    if coverage:
         github_group_start("Cleaning coverage state")
         subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"])
         github_group_end()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/ci_config.py around lines 176 - 184, Combine the duplicate
coverage checks by converting the two separate "if coverage:" blocks into one:
after computing coverage = getattr(args, "coverage", False) perform a single if
coverage: that calls github_output("crate_flags", ",".join(crates)) and then
runs the cleanup group (github_group_start("Cleaning coverage state"),
subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"]),
github_group_end()). This keeps the same calls to github_output,
github_group_start, subprocess.run and github_group_end but under one unified
conditional.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 14-15: The Codecov badge URLs currently reference the wrong GitHub
org "dashevo"; update both anchor href and image src URLs in the README badges
(the two <a>...<img> badge entries) to use "dashpay/rust-dashcore" instead of
"dashevo/rust-dashcore" for the master and v0.42-dev branches so both href and
src reflect the correct organization.

---

Nitpick comments:
In @.github/scripts/ci_config.py:
- Around line 176-184: Combine the duplicate coverage checks by converting the
two separate "if coverage:" blocks into one: after computing coverage =
getattr(args, "coverage", False) perform a single if coverage: that calls
github_output("crate_flags", ",".join(crates)) and then runs the cleanup group
(github_group_start("Cleaning coverage state"), subprocess.run(["cargo",
"llvm-cov", "clean", "--workspace"]), github_group_end()). This keeps the same
calls to github_output, github_group_start, subprocess.run and github_group_end
but under one unified conditional.

ℹ️ Review info
Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e34e1e37-4b82-472f-a0ac-5f5a36cb638a

📥 Commits

Reviewing files that changed from the base of the PR and between 2c8e81f and 9f39c71.

📒 Files selected for processing (5)
  • .codecov.yml
  • .github/scripts/ci_config.py
  • .github/workflows/build-and-test.yml
  • .github/workflows/rust.yml
  • README.md

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
README.md (1)

14-15: ⚠️ Potential issue | 🟡 Minor

Use the correct org (dashpay) for all Codecov links.

Line 14, Line 15, and the per-crate links (Line 27–Line 38) still point to dashevo/rust-dashcore, which doesn’t match this repo (dashpay/rust-dashcore). Please update all new Codecov URLs consistently.

Also applies to: 27-38

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

In `@README.md` around lines 14 - 15, The README contains Codecov links pointing
to the wrong GitHub org; update every Codecov URL that contains
"dashevo/rust-dashcore" to "dashpay/rust-dashcore" (including the two top badges
with alt="Coverage (master)" and alt="Coverage (develop)" and all per-crate
badge/link entries referenced later), ensuring both href and src attributes are
replaced consistently across the file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/scripts/ci_config.py:
- Line 179: The script currently calls github_output("crate_flags",
",".join(crates)) before the skip/filter logic, causing skipped crates (e.g.,
dash-fuzz on Windows) to be advertised; move the github_output("crate_flags",
",".join(...)) invocation to after the code that computes the final list of
executed crates (the filtering/skip logic that mutates or produces the filtered
'crates' list) so it emits only actually-run crates, and apply the same change
for the other outputs mentioned around the same area (the calls on/near lines
186-188) so all exported flags reflect the post-filtered executed set. Ensure
you reference and use the final filtered variable (the same 'crates' or its
filtered counterpart) when calling github_output and not the original unfiltered
list.
- Around line 178-182: The cleanup subprocess.run call for "cargo llvm-cov clean
--workspace" currently ignores failures; update the logic in the section guarded
by the coverage variable to fail fast by invoking subprocess.run with check=True
(or capture the CompletedProcess and if result.returncode != 0 call sys.exit or
raise a RuntimeError), and ensure you log or include context before exiting;
reference the existing subprocess.run invocation and the surrounding
github_group_start/github_group_end calls so the cleanup either succeeds or the
CI stops immediately.

---

Duplicate comments:
In `@README.md`:
- Around line 14-15: The README contains Codecov links pointing to the wrong
GitHub org; update every Codecov URL that contains "dashevo/rust-dashcore" to
"dashpay/rust-dashcore" (including the two top badges with alt="Coverage
(master)" and alt="Coverage (develop)" and all per-crate badge/link entries
referenced later), ensuring both href and src attributes are replaced
consistently across the file.

ℹ️ Review info
Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 12cb21c6-5c1c-4b63-9a73-ae497d724edc

📥 Commits

Reviewing files that changed from the base of the PR and between 9f39c71 and f9baf1a.

📒 Files selected for processing (5)
  • .codecov.yml
  • .github/scripts/ci_config.py
  • .github/workflows/build-and-test.yml
  • .github/workflows/rust.yml
  • README.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/build-and-test.yml
  • .github/workflows/rust.yml
  • .codecov.yml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/scripts/ci_config.py (1)

179-188: ⚠️ Potential issue | 🟡 Minor

Emit crate_flags from executed crates, not configured crates.

Line 179 exports all group crates before the skip at Lines 186-188, so skipped crates (e.g., dash-fuzz on Windows) can still be sent to Codecov flags.

Suggested fix
-    if coverage:
-        github_output("crate_flags", ",".join(crates))
+    executed_crates = []
+    if coverage:
         github_group_start("Cleaning coverage state")
         subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"], check=True)
         github_group_end()
@@
         if args.os == "windows-latest" and crate == "dash-fuzz":
             github_notice(f"Skipping {crate} on Windows (honggfuzz not supported)")
             continue

+        executed_crates.append(crate)
         github_group_start(f"Testing {crate}")
@@
         if result.returncode != 0:
             failed.append(crate)
             github_error(f"Test failed for {crate} on {args.os}")
+
+    if coverage:
+        github_output("crate_flags", ",".join(executed_crates))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/ci_config.py around lines 179 - 188, The script currently
calls github_output("crate_flags", ",".join(crates)) before skipping
platform-specific crates, causing skipped crates (like "dash-fuzz" on Windows)
to be emitted; change the logic to record only actually executed crates: inside
the for crate in crates loop (and after the if args.os == "windows-latest" and
crate == "dash-fuzz" skip) append non-skipped crate names to a new
executed_crates list, and then call github_output("crate_flags",
",".join(executed_crates)) after the loop (or at the point where you know skips
are applied) so Codecov only receives flags for crates that ran.
🧹 Nitpick comments (1)
.github/scripts/ci_config.py (1)

180-182: Ensure coverage cleanup always closes the GitHub log group.

With check=True at Line 181, an exception bypasses Line 182 and leaves the group unclosed. Wrap with try/finally and return a controlled error.

Suggested hardening
     if coverage:
         github_output("crate_flags", ",".join(crates))
         github_group_start("Cleaning coverage state")
-        subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"], check=True)
-        github_group_end()
+        try:
+            subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"], check=True)
+        except subprocess.CalledProcessError as e:
+            github_error(f"Failed to clean coverage state: {e}")
+            return e.returncode or 1
+        finally:
+            github_group_end()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/ci_config.py around lines 180 - 182, The github group opened
by github_group_start("Cleaning coverage state") may remain unclosed if
subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"], check=True)
raises; wrap the subprocess.run call in a try/finally so github_group_end()
always runs, and convert the raised exception into a controlled return/error
value (or re-raise after logging) to ensure the group is closed; update the
block around github_group_start / subprocess.run / github_group_end accordingly
and reference these symbols (github_group_start, subprocess.run call with the
"cargo llvm-cov clean" args, and github_group_end) when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/scripts/ci_config.py:
- Around line 179-188: The script currently calls github_output("crate_flags",
",".join(crates)) before skipping platform-specific crates, causing skipped
crates (like "dash-fuzz" on Windows) to be emitted; change the logic to record
only actually executed crates: inside the for crate in crates loop (and after
the if args.os == "windows-latest" and crate == "dash-fuzz" skip) append
non-skipped crate names to a new executed_crates list, and then call
github_output("crate_flags", ",".join(executed_crates)) after the loop (or at
the point where you know skips are applied) so Codecov only receives flags for
crates that ran.

---

Nitpick comments:
In @.github/scripts/ci_config.py:
- Around line 180-182: The github group opened by github_group_start("Cleaning
coverage state") may remain unclosed if subprocess.run(["cargo", "llvm-cov",
"clean", "--workspace"], check=True) raises; wrap the subprocess.run call in a
try/finally so github_group_end() always runs, and convert the raised exception
into a controlled return/error value (or re-raise after logging) to ensure the
group is closed; update the block around github_group_start / subprocess.run /
github_group_end accordingly and reference these symbols (github_group_start,
subprocess.run call with the "cargo llvm-cov clean" args, and github_group_end)
when making the change.

ℹ️ Review info
Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d425ee6-ecbc-4074-8faf-81d9640e25cc

📥 Commits

Reviewing files that changed from the base of the PR and between f9baf1a and bf7079e.

📒 Files selected for processing (4)
  • .codecov.yml
  • .github/scripts/ci_config.py
  • .github/workflows/build-and-test.yml
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .codecov.yml

@xdustinface xdustinface force-pushed the chore/coverage branch 2 times, most recently from 12ab005 to 1b4e854 Compare March 4, 2026 05:00
Inspired by #492 but integrated into the existing workflows.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/scripts/ci_config.py (1)

176-180: ⚠️ Potential issue | 🟠 Major

Reset coverage artifacts before emitting and collecting coverage flags.

Line 179 enables coverage reporting without first cleaning prior llvm-cov artifacts. With cached build state, coverage can be stale/inaccurate.

Suggested fix
     coverage = getattr(args, "coverage", False)

     if coverage:
-        github_output("crate_flags", ",".join(crates))
+        github_group_start("Cleaning previous coverage state")
+        clean_result = subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"])
+        github_group_end()
+        if clean_result.returncode != 0:
+            github_error("Failed to clean coverage state")
+            return 1
+        github_output("crate_flags", ",".join(crates))
#!/bin/bash
# Verify coverage flow and absence/presence of llvm-cov clean.
rg -n -C3 'coverage|crate_flags|llvm-cov' .github/scripts/ci_config.py
rg -n -C3 'rust-cache|shared-key|coverage|llvm-cov report' .github/workflows/build-and-test.yml
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/ci_config.py around lines 176 - 180, When coverage is
enabled (the coverage variable checked in the block that calls
github_output("crate_flags", ",".join(crates))), ensure you first remove stale
llvm-cov artifacts before emitting crate_flags: add a cleanup step that deletes
or resets previous coverage outputs (e.g., remove coverage directories or
llvm-cov generated files/artifacts) and any cached build state that could skew
results, then proceed to call github_output with the joined crates; update the
logic around the coverage check so the cleanup always runs when coverage is true
and before github_output is invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/scripts/ci_config.py:
- Around line 176-180: When coverage is enabled (the coverage variable checked
in the block that calls github_output("crate_flags", ",".join(crates))), ensure
you first remove stale llvm-cov artifacts before emitting crate_flags: add a
cleanup step that deletes or resets previous coverage outputs (e.g., remove
coverage directories or llvm-cov generated files/artifacts) and any cached build
state that could skew results, then proceed to call github_output with the
joined crates; update the logic around the coverage check so the cleanup always
runs when coverage is true and before github_output is invoked.

ℹ️ Review info
Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ddba4591-9e37-453a-8a11-7cdd3779e46d

📥 Commits

Reviewing files that changed from the base of the PR and between bf7079e and f17bfc9.

📒 Files selected for processing (5)
  • .codecov.yml
  • .github/scripts/ci_config.py
  • .github/workflows/build-and-test.yml
  • .github/workflows/rust.yml
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/rust.yml

@xdustinface xdustinface merged commit ab17348 into v0.42-dev Mar 4, 2026
53 checks passed
@xdustinface xdustinface deleted the chore/coverage branch March 4, 2026 06:16
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