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

Bring codecov back #1407

Merged
merged 4 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
47 changes: 47 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,53 @@ docs:
- chown -R nonroot:nonroot ./crate-docs


codecov:
stage: workspace
<<: *docker-env
<<: *test-refs
needs:
- job: check-std
artifacts: false
variables:
# For codecov it's sufficient to run the fuzz tests only once.
QUICKCHECK_TESTS: 1
INK_COVERAGE_REPORTING: "true"
CARGO_INCREMENTAL: 0
# Needed because `codecov` requires nightly features to work
# (see `-Z` in the `RUSTFLAGS` below).
RUSTC_BOOSTRAP: 1
# Variables partly came from https://github.com/mozilla/grcov/blob/master/README.md
RUSTFLAGS: "-Zprofile -Zmir-opt-level=0 -Ccodegen-units=1
-Clink-dead-code -Copt-level=0 -Coverflow-checks=off"
# The `cargo-taurpalin` coverage reporting tool seems to have better code instrumentation and thus
# produces better results for Rust codebases in general. However, unlike `grcov` it requires
# running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead.
before_script:
- *rust-info-script
# RUSTFLAGS are the cause target cache can't be used here
# FIXME: cust-covfix doesn't support the external target dir
# https://github.com/Kogia-sima/rust-covfix/issues/7
- unset "CARGO_TARGET_DIR"
- cargo clean
# make sure there's no stale coverage artifacts
- find . -name "*.profraw" -type f -delete
- find . -name "*.gcda" -type f -delete
script:
# RUSTFLAGS are the cause target cache can't be used here
- cargo build --verbose --all-features --workspace
- cargo test --verbose --all-features --no-fail-fast --workspace
# coverage with branches
- grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info
- rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info
- codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero
# lines coverage
- grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm
--ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info
- rust-covfix lcov-lines.info --output lcov-lines-fixed.info
- codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero


#### stage: examples

examples-test:
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
Parity's ink! for writing smart contracts
</h1>

[![linux][a1]][a2] [![loc][e1]][e2] [![stack-exchange][s1]][s2]
[![linux][a1]][a2] [![codecov][c1]][c2] [![coveralls][d1]][d2] [![loc][e1]][e2] [![stack-exchange][s1]][s2]

[a1]: https://gitlab.parity.io/parity/ink/badges/master/pipeline.svg
[a2]: https://gitlab.parity.io/parity/ink/pipelines?ref=master
[c1]: https://codecov.io/gh/paritytech/ink/branch/master/graph/badge.svg
[c2]: https://codecov.io/gh/paritytech/ink/branch/master
[d1]: https://coveralls.io/repos/github/paritytech/ink/badge.svg?branch=master
[d2]: https://coveralls.io/github/paritytech/ink?branch=master
[e1]: https://tokei.rs/b1/github/paritytech/ink?category=code
[e2]: https://github.com/Aaronepower/tokei#badges
[f1]: https://img.shields.io/badge/click-blue.svg
Expand Down Expand Up @@ -158,7 +162,7 @@ mod flipper {
#[cfg(test)]
mod tests {
use super::*;

#[ink::test]
fn it_works() {
let mut flipper = Flipper::new(false);
Expand Down