From 03188bfd5b971ce604f9f2cf670120cd497074f1 Mon Sep 17 00:00:00 2001 From: constantoine Date: Fri, 26 Aug 2022 10:28:45 +0200 Subject: [PATCH 1/3] Changed coverage tools to better represent coverage Signed-off-by: constantoine --- .github/workflows/rust.yml | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a99dc3f..1b487d3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,27 +21,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Install lcov_cobertura + run: curl -O https://raw.githubusercontent.com/eriwen/lcov-to-cobertura-xml/master/lcov_cobertura/lcov_cobertura.py && chmod +x lcov_cobertura.py + - name: Install llvm-tools-preview + run: rustup component add llvm-tools-preview + - name: Install grcov + run: cargo install grcov + - name: Create coverage output dir + run: mkdir -p target/coverage - name: All features - run: cargo test --all-features + run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --all-features - name: No feature - run: cargo test + run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test - name: otpauth feature - run: cargo test --features=otpauth + run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=otpauth - name: gen_secret feature - run: cargo test --features=gen_secret + run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=gen_secret - name: otpauth+gensecret feature - run: cargo test --features=gen_secret,otpauth - - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run cargo-tarpaulin - uses: actions-rs/tarpaulin@v0.1 - with: - version: '0.20.1' - args: --all-features --out=Xml - + run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=gen_secret,otpauth + - name: Create coverage file + run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov + - name: Convert coverage file to cobertura + run: python3 lcov_cobertura.py target/coverage/tests.lcov -o cobertura.xml - name: Upload to codecov.io uses: codecov/codecov-action@v2 with: From 28d72bc3684cf32fed1fddf9b646a7fa88e4c30c Mon Sep 17 00:00:00 2001 From: constantoine Date: Fri, 26 Aug 2022 10:41:36 +0200 Subject: [PATCH 2/3] Download grcov instead of recompiling Signed-off-by: constantoine --- .github/workflows/rust.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1b487d3..4b975c6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,12 +21,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install lcov_cobertura - run: curl -O https://raw.githubusercontent.com/eriwen/lcov-to-cobertura-xml/master/lcov_cobertura/lcov_cobertura.py && chmod +x lcov_cobertura.py - name: Install llvm-tools-preview run: rustup component add llvm-tools-preview - - name: Install grcov - run: cargo install grcov + - name: Download grcov + run: wget https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 + - name: Decompress grcov + run: tar xvf grcov-x86_64-unknown-linux-gnu.tar.bz2 - name: Create coverage output dir run: mkdir -p target/coverage - name: All features @@ -40,9 +40,7 @@ jobs: - name: otpauth+gensecret feature run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=gen_secret,otpauth - name: Create coverage file - run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov - - name: Convert coverage file to cobertura - run: python3 lcov_cobertura.py target/coverage/tests.lcov -o cobertura.xml + run: grcov . --binary-path ./target/debug/deps/ -s . -t cobertura --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/cobertura.xml - name: Upload to codecov.io uses: codecov/codecov-action@v2 with: @@ -52,4 +50,4 @@ jobs: uses: actions/upload-artifact@v1 with: name: code-coverage-report - path: cobertura.xml + path: target/coverage/cobertura.xml From ec0e7f3625d1eb441989be3a73f196fb13a97185 Mon Sep 17 00:00:00 2001 From: constantoine Date: Fri, 26 Aug 2022 10:44:46 +0200 Subject: [PATCH 3/3] Fix rust.yml Signed-off-by: constantoine --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4b975c6..51bdf83 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,7 +40,7 @@ jobs: - name: otpauth+gensecret feature run: CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features=gen_secret,otpauth - name: Create coverage file - run: grcov . --binary-path ./target/debug/deps/ -s . -t cobertura --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/cobertura.xml + run: ./grcov . --binary-path ./target/debug/deps/ -s . -t cobertura --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/cobertura.xml - name: Upload to codecov.io uses: codecov/codecov-action@v2 with: