Skip to content

ci: fix fuzz coverage report#4522

Merged
TheBlueMatt merged 1 commit intolightningdevkit:mainfrom
joostjager:debug-fuzz-coverage
Mar 31, 2026
Merged

ci: fix fuzz coverage report#4522
TheBlueMatt merged 1 commit intolightningdevkit:mainfrom
joostjager:debug-fuzz-coverage

Conversation

@joostjager
Copy link
Copy Markdown
Contributor

@joostjager joostjager commented Mar 30, 2026

Fix fuzz coverage reporting

@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Mar 30, 2026

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@joostjager joostjager force-pushed the debug-fuzz-coverage branch 3 times, most recently from 30be0ed to 798d4ea Compare March 30, 2026 12:59
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.09%. Comparing base (688544d) to head (922d9f1).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4522      +/-   ##
==========================================
+ Coverage   86.14%   87.09%   +0.94%     
==========================================
  Files         160      162       +2     
  Lines      108046   108539     +493     
  Branches   108046   108539     +493     
==========================================
+ Hits        93080    94531    +1451     
+ Misses      12346    11524     -822     
+ Partials     2620     2484     -136     
Flag Coverage Δ
fuzzing 40.13% <ø> (?)
tests 86.19% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Since cargo-llvm-cov 0.7.0, only workspace members are instrumented
by default. Since the fuzz crate is a standalone workspace, library
crates like lightning were not instrumented, and the coverage report
was empty.

Add --dep-coverage to instrument the library path dependencies.

This alone is not sufficient for the report: --dep-coverage's report
filtering only supports crates.io deps, not path deps (per a TODO in
cargo-llvm-cov source). Add --no-default-ignore-filename-regex to
include all instrumented code, then use a custom --ignore-filename-regex
to exclude unwanted paths (cargo registry, rustup toolchains, fuzz
harness).

AI tools were used in preparing this commit.
@joostjager joostjager force-pushed the debug-fuzz-coverage branch from 798d4ea to 922d9f1 Compare March 30, 2026 13:29
@joostjager joostjager changed the title ci: dump fuzz coverage JSON for debugging ci: fix fuzz coverage report Mar 30, 2026
@joostjager
Copy link
Copy Markdown
Contributor Author

Ugh, can't get a coverage report with fuzz failing.

@joostjager joostjager marked this pull request as ready for review March 30, 2026 19:50
@joostjager joostjager requested a review from TheBlueMatt March 30, 2026 19:51
@joostjager
Copy link
Copy Markdown
Contributor Author

joostjager commented Mar 30, 2026

Fuzz passed and subsequent fuzzing coverage now gets uploaded again. The fuzzer hits 48% of channelmanager.

if [ "$OUTPUT_CODECOV_JSON" = "0" ]; then
cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR"
cargo llvm-cov --html \
--dep-coverage lightning,lightning-invoice,lightning-liquidity,lightning-rapid-gossip-sync,lightning-persister \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lightning-types is a transitive dependency (used by lightning, lightning-invoice, and lightning-liquidity) and contains non-trivial code (features.rs, payment.rs, routing.rs, string.rs). It should likely be included in the --dep-coverage list so that coverage of its code is tracked.

Similarly, possiblyrandom is a dependency of lightning and may warrant inclusion depending on whether its coverage is of interest.

echo "Replaying imported corpus (if found) via tests to generate coverage..."
cargo llvm-cov -j8 --codecov --ignore-filename-regex "fuzz/" \
cargo llvm-cov -j8 --codecov \
--dep-coverage lightning,lightning-invoice,lightning-liquidity,lightning-rapid-gossip-sync,lightning-persister \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The --dep-coverage list and the --ignore-filename-regex are now duplicated between the HTML path (lines 60-64) and the codecov JSON path (lines 85-88). If a new dependency is added to fuzz/Cargo.toml, both places must be updated in lockstep. Consider extracting these common flags into a shell variable (e.g., LLVM_COV_FLAGS) to avoid divergence.

@ldk-claude-review-bot
Copy link
Copy Markdown
Collaborator

Review Summary

Issues found: 2

  1. contrib/generate_fuzz_coverage.sh:61--dep-coverage list is missing lightning-types (and possibly possiblyrandom), which are transitive workspace dependencies exercised by fuzz targets through lightning, lightning-invoice, and lightning-liquidity. Coverage of code in those crates won't be tracked.

  2. contrib/generate_fuzz_coverage.sh:86 — The --dep-coverage and --ignore-filename-regex flags are duplicated verbatim between the two code paths (HTML report vs. codecov JSON). These could diverge silently if only one is updated. Consider extracting common flags into a variable.

@TheBlueMatt TheBlueMatt merged commit 450c03a into lightningdevkit:main Mar 31, 2026
67 of 75 checks passed
@joostjager joostjager self-assigned this Apr 2, 2026
@joostjager
Copy link
Copy Markdown
Contributor Author

Coverage looks to be there now, but there is a different problem now: https://app.codecov.io/github/lightningdevkit/rust-lightning/commit/5330f9f4802be749ed46420690497c54f658fdd5/blob/lightning/src/ln/channelmanager.rs?flags%5B0%5D=fuzzing&dropdown=coverage

When you navigate to a source file:

There was a problem getting the source code from your provider. Unable to show line by line coverage.
If you continue to experience this issue, please try logging in again to refresh your credentials.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants