Add weekly cargo-mutants workflow

This commit is contained in:
Shing Him Ng 2024-12-22 15:48:30 -06:00
parent b94f26848e
commit 462c7a1130
3 changed files with 69 additions and 0 deletions

27
.cargo/mutants.toml Normal file
View File

@ -0,0 +1,27 @@
additional_cargo_args = ["--all-features"]
examine_globs = ["units/src/**/*.rs"]
exclude_globs = [
"units/src/amount/verification.rs" # kani tests
]
exclude_re = [
"impl Debug",
"impl Arbitrary",
"impl Display",
".*Error",
# --------------------------------------------Crate-specific exclusions--------------------------------------------
# Units
# src/amount/mod.rs
"parse_signed_to_satoshi", # Can't kill all mutants since there is no denomination smaller than Satoshi
"fmt_satoshi_in", # Related to formatting/display
"dec_width", # Replacing num /= 10 with num %=10 in a loop causes a timeout due to infinite loop
# src/fee_rate/serde.rs
"as_sat_per_kwu::opt::deserialize::<impl Visitor for VisitOpt>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_sat_per_vb_floor::opt::deserialize::<impl Visitor for VisitOpt>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_sat_per_vb_ceil::opt::deserialize::<impl Visitor for VisitOpt>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
# src/amount/serde.rs
"as_sat::opt::deserialize::<impl Visitor for VisitOptAmt<X>>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_btc::opt::deserialize::<impl Visitor for VisitOptAmt<X>>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_str::opt::deserialize::<impl Visitor for VisitOptAmt<X>>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
# src/locktime/relative.rs
"Time::to_consensus_u32" # It will replace | with ^, which will return the same value since the XOR is always taken against the u16 and an all-zero bitmask
]

View File

@ -0,0 +1,41 @@
name: Weekly cargo-mutants
on:
schedule:
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
workflow_dispatch: # allows manual triggering
jobs:
cargo-mutants:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: cargo-mutants
- run: cargo mutants --in-place --no-shuffle
- uses: actions/upload-artifact@v4
if: always()
with:
name: mutants.out
path: mutants.out
- name: Check for new mutants
if: always()
run: |
if [ -s mutants.out/missed.txt ]; then
echo "New missed mutants found"
gh issue create \
--title "New Mutants Found" \
--body "$(cat <<EOF
Displaying up to the first 10 mutants:
$(head -n 10 mutants.out/missed.txt)
For the complete list, please check the [mutants.out artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
EOF
)"
echo "create_issue=true" >> $GITHUB_ENV
else
echo "No new mutants found"
echo "create_issue=false" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ hashes/target
# Test artifacts
bitcoin/dep_test
mutants.out*
# Fuzz artifacts
hfuzz_target