Skip to content

ci: add code coverage workflow#45

Merged
ValuedMammal merged 1 commit intobitcoindevkit:masterfrom
noahjoeris:feat/coverage-workflow
Apr 21, 2026
Merged

ci: add code coverage workflow#45
ValuedMammal merged 1 commit intobitcoindevkit:masterfrom
noahjoeris:feat/coverage-workflow

Conversation

@noahjoeris
Copy link
Copy Markdown
Contributor

Description

This PR adds CI code coverage workflow. I tried to be as close to the bdk flow as possible. Adapted minor things to this repo.

Closes #8

@noahjoeris
Copy link
Copy Markdown
Contributor Author

noahjoeris commented Apr 8, 2026

I just saw the issue linked to an older bdk code_coverage.yml. I'll try to update. -> Done

@noahjoeris noahjoeris force-pushed the feat/coverage-workflow branch from a240bdb to c614e29 Compare April 8, 2026 11:58
@ValuedMammal
Copy link
Copy Markdown
Collaborator

Thank you @noahjoeris just noting that I think there are plans to switch to codecov-action for uploading coverage reports using BDK's CODECOV_TOKEN (bitcoindevkit/bdk#2144), maybe we can try that here?

@noahjoeris noahjoeris force-pushed the feat/coverage-workflow branch from c614e29 to 43f5537 Compare April 8, 2026 18:03
@noahjoeris
Copy link
Copy Markdown
Contributor Author

Changed it to codecov. You might still need to set the codecov token tho :)

@ValuedMammal
Copy link
Copy Markdown
Collaborator

The token exists at the org level but maybe not activated for this repo yet. While I look into it here's some additional notes

  • We can probably exclude unit/integration test modules from coverage as well
  • I'm not sure what --doctests is doing and seems to have produced a warning but I didn't investigate
  • It would be ideal to try cargo llvm-cov with a more recent version of the nightly compiler
  • Unrelated, but we should also using caching in rust.yml which is made easy by actions-rust-lang/setup-rust-toolchain

@noahjoeris noahjoeris force-pushed the feat/coverage-workflow branch from 43f5537 to bfee893 Compare April 10, 2026 14:37
@noahjoeris
Copy link
Copy Markdown
Contributor Author

Good points thx. I updated.

@ValuedMammal
Copy link
Copy Markdown
Collaborator

Ah I think merging to master is all that's needed for codecov.io.

@ValuedMammal
Copy link
Copy Markdown
Collaborator

Can we add this? ValuedMammal@8d2ea5b

@noahjoeris noahjoeris force-pushed the feat/coverage-workflow branch from bfee893 to effacf2 Compare April 21, 2026 12:34
@noahjoeris noahjoeris force-pushed the feat/coverage-workflow branch from effacf2 to cb52b8c Compare April 21, 2026 12:40
@noahjoeris
Copy link
Copy Markdown
Contributor Author

Cool, I added it. Seems to work and exclude unit tests. Though I get this warn.

warning: feature `coverage_attribute` is declared but not used

cargo llvm-cov compiles the crate twice, once as the library (no cfg(test)), once as the test binary. In the library pass, #[cfg(test)] mod tests is stripped before attribute checking, so rustc never sees #[coverage(off)] being used and flags the feature as unused. In the test pass it's seen and works as intended.

We probably don't want to just silence it with: #![cfg_attr(coverage_nightly, allow(unused_features))]. Can we live with that warning?

Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

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

ACK cb52b8c

@ValuedMammal ValuedMammal merged commit 8142a66 into bitcoindevkit:master Apr 21, 2026
7 checks passed
@ValuedMammal
Copy link
Copy Markdown
Collaborator

In the library pass, #[cfg(test)] mod tests is stripped before attribute checking, so rustc never sees #[coverage(off)] being used and flags the feature as unused.

I tried to reproduce the warning in bdk_wallet with no success. I suppose one fix could be to use coverage(off) for a non-test item like a Display impl.

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.

[ci] Add code coverage workflow

2 participants