Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add Rust coverage job #706

Merged
merged 1 commit into from
Feb 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,54 @@ jobs:
name: Test (debug mode)
command: RUSTFLAGS="-Z sanitizer=address -C opt-level=0" cargo +nightly test --target x86_64-unknown-linux-gnu

bindings-rust-coverage:
docker:
- image: rust:1-buster
steps:
- checkout
- run:
name: Update environment
command: |
echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list
apt -qq update
apt -yq -t buster-backports install cmake --no-install-recommends
apt -yq install llvm-8-dev clang-8 --no-install-recommends
rustup toolchain install nightly-x86_64-unknown-linux-gnu
rustup component add llvm-tools-preview
cargo install cargo-binutils rustfilt
- run:
name: Build (debug mode)
command: RUSTFLAGS="-Z instrument-coverage" cargo +nightly build --target x86_64-unknown-linux-gnu
- run:
name: Test (debug mode)
command: RUSTFLAGS="-Z instrument-coverage -C opt-level=0" LLVM_PROFILE_FILE="fizzy-%m.profraw" cargo +nightly test --target x86_64-unknown-linux-gnu
- run:
name: Collect coverage data (Rust)
command: |
mkdir -p coverage

# Coverage from integration-test is ignored.
cargo profdata -- merge bindings/rust/fizzy-*.profraw -o default.profdata

# Guess the cargo test executable name.
OBJECT=$(find target/x86_64-unknown-linux-gnu/debug/deps -executable -name 'fizzy-*')

cargo cov -- report -use-color -instr-profile default.profdata -ignore-filename-regex='cargo/registry' -Xdemangler rustfilt $OBJECT
cargo cov -- report -instr-profile default.profdata -ignore-filename-regex='cargo/registry' -Xdemangler rustfilt $OBJECT > coverage/report.txt
cargo cov -- show -format=html -instr-profile default.profdata -ignore-filename-regex='cargo/registry' -Xdemangler rustfilt -region-coverage-lt=100 $OBJECT > coverage/missing.html
cargo cov -- show -format=html -instr-profile default.profdata -ignore-filename-regex='cargo/registry' -Xdemangler rustfilt $OBJECT > coverage/full.html
cargo cov -- export -instr-profile default.profdata -ignore-filename-regex='cargo/registry' -format=lcov $OBJECT > coverage.lcov
- store_artifacts:
path: coverage
destination: rust-coverage-unittests
- run:
name: "Upload to Codecov"
command: |
# Convert to relative paths
sed -i 's|$(pwd)/||' coverage.lcov

bash <(curl -s https://codecov.io/bash) -F rust -Z -f coverage.lcov -X gcov

workflows:
version: 2

Expand Down Expand Up @@ -668,6 +716,9 @@ workflows:
- bindings-rust-asan:
requires:
- bindings-rust
- bindings-rust-coverage:
requires:
- bindings-rust

benchmarking:
when: <<pipeline.parameters.benchmark>>
Expand Down