Skip to content

Fix Codecov measuring and Publishing #863

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

Closed
wants to merge 13 commits into from
Closed
Changes from 8 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
48 changes: 48 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,54 @@ spellcheck:
cargo spellcheck check -vvv --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 examples/delegator/${contract}/;
done

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
# Now we're using the MIR source-based Rust test coverage, the setup assumes that default
# toolchain is nightly and both `grcov` and `rustup component add llvm-tools-preview` are
# installed on it.
RUSTFLAGS: "-Zinstrument-coverage"
LLVM_PROFILE_FILE: "llvmcoveragedata-%p-%m.profraw"
CARGO_INCREMENTAL: 0
# 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
- unset "CARGO_TARGET_DIR"
- cargo clean
script:
- cargo build --verbose --all-features --workspace
- cargo test --verbose --all-features --no-fail-fast --workspace

# Just needed as long as we have the `ink-experimental-engine` feature.
# We must additionally run the coverage without `--all-features` here -- this
# would imply the feature `ink-experimental-engine`. So in order to still run
# the tests without the experimental engine feature we need this command.
- cargo test --verbose --features std --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
# We'd like to not use a remote bash script for uploading the coverage reports,
# binary named `codecov` is already installed in the CI image, just doesn't work
# https://github.com/codecov/uploader/issues/217 https://github.com/codecov/uploader/issues/222
- bash <(curl -s https://codecov.io/bash) -t "$CODECOV_P_TOKEN" -f lcov-w-branch-fixed.info -Z
# 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
- bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -f lcov-lines-fixed.info -Z

clippy-std:
stage: workspace
<<: *docker-env
Expand Down