|
| 1 | +# cargo-mutants per-PR mutation testing — Linux-only, observability-only. |
| 2 | +# See spec: docs/superpowers/specs/2026-04-24-cargo-mutants-design.md |
| 3 | +# |
| 4 | +# WHY a separate workflow (not added to ci.yml's matrix): mutation |
| 5 | +# testing is CPU-heavy + slow (minutes per file); decoupling lets it |
| 6 | +# fail-or-skip independently of the main `just ci` matrix. PR contributors |
| 7 | +# see two checks instead of one. Failure of mutants.yml does NOT block |
| 8 | +# merge during slice 1 (continue-on-error swallows non-zero exit). |
| 9 | + |
| 10 | +name: mutants |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +env: |
| 18 | + CARGO_TERM_COLOR: always |
| 19 | + |
| 20 | +jobs: |
| 21 | + mutants: |
| 22 | + name: cargo mutants --in-diff |
| 23 | + runs-on: ubuntu-latest |
| 24 | + if: github.event_name == 'pull_request' |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + # WHY fetch-depth: 0 — `git diff origin/<base>..` requires the |
| 29 | + # base branch in local history; depth 0 fetches the full graph. |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - uses: dtolnay/rust-toolchain@stable |
| 33 | + - uses: Swatinem/rust-cache@v2 |
| 34 | + |
| 35 | + # WHY taiki-e/install-action (NOT cargo-binstall): this workflow |
| 36 | + # runs on ubuntu-latest only; the BASH_FUNC_* leak that broke |
| 37 | + # taiki-e/install-action on windows-latest (GH #137) does NOT |
| 38 | + # affect Linux. Multi-tool comma syntax fetches both binaries in |
| 39 | + # one step. |
| 40 | + - uses: taiki-e/install-action@v2 |
| 41 | + with: |
| 42 | + tool: cargo-mutants,cargo-nextest |
| 43 | + |
| 44 | + # WHY Tauri Linux deps even though crates/desktop is excluded from |
| 45 | + # mutation: `cargo metadata` (which cargo-mutants invokes |
| 46 | + # internally) resolves the WHOLE workspace including |
| 47 | + # perima-desktop's transitive deps. Without GTK headers, metadata |
| 48 | + # resolution fails before any mutation happens. |
| 49 | + - name: Install Tauri Linux deps |
| 50 | + run: | |
| 51 | + sudo apt-get update -q |
| 52 | + sudo apt-get install -yq \ |
| 53 | + libgtk-3-dev \ |
| 54 | + libwebkit2gtk-4.1-dev \ |
| 55 | + libayatana-appindicator3-dev \ |
| 56 | + librsvg2-dev \ |
| 57 | + patchelf |
| 58 | +
|
| 59 | + # WHY `| tee git.diff` (vs `> git.diff`): tee echoes the diff into |
| 60 | + # the CI log so reviewers can see what cargo-mutants will operate |
| 61 | + # on without downloading the artifact. Matches the canonical |
| 62 | + # mutants.rs/in-diff example. |
| 63 | + - name: Compute diff against base branch |
| 64 | + run: git diff origin/${{ github.base_ref }}.. | tee git.diff |
| 65 | + |
| 66 | + # WHY continue-on-error: per spec D-4, this slice is observability- |
| 67 | + # only. cargo-mutants exits 2 when mutants survive, 3 on timeout, |
| 68 | + # 4 on baseline failure. Without continue-on-error the very first |
| 69 | + # PR with a survivor blocks the workflow + defeats the |
| 70 | + # observability-first calibration goal. Precedent: kani.yml uses |
| 71 | + # the same pattern. Drop this in a future slice once the survivor |
| 72 | + # baseline is stable. |
| 73 | + - name: cargo mutants --in-diff |
| 74 | + continue-on-error: true |
| 75 | + run: cargo mutants --no-shuffle -vV --in-diff git.diff |
| 76 | + |
| 77 | + - name: Upload mutants.out |
| 78 | + if: always() |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: mutants-out |
| 82 | + path: mutants.out |
0 commit comments