Skip to content

ci: add cargo mutants weekly job #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/cron_cargo_mutants.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Weekly cargo-mutants

permissions: {}

on:
schedule:
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
workflow_dispatch: # allows manual triggering

jobs:
cargo-mutants:
name: Cargo Mutants
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: taiki-e/install-action@2383334cf567d78771fc7d89b6b3802ef1412cf6
with:
tool: cargo-mutants
- run: cargo mutants --in-place --no-shuffle
- uses: actions/upload-artifact@v4
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"
MUTANTS_VERSION=$(cargo mutants --version)
gh issue create \
--title "cargo-mutants: new mutants found" \
--body "$(cat <<EOF
Displaying up to the first 10 mutants:
\`\`\`
$(head -n 10 mutants.out/missed.txt)
\`\`\`
Running cargo mutants version: ${MUTANTS_VERSION}
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 }}
7 changes: 6 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ alias c := check
alias f := fmt
alias t := test
alias p := pre-push
alias m := mutants

# Build the project
build:
Expand All @@ -26,4 +27,8 @@ test:
cargo test --workspace --exclude 'example_*' --all-features

# Run pre-push suite: format, check, and test
pre-push: fmt check test
pre-push: fmt check test

# Run `cargo-mutants` for mutation testing
mutants:
cargo mutants --in-place --no-shuffle
Loading