From af6f32a9ce594b7e8b8279e400057e05d684cfeb Mon Sep 17 00:00:00 2001 From: Anson Date: Sat, 5 Nov 2022 22:59:04 -0600 Subject: [PATCH] trying to fix coverage --- .gitlab-ci.yml | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 804c08c..e303ae5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -101,26 +101,24 @@ test: - cargo test --all coverage: - image: 'rustlang/rust:nightly-bullseye' - stage: test - extends: .common - needs: - - job: check - artifacts: false + image: "rustdocker/rust:nightly" + stage: extras variables: RUSTFLAGS: "-Zinstrument-coverage" LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" - before_script: - - rustup component add llvm-tools-preview - - curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - script: - - cargo +nightly test - - ./grcov . --binary-path ./target/debug/ -s . -t cobertura --branch --ignore-not-existing --ignore "*cargo*" -o coverage.xml - - grep -Eo 'line-rate="[^"]+"' coverage.xml | head -n 1 | grep -Eo '[0-9.]+' | awk '{ print "Coverage:", $1 * 100 }' - coverage: '/Coverage: \d+\.\d+/' + - 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 artifacts: - name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA} - expire_in: 2 days reports: - cobertura: coverage.xml - + coverage_report: + coverage_format: cobertura + path: cobertura.xml + coverage: '/^\d+.\d+% coverage/' \ No newline at end of file