Skip to content

Commit 571cc60

Browse files
committed
Merge pull request #17 from 'ci/add-mutation-testing-job'
ci: add incremental-mutants job to execute cargo mutants against PR diff
2 parents 0992d0b + 0279861 commit 571cc60

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

.cargo/mutants.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
profile = "mutants"

.github/workflows/mutations.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test mutants
2+
3+
permissions:
4+
contents: read
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
pull_request:
14+
15+
jobs:
16+
incremental-mutants:
17+
name: Incremental mutants test
18+
runs-on: ubuntu-latest
19+
if: github.event_name == 'pull_request'
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Relative diff
25+
run: |
26+
git branch -av
27+
git diff origin/${{ github.base_ref }}.. | tee git.diff
28+
- name: Rust Cache
29+
uses: Swatinem/rust-cache@v2
30+
- name: Install Rust toolchain
31+
uses: taiki-e/install-action@v2
32+
with:
33+
tool: cargo-mutants
34+
- name: Mutants
35+
run: |
36+
cargo mutants --no-shuffle -vV --exclude "example-crates/**" --in-diff git.diff -- --all-targets
37+
- name: Archive mutants.out
38+
uses: actions/upload-artifact@v4
39+
if: always()
40+
with:
41+
name: mutants-incremental.out
42+
path: mutants.out

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ Cargo.lock
1717

1818
# Ignore media (should go into media branch)
1919
*.gif
20+
21+
# Ignore cargo-mutants generated output
22+
/mutants.out*

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ print_stderr = "deny"
1414

1515
[workspace.lints.rust]
1616
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
17+
18+
[profile.mutants]
19+
inherits = "test"
20+
debug = "none"
21+
opt-level = 3

0 commit comments

Comments
 (0)