---
name: Mutants
"on":
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: mutants-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
CARGO_PROFILE_TEST_DEBUG: "0"
NEXTEST_PROFILE: mutants
RUSTC_WRAPPER: sccache
jobs:
mutants:
name: Mutation testing ${{ strategy.job-index }}
runs-on: ubuntu-latest
timeout-minutes: 330
if: >-
github.event_name == 'push' ||
(github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.user.login != 'dependabot[bot]')
strategy:
fail-fast: false
matrix:
shard: ${{ fromJSON(github.event_name == 'pull_request' && '[0,1,2,3,4,5,6,7]' || '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]') }}
steps:
- uses: actions/checkout@v4
timeout-minutes: 3
with:
fetch-depth: 2
- name: Cache cargo downloads
uses: actions/cache@v6
timeout-minutes: 3
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: dl-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
dl-${{ runner.os }}-
- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 with:
toolchain: stable
timeout-minutes: 5
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad timeout-minutes: 5
- name: Install cargo-mutants and cargo-nextest
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 timeout-minutes: 5
with:
tool: cargo-mutants@27.1.0,cargo-nextest
- name: Diff the pull request
if: github.event_name == 'pull_request'
run: git diff HEAD^1 HEAD > git.diff
- name: Run mutants
timeout-minutes: 300
run: >-
cargo mutants --workspace --jobs 2
--shard ${{ strategy.job-index }}/${{ strategy.job-total }}
${{ github.event_name == 'pull_request' && '--in-diff git.diff' || '' }}
- name: Upload mutation outcome
if: always()
uses: actions/upload-artifact@v4
timeout-minutes: 3
with:
name: mutants-shard-${{ strategy.job-index }}
path: mutants.out