fix(ci): measure coverage over all test targets, not just --lib #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: "0" | |
| RUSTFLAGS: -Dwarnings | |
| jobs: | |
| test: | |
| name: Test & lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable | |
| with: | |
| components: rustfmt, clippy | |
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | |
| - run: cargo fmt --check | |
| - run: cargo clippy --workspace --all-targets | |
| - run: cargo test --workspace | |
| deny: | |
| name: cargo-deny (bans/licenses/sources) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 | |
| with: | |
| command: check bans licenses sources | |
| advisories: | |
| name: cargo-deny (advisories) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 | |
| with: | |
| command: check advisories | |
| vet: | |
| name: Cargo Vet (supply-chain) | |
| runs-on: ubuntu-latest | |
| # Complements `deny` (known-bad advisories/licenses) with the supply-chain- | |
| # injection layer: every dependency version must be human-source-reviewed or | |
| # covered by an imported aggregate audit set (Google/Mozilla/Bytecode-Alliance/ | |
| # Embark). Config in supply-chain/{config,audits,imports}.toml. | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable | |
| - name: Install cargo-vet | |
| uses: taiki-e/install-action@59012be0884e296ca2da49b530610e72c49039ad # v2.81.6 | |
| with: | |
| tool: cargo-vet | |
| - name: Fetch dependencies | |
| run: cargo fetch | |
| - name: Check supply chain | |
| run: cargo vet --locked | |
| coverage: | |
| name: Coverage (100% lib) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable | |
| with: | |
| components: llvm-tools-preview | |
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | |
| - uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: Gate on 100% line coverage (excluding // cov:unreachable) | |
| run: | | |
| cargo llvm-cov --workspace --lcov --output-path lcov.info --ignore-filename-regex '(^|/)src/(main\.rs|bin/)' | |
| # Walk the lcov: track the current source file (SF:) and fail on any | |
| # DA:<line>,0 whose source line lacks a `// cov:unreachable` marker. | |
| fail=0; file="" | |
| while IFS= read -r entry; do | |
| case "$entry" in | |
| SF:*) file="${entry#SF:}" ;; | |
| DA:*,0) | |
| line="${entry#DA:}"; line="${line%,0}" | |
| src=$(sed -n "${line}p" "$file") | |
| case "$src" in | |
| *cov:unreachable*) ;; | |
| *) echo "Uncovered (no cov:unreachable): ${file}:${line}: ${src}"; fail=1 ;; | |
| esac | |
| ;; | |
| esac | |
| done < lcov.info | |
| exit $fail | |
| msrv: | |
| name: MSRV (1.85) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@1.85 | |
| - uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # v2.7.8 | |
| - run: cargo build --workspace |