Skip to content

Replaced mutagen with cargo-mutants #241

Open
HrushikeshAnandSarangi wants to merge 1 commit intorust-bitcoin:masterfrom
HrushikeshAnandSarangi:master
Open

Replaced mutagen with cargo-mutants #241
HrushikeshAnandSarangi wants to merge 1 commit intorust-bitcoin:masterfrom
HrushikeshAnandSarangi:master

Conversation

@HrushikeshAnandSarangi
Copy link

Replaced mutagen with cargo-mutants #238
Overview:

  • removed all dependencies of mutagen.
  • Integrated cargo mutants and a workflow for raising issues weekly for top 10 mutations found.
    Please let me know if any additional changes are required.

@apoelstra
Copy link
Member

In 54ab789:

I'd prefer you just have empty arrays in your mutants.toml rather than having stuff from rust-bitcoin that's commented out. (Though I could go either way; it is kinda nice to have examples.)

In 7e37281

This commit has only formatting in it and should be removed or squashed.

@apoelstra
Copy link
Member

Also in 54ab789:

You updated Cargo.toml without updating the lockfile.

@HrushikeshAnandSarangi
Copy link
Author

Please review this

@tcharding
Copy link
Member

Thanks for the contribution. To help me review can you explain how you came up with the GitHub action? I assume you copied it from rust-bitcoin, if this is true knowing this would help me.

FTR to ack this I need to know if there is output in this command and what it means. If you explain that it would help me.

diff .github/workflows/cron-weekly-cargo-mutants.yml ../rust-bitcoin/.github/workflows/cron-weekly-cargo-mutants.yml

@HrushikeshAnandSarangi
Copy link
Author

Yes, I based this workflow from rust-bitcoin. Since it was already in practice. The difference between the two scripts would be

  • name: Generate Cargo.lock
    run: cargo generate-lockfile

Which regenerates the lockfile before running cargo mutants.

diff .github/workflows/cron-weekly-cargo-mutants.yml ../rust-bitcoin/.github/workflows/cron-weekly-cargo-mutants.yml:

diff ./cron-weekly-cargo-mutants.yml ../../../../rust-bitcoin/.github/workflows/cron-weekly-cargo-mutants.yml
1,51c1,49
< name: Weekly cargo-mutants
< on:
< schedule:
< - cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
< workflow_dispatch: # allows manual triggering
< permissions: {}
< jobs:
< cargo-mutants:
< runs-on: ubuntu-24.04
< permissions:
< contents: read
< issues: write
< steps:
< - uses: actions/checkout@08c6903 # v5.0.0
< with:
< persist-credentials: false
< - uses: taiki-e/install-action@81ee1d4 # v2.62.45
< with:
< tool: cargo-mutants
< - name: Generate Cargo.lock
< run: cargo generate-lockfile
< - run: cargo mutants --in-place --no-shuffle
< - uses: actions/upload-artifact@330a01c # v5.0.0
< 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"
< MUTANTS_VERSION=$(cargo mutants --version)
< gh issue create
< --title "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 }}
\ No newline at end of file


name: Weekly cargo-mutants
on:
schedule:
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
workflow_dispatch: # allows manual triggering
permissions: {}
jobs:
cargo-mutants:
runs-on: ubuntu-24.04
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@08c6903 # v5.0.0
with:
persist-credentials: false
- uses: taiki-e/install-action@81ee1d4 # v2.62.45
with:
tool: cargo-mutants
- run: cargo mutants --in-place --no-shuffle
- uses: actions/upload-artifact@330a01c # v5.0.0
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"
MUTANTS_VERSION=$(cargo mutants --version)
gh issue create
--title "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 }}

Please let me know if any changes are required.

@apoelstra
Copy link
Member

You updated Cargo.toml without updating the lockfile.

Oops, I was wrong about this. We don't have a committed lockfile here (yet). I need to mess around with my local lockfiles :/.

@tcharding
Copy link
Member

Great, thanks. We can get rid of mutate from the manifest too in this line:

unexpected_cfgs = { level = "deny", check-cfg = [ 'cfg(bench)', 'cfg(kani)', 'cfg(mutate)' ] }

@tcharding
Copy link
Member

nit: If you add a newline at the end of cron-weekly-cargo-mutants.yml then there will be no noise whatsoever if the diff output for me locally.

@HrushikeshAnandSarangi
Copy link
Author

Thanks for the review

Removed the cfg(mutate) and added a trailing newline at the EOF

Let me know if any other changes are required

@tcharding
Copy link
Member

Please squash into a single commit.

@HrushikeshAnandSarangi
Copy link
Author

Done

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 43b48a5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants