]> Untitled Git - bdk/commitdiff
ci: replace grcov by cargo-llvm-cov
authornymius <155548262+nymius@users.noreply.github.com>
Wed, 2 Jul 2025 14:10:20 +0000 (11:10 -0300)
committernymius <155548262+nymius@users.noreply.github.com>
Fri, 11 Jul 2025 12:31:29 +0000 (09:31 -0300)
16 files changed:
.github/workflows/code_coverage.yml
Cargo.toml
crates/bitcoind_rpc/src/lib.rs
crates/chain/src/chain_data.rs
crates/chain/src/lib.rs
crates/chain/src/rusqlite_impl.rs
crates/chain/src/spk_iter.rs
crates/electrum/src/bdk_electrum_client.rs
crates/electrum/src/lib.rs
crates/esplora/src/async_ext.rs
crates/esplora/src/blocking_ext.rs
crates/esplora/src/lib.rs
crates/file_store/src/lib.rs
crates/file_store/src/store.rs
crates/testenv/Cargo.toml
crates/testenv/src/lib.rs

index 618e5dc0d9e57823431504d0f6ab3b29b583387a..d6d8e9acf1ff4e7c083a5ae3be61334a13953343 100644 (file)
@@ -8,11 +8,6 @@ jobs:
   Codecov:
     name: Code Coverage
     runs-on: ubuntu-latest
-    env:
-      RUSTFLAGS: "-Cinstrument-coverage"
-      RUSTDOCFLAGS: "-Cinstrument-coverage"
-      LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw"
-
     steps:
       - name: Checkout
         uses: actions/checkout@v4
@@ -23,20 +18,18 @@ jobs:
       - name: Install Rust toolchain
         uses: actions-rs/toolchain@v1
         with:
-            toolchain: stable
+            toolchain: nightly
             override: true
             profile: minimal
             components: llvm-tools-preview
       - name: Rust Cache
         uses: Swatinem/rust-cache@v2.7.8
-      - name: Install grcov
-        run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
-      - name: Test
-        run: cargo test --all-features
+      - name: Install cargo-llvm-cov
+        run: if [[ ! -e ~/.cargo/bin/cargo-llvm-cov ]]; then cargo install cargo-llvm-cov; fi
       - name: Make coverage directory
         run: mkdir coverage
-      - name: Run grcov
-        run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/crates/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
+      - name: Test and report coverage
+        run: cargo +nightly llvm-cov -q --doctests --branch --all --ignore-filename-regex "(example*|crates/testenv/*)" --all-features --lcov --output-path ./coverage/lcov.info
       - name: Generate HTML coverage report
         run: genhtml -o coverage-report.html --ignore-errors unmapped ./coverage/lcov.info
       - name: Coveralls upload
index 0a62ba43ae6e638d12f1eae13f5f3297d1d6d376..d505c1a0a9908844cc0eac359fde67d240ea43c0 100644 (file)
@@ -20,3 +20,6 @@ authors = ["Bitcoin Dev Kit Developers"]
 [workspace.lints.clippy]
 print_stdout = "deny"
 print_stderr = "deny"
+
+[workspace.lints.rust]
+unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
index 250ff430691dfcc2e789bb461aa254030da8b9aa..8ab3a44826796299fb120956b5e115b525590581 100644 (file)
@@ -7,6 +7,7 @@
 //! To only get block updates (exclude mempool transactions), the caller can use
 //! [`Emitter::next_block`] until it returns `Ok(None)` (which means the chain tip is reached). A
 //! separate method, [`Emitter::mempool`] can be used to emit the whole mempool.
+#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
 #![warn(missing_docs)]
 
 use bdk_core::{BlockId, CheckPoint};
@@ -444,6 +445,7 @@ impl BitcoindRpcErrorExt for bitcoincore_rpc::Error {
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use crate::{bitcoincore_rpc::RpcApi, Emitter, NO_EXPECTED_MEMPOOL_TXIDS};
     use bdk_chain::local_chain::LocalChain;
index ea088934bcf8ccf8874f6e5ac35024eaf51b956a..b641f15ecf60efa06b69f66a8322594343ef0aa7 100644 (file)
@@ -164,6 +164,7 @@ impl<A: Anchor> FullTxOut<A> {
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use bdk_core::ConfirmationBlockTime;
 
index 21ead1590454da0fda8eed4f94cd4cf7d026c162..0cb5b48d39d9a42143b5f05630850e1fa0d94ef5 100644 (file)
@@ -25,6 +25,7 @@
 )]
 #![no_std]
 #![warn(missing_docs)]
