From 1921c6c8c1be00a641952b2364a9b843340eec19 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:28:39 +0100 Subject: [PATCH 1/3] Replace Tarpaulin by cargo-llvm-cov for coverage --- .github/workflows/codecov.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index c9c31b511..20070dbf3 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -22,16 +22,16 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Rust Nightly + - name: Setup Rust shell: bash run: > - rustup update nightly && - rustup default nightly && - echo RUST_VERSION=$(rustc --version | awk -F '[( ]' '{print $4}') >> $GITHUB_ENV + rustup update stable && + rustup default stable && + echo RUST_VERSION=$(rustc --version | cut -d' ' -f2) >> $GITHUB_ENV - name: Install Binstall uses: cargo-bins/cargo-binstall@main - - name: Install Tarpaulin - run: cargo binstall cargo-tarpaulin + - name: Install cargo-llvm-cov + run: cargo binstall cargo-llvm-cov - name: Install Nextest run: cargo binstall cargo-nextest - name: Cargo cache @@ -46,20 +46,23 @@ jobs: ./backend/target/ key: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}- - - name: Run tests - run: cargo nextest run --profile ci + - name: Run tests with coverage + run: cargo llvm-cov nextest --profile ci - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} - files: ./target/nextest/ci/junit.xml - - name: Generate code coverage - run: cargo --verbose --locked tarpaulin --timeout 120 --out xml + files: backend/target/nextest/ci/junit.xml + fail_ci_if_error: true + - name: Create code coverage report + run: cargo llvm-cov report --cobertura --output-path ./target/llvm-cov-target/codecov.json - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} + files: backend/target/llvm-cov/codecov.json + fail_ci_if_error: true frontend: name: Frontend From 50008f1cf03c1b86cd61057311cd6fd79667f817 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:53:11 +0100 Subject: [PATCH 2/3] Configure branch coverage --- .github/workflows/codecov.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 20070dbf3..bf214e2da 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -22,12 +22,13 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Rust + # Branch coverage requires Rust nightly: https://github.com/taiki-e/cargo-llvm-cov/issues/8 + - name: Setup Rust Nightly shell: bash run: > - rustup update stable && - rustup default stable && - echo RUST_VERSION=$(rustc --version | cut -d' ' -f2) >> $GITHUB_ENV + rustup update nightly && + rustup default nightly && + echo RUST_VERSION=$(rustc --version | awk -F '[( ]' '{print $4}') >> $GITHUB_ENV - name: Install Binstall uses: cargo-bins/cargo-binstall@main - name: Install cargo-llvm-cov @@ -47,7 +48,7 @@ jobs: key: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}- - name: Run tests with coverage - run: cargo llvm-cov nextest --profile ci + run: cargo llvm-cov --branch nextest --profile ci - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/test-results-action@v1 From 6845cfdc72cf571af7e67f2a0bda19a17387f3e8 Mon Sep 17 00:00:00 2001 From: Mark Janssen <20283+praseodym@users.noreply.github.com> Date: Thu, 30 Jan 2025 13:04:58 +0100 Subject: [PATCH 3/3] Specify exact file for Codecov uploads Also disable file search and fail on upload error. --- .github/workflows/codecov.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index bf214e2da..507d4ecae 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -55,6 +55,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: backend/target/nextest/ci/junit.xml + disable_search: true fail_ci_if_error: true - name: Create code coverage report run: cargo llvm-cov report --cobertura --output-path ./target/llvm-cov-target/codecov.json @@ -62,7 +63,8 @@ jobs: uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} - files: backend/target/llvm-cov/codecov.json + files: backend/target/llvm-cov-target/codecov.json + disable_search: true fail_ci_if_error: true frontend: @@ -88,12 +90,18 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - name: Run tests with coverage run: npx vitest run --coverage --reporter=junit --outputFile=test-report.junit.xml - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} + files: frontend/test-report.junit.xml + disable_search: true + fail_ci_if_error: true + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: frontend/coverage/coverage-final.json + disable_search: true + fail_ci_if_error: true