Unverified Commit ce29733a authored by Denis_P's avatar Denis_P 🏑 Committed by GitHub
Browse files

CI: Add automated test coverage reports. (#276)

* 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: default avatarHero Bird <robin.freyler@gmail.com>

* 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: default avatarHero Bird <robin.freyler@gmail.com>

* Update .gitlab-ci.yml

Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

* Update .gitlab-ci.yml

Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

* Update .gitlab-ci.yml

Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

Co-authored-by: default avatarHero Bird <robin.freyler@gmail.com>
parent a33bd043
Pipeline #90273 failed with stages
in 6 minutes and 23 seconds
......@@ -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
......@@ -113,9 +110,34 @@ test:
- check-std
- for crate in ${ALL_CRATES}; do
cargo test --verbose --all-features --release --manifest-path ${crate}/Cargo.toml;
- cargo test --verbose --all-features --no-fail-fast --release --workspace
stage: workspace
<<: *docker-env
- check-std
# According to https://github.com/mozilla/grcov/blob/master/README.md
# we have to use these variables.
# 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.
# RUSTFLAGS are the cause target cache can't be used here
- 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
stage: workspace
language: rust
cache: cargo
dist: trusty
sudo: true
- master
- nightly-2019-11-17
- rust: nightly
- RUSTFLAGS="-C link-dead-code"
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- binutils-dev
- libiberty-dev
- g++
- cmake
- zlib1g-dev
# Print rustc and cargo versions
- rustc -vV
- cargo -vV
- bash --version
# Install cargo-kcov Cargo plugin
- cargo install --force cargo-kcov
- cargo kcov -vV
# Install kcov binary
- wget https://github.com/SimonKagstrom/kcov/archive/v36.tar.gz
- tar xzf v36.tar.gz
- pushd kcov-36
- mkdir build
- pushd build
- cmake ..
- make
- sudo make install # Puts kcov in the default location usually /usr/local/bin/kcov
- kcov --version
- popd
- popd
# Export cargo binaries, python and misc settings
- export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$HOME/Library/Python/2.7/bin:$PATH
# Print current work directory state as directions.
- ls -lah
- |
cargo test --all-features --all
cargo kcov --verbose --coveralls --all --no-clean-rebuild
bash <(curl -s https://codecov.io/bash)
exit 0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment