feat: Add a coverage helper script for development#123
Conversation
WalkthroughAdds coverage reporting infrastructure by introducing a new Bash script for LCOV-based coverage calculation, configuring bacon.toml with a coverage job and keybindings, and adding a justfile target to execute the coverage workflow. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @scripts/get-coverage.sh:
- Line 21: Add a pre-flight availability check for the cargo-llvm-cov tool in
scripts/get-coverage.sh before the existing cargo llvm-cov invocation; detect
presence with a shell check (e.g., command -v cargo-llvm-cov or checking `cargo
llvm-cov --version`), and if missing print a clear error telling the user to
install it (suggesting `cargo install cargo-llvm-cov --locked`) and exit 1 —
mirror the behavior and messaging used in the coverage.sh check (lines ~45-53)
so get-coverage.sh fails gracefully instead of producing a cryptic
command-not-found error.
🧹 Nitpick comments (1)
scripts/get-coverage.sh (1)
21-29: Consider: Error output suppression might complicate debugging.While the subsequent file existence check (lines 26-29) catches failures, suppressing stderr on lines 21 and 24 could make troubleshooting more difficult during development. For a developer-facing tool, showing errors directly might be more helpful.
💡 Optional: Preserve stderr for better debugging
-cargo llvm-cov --all-features --workspace --tests --no-report > /dev/null 2>&1 +cargo llvm-cov --all-features --workspace --tests --no-report > /dev/null-cargo llvm-cov report --lcov --output-path "$LCOV_FILE" > /dev/null 2>&1 +cargo llvm-cov report --lcov --output-path "$LCOV_FILE" > /dev/null
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
bacon.tomljustfilescripts/get-coverage.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test Coverage
🔇 Additional comments (5)
justfile (1)
230-232: LGTM! Clean addition of the coverage helper target.The new target follows the existing pattern and correctly references the new script.
bacon.toml (1)
1-11: LGTM! Well-configured bacon setup.The coverage job configuration is appropriate:
- Watch patterns correctly monitor Rust source files and manifests
- Ignore patterns exclude build artifacts and generated coverage
- The keybinding provides convenient access during development
scripts/get-coverage.sh (3)
1-8: LGTM! Solid script setup.The script correctly determines its location and navigates to the project root, with appropriate error handling via
set -e.
31-47: LGTM! Robust coverage calculation and colorization.The script correctly:
- Parses LCOV metrics using awk aggregation
- Handles division by zero (lines 34-38)
- Applies sensible color thresholds (≥80% green, ≥60% yellow, <60% red)
49-59: LGTM! Clean formatted output.The summary presentation is clear and visually appealing with appropriate use of colors and formatting.
|
|
||
| echo -e "${CYAN}→${NC} Generating coverage report..." | ||
|
|
||
| cargo llvm-cov --all-features --workspace --tests --no-report > /dev/null 2>&1 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check for cargo-llvm-cov references in documentation and setup files
echo "=== Searching for cargo-llvm-cov documentation ==="
rg -n "cargo-llvm-cov|llvm-cov" --type md --type txt -g '!scripts/get-coverage.sh' 2>/dev/null || echo "No matches in markdown/text files"
echo -e "\n=== Checking for coverage-related scripts ==="
fd -e sh . scripts/ --exec basename {} \; | head -20
echo -e "\n=== Looking at scripts directory content ==="
ls -la scripts/ | head -20
echo -e "\n=== Checking Cargo.toml for coverage-related dependencies ==="
if [ -f "Cargo.toml" ]; then
echo "=== Full Cargo.toml ==="
cat Cargo.toml | head -50
fi
echo -e "\n=== Checking for CI/CD configuration files ==="
fd -e yml -e yaml . .github --max-depth 2 2>/dev/null | head -10
echo -e "\n=== Checking README for dependency info ==="
if [ -f "README.md" ]; then
echo "=== Checking README.md ==="
head -100 README.md
fiRepository: marmot-protocol/mdk
Length of output: 7604
🏁 Script executed:
cat -n scripts/get-coverage.sh
echo -e "\n=== Also checking coverage.sh ==="
cat -n scripts/coverage.shRepository: marmot-protocol/mdk
Length of output: 5349
Add cargo-llvm-cov availability check before invoking the tool.
The coverage.sh script already includes this check (lines 45-53), but get-coverage.sh does not. Add a similar check to fail gracefully with installation instructions if cargo-llvm-cov is not installed, rather than failing with a cryptic command-not-found error.
🤖 Prompt for AI Agents
In @scripts/get-coverage.sh at line 21, Add a pre-flight availability check for
the cargo-llvm-cov tool in scripts/get-coverage.sh before the existing cargo
llvm-cov invocation; detect presence with a shell check (e.g., command -v
cargo-llvm-cov or checking `cargo llvm-cov --version`), and if missing print a
clear error telling the user to install it (suggesting `cargo install
cargo-llvm-cov --locked`) and exit 1 — mirror the behavior and messaging used in
the coverage.sh check (lines ~45-53) so get-coverage.sh fails gracefully instead
of producing a cryptic command-not-found error.
A super simple small dev utility I made for myself. I keep bacon running on my third monitor during dev to watch tests, errors, and clippy warnings. This adds our coverage test as a single keypress (v in bacon), so I can quickly check coverage without switching away.
Usage
In bacon, just hit
v. Or from terminal:Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.