From 380e20213ee9354ee3f916f59ef62b9e3f5d8132 Mon Sep 17 00:00:00 2001 From: Sergey Bronnikov Date: Fri, 27 Nov 2026 11:06:48 +0300 Subject: [PATCH] ci: add coverage workflow with Coveralls Measure workspace test coverage with cargo-llvm-cov and upload the resulting LCOV report to Coveralls. - Run on push to main and pull_request targeting main, plus workflow_dispatch. - Use --workspace --all-features to match the test suite in test.yml. - Install llvm-tools-preview and cargo-llvm-cov via taiki-e/install-action. - Cache cargo/target with Swatinem/rust-cache (shared-key: coverage). - Authenticate to Coveralls with GITHUB_TOKEN; the job fails if upload fails. --- .github/workflows/coverage.yml | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..0a00b45a7 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,63 @@ +name: Coverage + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + branches: + - main + workflow_dispatch: + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +# Cancel stale PR runs, but let main pushes finish. +concurrency: + group: coverage-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + coverage: + name: Coverage (llvm-cov -> Coveralls) + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + + - name: Cache cargo/target + uses: Swatinem/rust-cache@v2 + with: + shared-key: coverage + + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@v2 + with: + tool: cargo-llvm-cov + + - name: Generate LCOV + run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info + + - name: Upload to Coveralls + # Secrets are not exposed to PRs from forks, so skip the upload there + # instead of failing the job. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false + uses: coverallsapp/github-action@v2 + with: + file: lcov.info + format: lcov + github-token: ${{ secrets.GITHUB_TOKEN }}