From 462c7a11309fb4828d69ca8df045155413497244 Mon Sep 17 00:00:00 2001 From: Shing Him Ng Date: Sun, 22 Dec 2024 15:48:30 -0600 Subject: [PATCH] Add weekly cargo-mutants workflow --- .cargo/mutants.toml | 27 ++++++++++++ .../workflows/cron-weekly-cargo-mutants.yml | 41 +++++++++++++++++++ .gitignore | 1 + 3 files changed, 69 insertions(+) create mode 100644 .cargo/mutants.toml create mode 100644 .github/workflows/cron-weekly-cargo-mutants.yml diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml new file mode 100644 index 000000000..b6ed18c55 --- /dev/null +++ b/.cargo/mutants.toml @@ -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::.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) + "as_sat_per_vb_floor::opt::deserialize::.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) + "as_sat_per_vb_ceil::opt::deserialize::.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) + # src/amount/serde.rs + "as_sat::opt::deserialize::>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) + "as_btc::opt::deserialize::>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) + "as_str::opt::deserialize::>.*", # 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 +] diff --git a/.github/workflows/cron-weekly-cargo-mutants.yml b/.github/workflows/cron-weekly-cargo-mutants.yml new file mode 100644 index 000000000..30896e402 --- /dev/null +++ b/.github/workflows/cron-weekly-cargo-mutants.yml @@ -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 <> $GITHUB_ENV + else + echo "No new mutants found" + echo "create_issue=false" >> $GITHUB_ENV + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 6055dd863..48c9cedca 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ hashes/target # Test artifacts bitcoin/dep_test +mutants.out* # Fuzz artifacts hfuzz_target