+#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
 
 pub use bitcoin;
 mod balance;
index 38f76b12e09b5347a1a724aab4370d9fbe751d4b..7e9e2f6f9f8878d1e815b1568eef6df2a3d28a76 100644 (file)
@@ -660,6 +660,7 @@ impl keychain_txout::ChangeSet {
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use super::*;
 
index 64f38c6dc0c49631ff18b8640278605f5218f69c..2353807a77b6e27f84c01d4e44056b8ce327105d 100644 (file)
@@ -134,6 +134,7 @@ where
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use crate::{
         bitcoin::secp256k1::Secp256k1,
index b0b30ea6812802d2725f315de7d339bf096c8528..8358cae830729236b0e45c36c49f1cba1a0dd631 100644 (file)
@@ -685,6 +685,7 @@ fn chain_update(
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use crate::{bdk_electrum_client::TxUpdate, BdkElectrumClient};
     use bdk_chain::bitcoin::{OutPoint, Transaction, TxIn};
index d791f962e6e9b4e82d96615286a49491d9958df6..9c1d9f452c93453a6f4a0f324d39b2eb277851bc 100644 (file)
@@ -16,7 +16,7 @@
 //! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/examples/example_electrum
 //! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
 //! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse
-
+#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
 #![warn(missing_docs)]
 
 mod bdk_electrum_client;
index dc82063bd661c754ece63b3fc0e499ec70f9e77d..c0e55ab50764a342e91d51dd19497995692bdf1b 100644 (file)
@@ -550,6 +550,7 @@ where
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use std::{collections::BTreeSet, time::Duration};
 
index 60588376140fa56f065a1f57c966c369b6939d17..5a52b7a098f91c3f413d337c931ef024431339e6 100644 (file)
@@ -509,6 +509,7 @@ fn fetch_txs_with_outpoints<I: IntoIterator<Item = OutPoint>>(
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use crate::blocking_ext::{chain_update, fetch_latest_blocks};
     use bdk_chain::bitcoin;
index a88c266a0660cc29baf53209ed3cc3249c64541a..60b4f1eb3f60a68b3aa9ebc1771684d7b8265830 100644 (file)
@@ -19,6 +19,7 @@
 //! Just like how [`EsploraExt`] extends the functionality of an
 //! [`esplora_client::BlockingClient`], [`EsploraAsyncExt`] is the async version which extends
 //! [`esplora_client::AsyncClient`].
+#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
 
 use bdk_core::bitcoin::{Amount, OutPoint, TxOut, Txid};
 use bdk_core::{BlockId, ConfirmationBlockTime, TxUpdate};
index 8b76473d518d8d4312326e2ebf5c0be5dfc7fe96..d7dd35bf477a64e7f320d0d970428b1c05ac1e1b 100644 (file)
@@ -1,4 +1,5 @@
 #![doc = include_str!("../README.md")]
+#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
 mod entry_iter;
 mod store;
 use std::io;
index da1fda0b9de969ba9f069160d26744ee49ffd210..1bea6c83e310475c84c34345d173bb058ee02798 100644 (file)
@@ -281,6 +281,7 @@ impl<C> std::fmt::Display for StoreErrorWithDump<C> {
 impl<C: fmt::Debug> std::error::Error for StoreErrorWithDump<C> {}
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use super::*;
 
index ad544e725cb3317bb186ca23b08c76a2376aa5a0..8c02bf645e51cef05ae65c3fbac3e6c184b4eae1 100644 (file)
@@ -29,4 +29,4 @@ std = ["bdk_chain/std"]
 serde = ["bdk_chain/serde"]
 
 [package.metadata.docs.rs]
-no-default-features = true
\ No newline at end of file
+no-default-features = true
index 2c0f15f643160d6774d12b5d6c0ac1043986b3d4..9faf43bf202a17a0c2671d00f42e9cee6f962a7b 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
+
 pub mod utils;
 
 use bdk_chain::{
@@ -311,6 +313,7 @@ impl TestEnv {
 }
 
 #[cfg(test)]
+#[cfg_attr(coverage_nightly, coverage(off))]
 mod test {
     use crate::TestEnv;
     use core::time::Duration;