From 3c853126de917b2534bc1883e0d865bc073c58ba Mon Sep 17 00:00:00 2001 From: Arturo Marquez Date: Thu, 6 Jan 2022 14:05:17 -0600 Subject: [PATCH] Add `coverage` job Following instructions at: `https://www.collabora.com/news-and-blog/blog/2021/03/24/rust-integrating-llvm-source-base-code-coverage-with-gitlab/` --- .gitlab-ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b237cd071..b6f2bf5aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,6 +50,31 @@ rust-nightly: tags: - amd64 +coverage: + stage: test + image: rustlang/rust:nightly + variables: + RUSTFLAGS: "-Zinstrument-coverage" + LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" + script: + - rustup component add llvm-tools-preview + - cargo test + # generate html report + - cargo install grcov + - grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --ignore "*cargo*" -o ./coverage/ + # generate cobertura report for gitlab integration + - pip3 install lcov_cobertura + - grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "*cargo*" -o coverage.lcov + - python3 /usr/local/lib/python3.5/dist-packages/lcov_cobertura.py coverage.lcov + # output coverage summary for gitlab parsing + - apt-get update && apt-get install -y lcov + - lcov --summary coverage.lcov + artifacts: + paths: + - 'coverage' + reports: + cobertura: coverage.xml + minimal-versions: stage: test image: rust:1.53