Skip to content

Commit d8083c7

Browse files
committed
Add codecov ci workflow
1 parent 519a4cf commit d8083c7

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/code_coverage.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
on: [push, pull_request]
2+
3+
name: Code Coverage
4+
5+
jobs:
6+
Codecov:
7+
name: Code Coverage
8+
runs-on: ubuntu-latest
9+
env:
10+
RUSTFLAGS: "-Cinstrument-coverage"
11+
RUSTDOCFLAGS: "-Cinstrument-coverage"
12+
LLVM_PROFILE_FILE: "report-%p-%m.profraw"
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Install lcov tools
18+
run: sudo apt-get install lcov -y
19+
- name: Install rustup
20+
run: curl https://sh.rustup.rs -sSf | sh -s -- -y
21+
- name: Set default toolchain
22+
run: rustup default nightly
23+
- name: Set profile
24+
run: rustup set profile minimal
25+
- name: Add llvm tools
26+
run: rustup component add llvm-tools-preview
27+
- name: Update toolchain
28+
run: rustup update
29+
- name: Cache cargo
30+
uses: actions/cache@v3
31+
with:
32+
path: |
33+
~/.cargo/bin/
34+
~/.cargo/registry/index/
35+
~/.cargo/registry/cache/
36+
~/.cargo/git/db/
37+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+
- name: Install grcov
39+
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
40+
- name: Test
41+
# WARNING: this is not testing the following features: test-esplora, test-hardware-signer, async-interface
42+
# This is because some of our features are mutually exclusive, and generating various reports and
43+
# merging them doesn't seem to be working very well.
44+
# For more info, see:
45+
# - https://github.com/bitcoindevkit/bdk/issues/696
46+
# - https://github.com/bitcoindevkit/bdk/pull/748#issuecomment-1242721040
47+
run: cargo test
48+
- name: Run grcov
49+
run: mkdir coverage; grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '/*' -o ./coverage/lcov.info
50+
- name: Generate HTML coverage report
51+
run: genhtml -o coverage-report.html ./coverage/lcov.info
52+
53+
- name: Coveralls upload
54+
uses: coverallsapp/github-action@master
55+
with:
56+
github-token: ${{ secrets.GITHUB_TOKEN }}
57+
- name: Upload artifact
58+
uses: actions/upload-artifact@v2
59+
with:
60+
name: coverage-report
61+
path: coverage-report.html

0 commit comments

Comments
 (0)