on: pull_request: push: branches: - master name: Codecov jobs: test-and-coverage: runs-on: ubuntu-latest env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C instrument-coverage -C linker=cc" LLVM_PROFILE_FILE: "coverage-%p-%m.profraw" steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Rust uses: actions-rs/toolchain@v1 with: toolchain: stable override: true - name: Install system deps run: sudo apt-get update && sudo apt-get install -y build-essential clang lld - name: Build with coverage run: | export RUSTFLAGS="-C instrument-coverage" cargo clean cargo build cargo test - name: Install grcov run: cargo install grcov - name: Generate coverage report run: | mkdir -p coverage grcov . \ --binary-path ./target/debug/ \ -s . \ -t lcov \ --branch \ --ignore-not-existing \ --ignore '../*' \ --ignore "/*" \ -o coverage/tests.lcov - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} # only needed for private repos files: coverage/tests.lcov fail_ci_if_error: true flags: unittests name: rust-codecov