chore: add codecov coverage tracking#493
Conversation
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
9f39c71 to
f9baf1a
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
.codecov.yml.github/scripts/ci_config.py.github/workflows/build-and-test.yml.github/workflows/rust.ymlREADME.md
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
README.md (1)
14-15:⚠️ Potential issue | 🟡 MinorUse 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
📒 Files selected for processing (5)
.codecov.yml.github/scripts/ci_config.py.github/workflows/build-and-test.yml.github/workflows/rust.ymlREADME.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
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/scripts/ci_config.py (1)
179-188:⚠️ Potential issue | 🟡 MinorEmit
crate_flagsfrom executed crates, not configured crates.Line 179 exports all group crates before the skip at Lines 186-188, so skipped crates (e.g.,
dash-fuzzon 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=Trueat Line 181, an exception bypasses Line 182 and leaves the group unclosed. Wrap withtry/finallyand 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
📒 Files selected for processing (4)
.codecov.yml.github/scripts/ci_config.py.github/workflows/build-and-test.ymlREADME.md
🚧 Files skipped from review as they are similar to previous changes (1)
- .codecov.yml
12ab005 to
1b4e854
Compare
Inspired by #492 but integrated into the existing workflows.
1b4e854 to
f17bfc9
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/scripts/ci_config.py (1)
176-180:⚠️ Potential issue | 🟠 MajorReset coverage artifacts before emitting and collecting coverage flags.
Line 179 enables coverage reporting without first cleaning prior
llvm-covartifacts. 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
📒 Files selected for processing (5)
.codecov.yml.github/scripts/ci_config.py.github/workflows/build-and-test.yml.github/workflows/rust.ymlREADME.md
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/rust.yml
Inspired by #492 but integrated into the existing workflows.
Summary by CodeRabbit
Documentation
Chores