Skip to content

Commit 5d1604d

Browse files
authored
Add code coverage step in CircleCi configuration (#33)
1 parent 08a3496 commit 5d1604d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

.circleci/config.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ jobs:
1717
- run: cargo test --all-features
1818
- run: cargo doc --no-deps
1919
- run: cargo clippy --all-features -- -D warnings
20-
2120
- store_artifacts:
2221
path: target/doc
2322
destination: doc
23+
- run:
24+
name: Gather Coverage
25+
command: ./coverage.sh --html
26+
- store_artifacts:
27+
name: Upload Coverage
28+
path: target/llvm-cov/html
29+
destination: coverage
2430
- run:
2531
command: make start-contract-test-service
2632
background: true

coverage.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
# We are using an older version of the toolchain for now as there is a bug with
7+
# coverage generation. See https://github.com/rust-lang/rust/issues/79645
8+
export RUSTUP_TOOLCHAIN=nightly-2022-01-09
9+
10+
# cargo-llvm-cov requires the nightly compiler to be installed
11+
rustup toolchain install $RUSTUP_TOOLCHAIN
12+
rustup component add llvm-tools-preview --toolchain $RUSTUP_TOOLCHAIN
13+
cargo install cargo-llvm-cov
14+
15+
# generate coverage report to command line by default; otherwise allow
16+
# CI to pass in '--html' (or other formats).
17+
18+
if [ -n "$1" ]; then
19+
cargo llvm-cov --all-features --workspace "$1"
20+
else
21+
cargo llvm-cov --all-features --workspace
22+
fi

0 commit comments

Comments
 (0)