Skip to content

Mutation testing

Mutation testing #200

Workflow file for this run

name: Mutation testing
on:
pull_request:
branches: [main]
paths:
- "src-tauri/**"
- ".github/workflows/mutants.yml"
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
incremental:
name: cargo-mutants — PR diff
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- uses: taiki-e/install-action@v2
with:
tool: cargo-mutants
- name: Compute PR diff (src-tauri only)
run: |
# Three-dot range so the diff covers only commits introduced by
# this PR, not upstream churn on the base branch since the PR
# diverged. Without it, mutation testing can run on unrelated
# files that landed on `main` after the branch was created.
git diff "origin/${{ github.base_ref }}...HEAD" -- 'src-tauri/**' | tee mutants.diff
- name: cargo mutants --in-diff
# Fails the job if any mutant survives. Exit 0 = all killed/unviable,
# exit 2 = uncaught mutants.
run: |
cargo mutants \
--manifest-path src-tauri/Cargo.toml \
--no-shuffle \
--in-place \
-vV \
--in-diff mutants.diff
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: mutants-incremental
path: src-tauri/mutants.out
full:
name: cargo-mutants — full sharded (shard ${{ matrix.shard }}/4)
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 360
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
key: mutants-shard-${{ matrix.shard }}
- uses: taiki-e/install-action@v2
with:
tool: cargo-mutants
- name: cargo mutants --shard ${{ matrix.shard }}/4
run: |
cargo mutants \
--manifest-path src-tauri/Cargo.toml \
--no-shuffle \
--in-place \
-vV \
--shard ${{ matrix.shard }}/4
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: mutants-full-shard-${{ matrix.shard }}
path: src-tauri/mutants.out