Unverified Commit ce29733a authored by Denis_P's avatar Denis_P 👙 Committed by GitHub

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:
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
......
language: rust
cache: cargo
dist: trusty
sudo: true
branches:
only:
- master
rust:
- nightly-2019-11-17
matrix:
allow_failures:
- rust: nightly
env:
global:
- RUSTFLAGS="-C link-dead-code"
addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- binutils-dev
- libiberty-dev
- g++
- cmake
- zlib1g-dev
install:
# 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
script:
- |
cargo test --all-features --all
cargo kcov --verbose --coveralls --all --no-clean-rebuild
bash <(curl -s https://codecov.io/bash)
exit 0
Markdown is supported
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