Skip to content

Commit 2421347

Browse files
author
Martin Taillefer
committed
ci: Support incremental and nightly mutation testing
1 parent d4ac21e commit 2421347

2 files changed

Lines changed: 96 additions & 6 deletions

File tree

.github/workflows/main.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: main
2+
23
permissions:
34
contents: read
45
pull-requests: read
@@ -44,7 +45,7 @@ jobs:
4445
# prep
4546
- name: Checkout
4647
uses: actions/checkout@v6.0.0
47-
- name: Start sscache
48+
- name: Start sccache
4849
uses: mozilla-actions/sccache-action@v0.0.9
4950
with:
5051
version: ${{ env.SCCACHE_VERSION }}
@@ -87,7 +88,7 @@ jobs:
8788
~/.cargo/registry/cache/
8889
~/.cargo/git/db/
8990
key: ${{ runner.os }}-cargo-tools-${{ hashFiles('**/Cargo.lock') }}
90-
- name: Start sscache
91+
- name: Start sccache
9192
uses: mozilla-actions/sccache-action@v0.0.9
9293
with:
9394
version: ${{ env.SCCACHE_VERSION }}
@@ -161,7 +162,9 @@ jobs:
161162
# prep
162163
- name: Checkout
163164
uses: actions/checkout@v6.0.0
164-
- name: Start sscache
165+
with:
166+
fetch-depth: 0
167+
- name: Start sccache
165168
uses: mozilla-actions/sccache-action@v0.0.9
166169
with:
167170
version: ${{ env.SCCACHE_VERSION }}
@@ -176,11 +179,13 @@ jobs:
176179
tool: cargo-mutants@${{ env.CARGO_MUTANTS_VERSION }}
177180

178181
# execute
179-
- name: Mutate
182+
- name: Generate PR diff
183+
run: git diff origin/main...HEAD >diff.txt
184+
- name: Mutate Diff
180185
env:
181186
DISABLE_T_REX: 1
182187
timeout-minutes: 45
183-
run: cargo mutants --test-workspace=true --colors=never --jobs=1 --build-timeout=120
188+
run: cargo mutants --test-workspace=true --colors=never --jobs=1 --build-timeout=120 --in-diff diff.txt
184189

185190
coverage:
186191
if: github.event_name == 'pull_request'
@@ -196,7 +201,7 @@ jobs:
196201
# prep
197202
- name: Checkout
198203
uses: actions/checkout@v6.0.0
199-
- name: Start sscache
204+
- name: Start sccache
200205
uses: mozilla-actions/sccache-action@v0.0.9
201206
with:
202207
version: ${{ env.SCCACHE_VERSION }}

.github/workflows/nightly.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: nightly
2+
3+
permissions:
4+
contents: read
5+
pull-requests: read
6+
security-events: write
7+
8+
on:
9+
schedule:
10+
- cron: '0 0 * * *'
11+
workflow_dispatch:
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
# Rust toolchain versions
17+
RUST_LATEST: "1.91" # used for mutation testing
18+
19+
# Tool versions
20+
CARGO_MUTANTS_VERSION: "25.3.1"
21+
SCCACHE_VERSION: "v0.12.0"
22+
23+
jobs:
24+
nightly-gatekeeper:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
should_skip: ${{ steps.check.outputs.should_skip }}
28+
steps:
29+
- uses: actions/checkout@v6.0.0
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Check for changes in last 24 hours
34+
id: check
35+
run: |
36+
# Check logs for commits in the last 24 hours on the current branch
37+
if [[ -z $(git log --since="24 hours ago" --pretty=format:"%H") ]]; then
38+
echo "No commits in the last 24 hours. Skipping..."
39+
echo "should_skip=true" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "New commits found. Proceeding..."
42+
echo "should_skip=false" >> "$GITHUB_OUTPUT"
43+
fi
44+
45+
mutation-testing:
46+
needs: nightly-gatekeeper
47+
if: ${{ needs.nightly-gatekeeper.outputs.should_skip != 'true' }}
48+
runs-on: ubuntu-latest
49+
env:
50+
SCCACHE_GHA_ENABLED: "true"
51+
RUSTC_WRAPPER: "sccache"
52+
steps:
53+
# prep
54+
- name: Checkout
55+
uses: actions/checkout@v6.0.0
56+
- name: Start sccache
57+
uses: mozilla-actions/sccache-action@v0.0.9
58+
with:
59+
version: ${{ env.SCCACHE_VERSION }}
60+
- name: Install Rust
61+
uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
62+
with:
63+
toolchain: ${{ env.RUST_LATEST }}
64+
components: clippy, rustfmt
65+
- name: Install Cargo Tools
66+
uses: taiki-e/install-action@v2.62.53
67+
with:
68+
tool: cargo-mutants@${{ env.CARGO_MUTANTS_VERSION }}
69+
70+
# execute
71+
- name: Mutate All
72+
env:
73+
DISABLE_T_REX: 1
74+
timeout-minutes: 90
75+
run: cargo mutants --test-workspace=true --colors=never --jobs=1 --build-timeout=120
76+
77+
- name: Create Issue on Failure
78+
if: failure()
79+
env:
80+
GH_TOKEN: ${{ github.token }}
81+
run: |
82+
gh issue create \
83+
--title "🚨 Nightly Build Failed: $(date +'%Y-%m-%d')" \
84+
--body "The nightly scheduled build failed. Please check the logs here: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
85+
--label "bug"

0 commit comments

Comments
 (0)