From b735a80adf84e07026660880d4e8fea69effd5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferry=20J=C3=A9r=C3=A9mie?= Date: Fri, 23 Aug 2024 11:48:59 +0200 Subject: [PATCH] update ci with codecov --- .github/workflows/ci.yml | 109 ++++++--------------------------------- 1 file changed, 16 insertions(+), 93 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb403a1..4a2b4a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,106 +39,29 @@ jobs: command: test args: --verbose ${{ matrix.features }} - test-coverage: - name: Test coverage (gcc-${{ matrix.gcc }}, clang-${{ matrix.clang }}) - runs-on: ubuntu-latest - strategy: - matrix: - include: - - gcc: 10 - clang: 11 - - gcc: 11 - clang: 12 - - gcc: 11 - clang: 13 - env: - CXX: clang++-${{ matrix.clang }} - CLANG_CXX: clang++-${{ matrix.clang }} - GCC_CXX: g++-${{ matrix.gcc }} - GCOV: gcov-${{ matrix.gcc }} - continue-on-error: true - steps: - - name: Prepare C toolchains - run: | - # Add LLVM keys - curl -o- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - - # Add extra APT repos - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' - sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' - sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main' - - # Install toolchains - sudo apt-get update - sudo apt-get install -y clang-${{ matrix.clang }} g++-${{ matrix.gcc }} - - name: Checkout repository - uses: actions/checkout@v3 - - name: Setup Rust - run: | - rustup toolchain add nightly --component llvm-tools-preview - rustup override set nightly - - name: Configure cache - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: test-${{ runner.os }}-cargo-gcc-${{ matrix.gcc }}-clang-${{ matrix.clang }}-${{ hashFiles('**/Cargo.lock') }} - - name: Build - env: - RUSTFLAGS: -Cinstrument-coverage - run: cargo build - - name: Test - env: - LLVM_PROFILE_FILE: grcov-%p-%m.profraw - RUSTFLAGS: -Cinstrument-coverage - run: cargo test - - name: Generate coverage - run: | - ./target/debug/grcov $(find . -name "grcov-*.profraw" -print) \ - --branch \ - --ignore-not-existing \ - --binary-path ./target/debug/ \ - -s . \ - -t lcov \ - --ignore "/*" \ - -o lcov.info - coverage: - name: Coverage runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Install rust - uses: actions-rs/toolchain@v1 + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: - toolchain: stable - profile: minimal - override: true - - - name: Cache - uses: Swatinem/rust-cache@v1 + toolchain: nightly + components: llvm-tools - - name: Install cargo-tarpaulin - uses: actions-rs/cargo@v1 + - name: Install just, cargo-llvm-cov, cargo-nextest + uses: taiki-e/install-action@v2.42.26 with: - command: install - args: cargo-tarpaulin + tool: just,cargo-llvm-cov,cargo-nextest - - name: Run cargo tarpaulin - uses: actions-rs/cargo@v1 - with: - command: tarpaulin - args: -- --test-threads 1 + - name: Generate code coverage + run: just test-coverage-codecov - - name: Publish to Coveralls - uses: coverallsapp/github-action@master + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4.5.0 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + files: codecov.json + fail_ci_if_error: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}