From 0f473b58504cf85ccaafe5bb414a37983d957a56 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 14 Mar 2024 10:37:10 +0200 Subject: [PATCH] ci: Run `cargo mutants` on changed code (#1742) * ci: Run `cargo mutants` on changed code See https://mutants.rs/, esp. https://mutants.rs/pr-diff.html * Fixes * Fix trigger --- .github/actions/rust/action.yml | 2 +- .github/workflows/mutants.yml | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mutants.yml diff --git a/.github/actions/rust/action.yml b/.github/actions/rust/action.yml index dce4923678..bfb09d332d 100644 --- a/.github/actions/rust/action.yml +++ b/.github/actions/rust/action.yml @@ -30,7 +30,7 @@ runs: - name: Install Rust tools shell: bash - run: cargo +${{ inputs.version }} binstall --no-confirm cargo-llvm-cov cargo-nextest flamegraph cargo-hack + run: cargo +${{ inputs.version }} binstall --no-confirm cargo-llvm-cov cargo-nextest flamegraph cargo-hack cargo-mutants # sccache slows CI down, so we leave it disabled. # Leaving the steps below commented out, so we can re-evaluate enabling it later. diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml new file mode 100644 index 0000000000..4e757b267f --- /dev/null +++ b/.github/workflows/mutants.yml @@ -0,0 +1,36 @@ +name: Find mutants +on: + pull_request: + branches: ["main"] + paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"] + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + incremental-mutants: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Relative diff + run: git diff origin/${{ github.base_ref }}.. > pr.diff + + - name: Install Rust + uses: ./.github/actions/rust + with: + version: stable + + - name: Mutants + run: cargo mutants --test-tool=nextest --no-shuffle -j 2 -vV --in-diff pr.diff + + - name: Archive mutants.out + uses: actions/upload-artifact@v4 + if: always() + with: + name: mutants-incremental.out + path: mutants.out