Skip to content

Commit effacf2

Browse files
committed
ci: add code coverage workflow
1 parent 338857f commit effacf2

6 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Code Coverage
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
pull-requests: write
8+
9+
jobs:
10+
Coverage:
11+
name: Code Coverage
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v6
16+
with:
17+
persist-credentials: false
18+
- name: Install Rust toolchain
19+
uses: actions-rust-lang/setup-rust-toolchain@v1
20+
with:
21+
toolchain: nightly-2026-04-09
22+
override: true
23+
cache: true
24+
components: llvm-tools-preview
25+
- name: Install cargo-llvm-cov
26+
run: if [[ ! -e ~/.cargo/bin/cargo-llvm-cov ]]; then cargo install cargo-llvm-cov; fi
27+
- name: Make coverage directory
28+
run: mkdir coverage
29+
- name: Test and export lcov coverage
30+
run: cargo llvm-cov -q --branch --all --ignore-filename-regex "(examples/|tests/)" --all-features --lcov --output-path ./coverage/lcov.info
31+
env:
32+
RUSTFLAGS: "--cfg coverage_nightly"
33+
- name: Generate HTML coverage report
34+
run: cargo llvm-cov -q --branch --all --ignore-filename-regex "(examples/|tests/)" --all-features --html
35+
env:
36+
RUSTFLAGS: "--cfg coverage_nightly"
37+
- name: Codecov upload
38+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
39+
with:
40+
files: ./coverage/lcov.info
41+
flags: rust
42+
name: codecov-bdk-tx
43+
token: ${{ secrets.CODECOV_TOKEN }}
44+
fail_ci_if_error: false
45+
- name: Upload artifact
46+
uses: actions/upload-artifact@v7
47+
with:
48+
name: coverage-report
49+
path: target/llvm-cov/html

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ description = "Bitcoin transaction building library."
1010
license = "MIT OR Apache-2.0"
1111
readme = "README.md"
1212

13+
[lints.rust]
14+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
15+
1316
[dependencies]
1417
miniscript = { version = "12.3.5", default-features = false }
1518
bdk_coin_select = "0.4.0"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! `bdk_tx`
2+
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
23
#![warn(missing_docs)]
34
#![no_std]
45

src/selection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ impl Selection {
299299
}
300300
}
301301

302+
#[cfg_attr(coverage_nightly, coverage(off))]
302303
#[cfg(test)]
303304
mod tests {
304305
use super::*;

src/selector.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ impl<'c> Selector<'c> {
339339
}
340340
}
341341

342+
#[cfg_attr(coverage_nightly, coverage(off))]
342343
#[cfg(test)]
343344
mod tests {
344345
use super::*;

src/signer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl GetKey for Signer {
6666
}
6767
}
6868

69+
#[cfg_attr(coverage_nightly, coverage(off))]
6970
#[cfg(test)]
7071
mod test {
7172
use crate::bitcoin::bip32::ChildNumber;

0 commit comments

Comments
 (0)