Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit ad93795

Browse files
sausageebors-libra
authored andcommittedNov 15, 2019
[CI] add code coverage by grcov
We need to track the code coverage to make sure the basic testing is in place to exercise all the code. We are adding grcov to the CI pipeline to collect and aggregate code coverage. The coverage result is uploaded to codecov.io. The dashboard can help visualize the breakdown of test coverage. Closes: #1420 Approved by: bob-wilson
1 parent 907dc9a commit ad93795

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed
 

‎.circleci/config.yml

+30
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ commands:
5151
sudo apt-get clean
5252
sudo rm -r /var/lib/apt/lists/*
5353
rustup component add clippy rustfmt
54+
install_code_coverage_deps:
55+
steps:
56+
- run:
57+
name: Install grcov and lcov
58+
command: |
59+
sudo apt-get update
60+
sudo apt-get install lcov
61+
cargo install --force grcov
62+
install_rust_nightly_toolchain:
63+
steps:
64+
- run:
65+
name: Install nightly toolchain for features not in beta/stable
66+
command: rustup install nightly
5467
build_setup:
5568
steps:
5669
- checkout
@@ -138,6 +151,22 @@ jobs:
138151
cargo install --force cargo-audit
139152
cargo audit
140153
- build_teardown
154+
code-coverage:
155+
description: Run code coverage
156+
executor: build-executor
157+
steps:
158+
- build_setup
159+
- install_code_coverage_deps
160+
- install_rust_nightly_toolchain
161+
- run:
162+
name: Setup code coverage output
163+
command: echo "export CODECOV_OUTPUT=codecov" >> $BASH_ENV
164+
- run:
165+
name: Run code coverage
166+
command: ./scripts/coverage_report.sh . $CODECOV_OUTPUT --batch
167+
- run:
168+
name: Upload result to codecov.io
169+
command: bash <(curl -s https://codecov.io/bash) -f $CODECOV_OUTPUT/lcov.info;
141170
terraform:
142171
executor: terraform-executor
143172
steps:
@@ -203,3 +232,4 @@ workflows:
203232
only: master
204233
jobs:
205234
- audit
235+
- code-coverage

‎codecov.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
codecov:
3+
require_ci_to_pass: true
4+
5+
ignore:
6+
- testsuite/*
7+
- x/*
8+
9+
coverage:
10+
# range for color spectrum display, red=50%, green=80%
11+
range: "50...80"
12+
round: down
13+
precision: 1
14+
15+
status:
16+
project: true
17+
patch: true
18+
changes: false

‎scripts/coverage_report.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ echo "Cleaning project..."
8484
echo "Running tests..."
8585
while read -r line; do
8686
dirline=$(realpath $(dirname "$line"));
87-
(cd "$dirline" && pwd && cargo xtest)
87+
# Don't fail out of the loop here. We just want to run the test binary
88+
# to collect its profile data.
89+
(cd "$dirline" && pwd && cargo xtest || true)
8890
done < <(find "$TEST_DIR" -name 'Cargo.toml')
8991

9092
# Make the coverage directory if it doesn't exist

0 commit comments

Comments
 (0)
This repository has been archived.