Skip to content

Commit 066c4cd

Browse files
committed
ci: replace grcov by cargo-llvm-cov
1 parent d9c2b95 commit 066c4cd

File tree

16 files changed

+25
-14
lines changed

16 files changed

+25
-14
lines changed

.github/workflows/code_coverage.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ jobs:
88
Codecov:
99
name: Code Coverage
1010
runs-on: ubuntu-latest
11-
env:
12-
RUSTFLAGS: "-Cinstrument-coverage"
13-
RUSTDOCFLAGS: "-Cinstrument-coverage"
14-
LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw"
15-
1611
steps:
1712
- name: Checkout
1813
uses: actions/checkout@v4
@@ -23,20 +18,18 @@ jobs:
2318
- name: Install Rust toolchain
2419
uses: actions-rs/toolchain@v1
2520
with:
26-
toolchain: stable
21+
toolchain: nightly
2722
override: true
2823
profile: minimal
2924
components: llvm-tools-preview
3025
- name: Rust Cache
3126
uses: Swatinem/rust-cache@v2.7.8
32-
- name: Install grcov
33-
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
34-
- name: Test
35-
run: cargo test --all-features
27+
- name: Install cargo-llvm-cov
28+
run: if [[ ! -e ~/.cargo/bin/cargo-llvm-cov ]]; then cargo install cargo-llvm-cov; fi
3629
- name: Make coverage directory
3730
run: mkdir coverage
38-
- name: Run grcov
39-
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/crates/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
31+
- name: Test and report coverage
32+
run: cargo +nightly llvm-cov -q --doctests --branch --all --ignore-filename-regex "(example*|crates/testenv/*)" --all-features --lcov --output-path ./coverage/lcov.info
4033
- name: Generate HTML coverage report
4134
run: genhtml -o coverage-report.html --ignore-errors unmapped ./coverage/lcov.info
4235
- name: Coveralls upload

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ authors = ["Bitcoin Dev Kit Developers"]
2020
[workspace.lints.clippy]
2121
print_stdout = "deny"
2222
print_stderr = "deny"
23+
24+
[workspace.lints.rust]
25+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }

crates/bitcoind_rpc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! To only get block updates (exclude mempool transactions), the caller can use
88
//! [`Emitter::next_block`] until it returns `Ok(None)` (which means the chain tip is reached). A
99
//! separate method, [`Emitter::mempool`] can be used to emit the whole mempool.
10+
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
1011
#![warn(missing_docs)]
1112

1213
use bdk_core::{BlockId, CheckPoint};
@@ -444,6 +445,7 @@ impl BitcoindRpcErrorExt for bitcoincore_rpc::Error {
444445
}
445446

446447
#[cfg(test)]
448+
#[cfg_attr(coverage_nightly, coverage(off))]
447449
mod test {
448450
use crate::{bitcoincore_rpc::RpcApi, Emitter, NO_EXPECTED_MEMPOOL_TXIDS};
449451
use bdk_chain::local_chain::LocalChain;

crates/chain/src/chain_data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl<A: Anchor> FullTxOut<A> {
164164
}
165165

166166
#[cfg(test)]
167+
#[cfg_attr(coverage_nightly, coverage(off))]
167168
mod test {
168169
use bdk_core::ConfirmationBlockTime;
169170

crates/chain/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)]
2626
#![no_std]
2727
#![warn(missing_docs)]
28+
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
2829

2930
pub use bitcoin;
3031
mod balance;

crates/chain/src/rusqlite_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ impl keychain_txout::ChangeSet {
660660
}
661661

662662
#[cfg(test)]
663+
#[cfg_attr(coverage_nightly, coverage(off))]
663664
mod test {
664665
use super::*;
665666

crates/chain/src/spk_iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ where
134134
}
135135

136136
#[cfg(test)]
137+
#[cfg_attr(coverage_nightly, coverage(off))]
137138
mod test {
138139
use crate::{
139140
bitcoin::secp256k1::Secp256k1,

crates/electrum/src/bdk_electrum_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ fn chain_update(
685685
}
686686

687687
#[cfg(test)]
688+
#[cfg_attr(coverage_nightly, coverage(off))]
688689
mod test {
689690
use crate::{bdk_electrum_client::TxUpdate, BdkElectrumClient};
690691
use bdk_chain::bitcoin::{OutPoint, Transaction, TxIn};

crates/electrum/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/examples/example_electrum
1717
//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
1818
//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse
19-
19+
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
2020
#![warn(missing_docs)]
2121

2222
mod bdk_electrum_client;

crates/esplora/src/async_ext.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ where
550550
}
551551

552552
#[cfg(test)]
553+
#[cfg_attr(coverage_nightly, coverage(off))]
553554
mod test {
554555
use std::{collections::BTreeSet, time::Duration};
555556

0 commit comments

Comments
 (0)