Skip to content

Commit 3311a09

Browse files
authored
Introduce cargo mutants cron job (payjoin#573)
Relates to payjoin#539 This is our first step at cargo mutants in our ci! At the moment all cargo mutant exploration I have been doing locally but with over 250 missed mutants remaining and possibly growing as new code is introduced I think it is time to implement a weekly cron job to track these mutants. This heavily copies the rust-bitcoin implementation of their mutants workflow with tweaks for our codebase and mutants coverage progress. currently set to happen weekly Sun 00:00
2 parents d510ace + f8cb70d commit 3311a09

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

.cargo/mutants.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
additional_cargo_args = ["--all-features"]
2+
examine_globs = ["payjoin/src/uri/*.rs"]
3+
exclude_globs = []
4+
exclude_re = [
5+
"impl Debug",
6+
"impl Display",
7+
"deserialize",
8+
"Iterator",
9+
".*Error",
10+
11+
# ---------------------Crate-specific exculsions---------------------
12+
# Receive
13+
# src/receive/v1/mod.rs
14+
"interleave_shuffle", # Replacing index += 1 with index *= 1 in a loop causes a timeout due to an infinite loop
15+
]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Weekly cargo-mutants
2+
on:
3+
schedule:
4+
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
5+
workflow_dispatch: # allows manual triggering
6+
jobs:
7+
cargo-mutants:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: taiki-e/install-action@v2
12+
with:
13+
tool: cargo-mutants
14+
- run: cargo mutants --in-place --no-shuffle
15+
- uses: actions/upload-artifact@v4
16+
if: always()
17+
with:
18+
name: mutants.out
19+
path: mutants.out
20+
- name: Check for new mutants
21+
if: always()
22+
run: |
23+
if [ -s mutants.out/missed.txt ]; then
24+
echo "New missed mutants found"
25+
gh issue create \
26+
--title "New Mutants Found" \
27+
--body "$(cat <<EOF
28+
Displaying up to the first 15 missed mutants:
29+
$(head -n 15 mutants.out/missed.txt)
30+
For the complete list, please check the [mutants.out artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
31+
EOF
32+
)"
33+
echo "create_issue=true" >> $GITHUB_ENV
34+
else
35+
echo "No new mutants found"
36+
echo "create_issue=false" >> $GITHUB_ENV
37+
fi
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ target
44
*payjoin.sled
55
Cargo.lock
66
.vscode
7+
mutants.out

0 commit comments

Comments
 (0)