Skip to content

Commit

Permalink
CI: Add automated test coverage reports. (#276)
Browse files Browse the repository at this point in the history
* initial save state, need to experiment [ skip ci]

* try config

* more vars

* not that long URL

* json is not a host

* travis has to go

* canonic way of reporting

* coveralls+ way of reporting

* nightly explicitly

* tests with for cycle

* meant to compare coverages from loop and --workspace

* Update .gitlab-ci.yml

Co-Authored-By: Hero Bird <[email protected]>

* test (ci): codecov with --workspace

* test (ci):

* test (ci): comparing test runs

* test (ci): old hack conflicts with a new one

* test (ci): -Zno-landing-pads caused test failures

* test (ci): try with cache

* test (ci): no cache and zip with tar

* test (ci): return to zip

* test (ci): no target caching, no release

* test (ci): better report

* test (ci): target dir var, cleanup after

* test (ci): final version

* test (ci): restore CI config

* change (ci): code coverage with grcov -> coveralls

* doc (ci): cleaner comments

* Update .gitlab-ci.yml

Co-Authored-By: Hero Bird <[email protected]>

* Update .gitlab-ci.yml

Co-Authored-By: Hero Bird <[email protected]>

* Update .gitlab-ci.yml

Co-Authored-By: Hero Bird <[email protected]>

* Update .gitlab-ci.yml

Co-Authored-By: Hero Bird <[email protected]>

Co-authored-by: Hero Bird <[email protected]>
  • Loading branch information
TriplEight and Robbepop authored Apr 29, 2020
1 parent a33bd04 commit ce29733
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 69 deletions.
34 changes: 28 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ variables:
- rustc -vV
- rustup show
- bash --version
- mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config
# global RUSTFLAGS overrides the linker args so this way is better to pass the flags
- printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config
# if there is no directory for this $CI_COMMIT_REF_NAME/$CI_JOB_NAME
# create such directory and
# create hardlinks recursively of all the files from the master/$CI_JOB_NAME if it exists
Expand Down Expand Up @@ -113,9 +110,34 @@ test:
needs:
- check-std
script:
- for crate in ${ALL_CRATES}; do
cargo test --verbose --all-features --release --manifest-path ${crate}/Cargo.toml;
done
- cargo test --verbose --all-features --no-fail-fast --release --workspace

codecov:
stage: workspace
<<: *docker-env
needs:
- check-std
variables:
# According to https://github.com/mozilla/grcov/blob/master/README.md
# we have to use these variables.
CARGO_INCREMENTAL: 0
# If `-Zno-landing-pads` is enabled some some tests start to fail.
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -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.
script:
# RUSTFLAGS are the cause target cache can't be used here
- unset "CARGO_TARGET_DIR"
- cargo clean
- cargo test --verbose --all-features --no-fail-fast --workspace
- cargo build --verbose --all-features --workspace
- grcov ./target -s . -t coveralls+ --guess-directory-when-missing --llvm --branch --ignore-not-existing --ignore "/*"
--token "$CODECOV_TOKEN" --commit-sha "$CI_COMMIT_SHA" --output-file ccov.json
# We'd like to not use a remote bash script for uploading the coverage reports,
# however this job seems to be more tricky than we hoped.
- bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -X gcov -f ccov.json

clippy-std:
stage: workspace
Expand Down
63 changes: 0 additions & 63 deletions .travis.yml

This file was deleted.

0 comments on commit ce29733

Please sign in to comment.