Skip to content

feat: Add a coverage helper script for development#123

Merged
dannym-arx merged 1 commit intomasterfrom
coverage-helper
Jan 9, 2026
Merged

feat: Add a coverage helper script for development#123
dannym-arx merged 1 commit intomasterfrom
coverage-helper

Conversation

@dannym-arx
Copy link
Contributor

@dannym-arx dannym-arx commented Jan 7, 2026

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:

just coverage-during-dev

Summary by CodeRabbit

  • Chores
    • Added comprehensive coverage reporting configuration and automation to the development build system.
    • New coverage command enables automated test coverage analysis with LCOV report generation and color-coded result display.
    • Coverage tracking configured for workspace-wide testing across all feature combinations.

✏️ Tip: You can customize this high-level summary in your review settings.

@dannym-arx dannym-arx added the no-changelog This PR will skip changelog update checks label Jan 7, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Walkthrough

Adds 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

Cohort / File(s) Summary
Configuration & Build Files
bacon.toml, justfile
New bacon.toml with coverage job configuration, default job setting, environment variables, and keybinding mapping. New coverage-during-dev target added to justfile for coverage execution.
Coverage Script
scripts/get-coverage.sh
New Bash script automating Rust coverage reporting with LCOV parsing, color-coded output based on thresholds (green ≥80%, yellow ≥60%, red otherwise), and formatted coverage summary display. Includes error handling for report generation failures.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 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 clearly and concisely summarizes the main purpose of the changeset: adding a coverage helper script for development.
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 docstrings

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.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

⚠️ Coverage: 87.44% → 87.44% (0.00%)

Copy link

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 51b8ec5 and a668db1.

📒 Files selected for processing (3)
  • bacon.toml
  • justfile
  • scripts/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
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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
fi

Repository: 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.sh

Repository: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR will skip changelog update checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants