Skip to content

Conversation

@benalleng
Copy link
Collaborator

@benalleng benalleng commented Jul 30, 2025

This is a PR to test adding diff based mutations for future changes in the source code moving forward.

Note: this does not add mutations if the mutants.toml or other non .rs code is changed

The last 2 commits are simply testing commits to show diff mutations are caught or missed or the diff is ignored alltogether.

  • the ohttp commit shows that while an .rs file was changed since it is in the test cfg it is ultimately ignored
  • my mock commit creates some code with intentionally missed mutants

@benalleng benalleng marked this pull request as draft July 30, 2025 15:22
@coveralls
Copy link
Collaborator

coveralls commented Jul 30, 2025

Pull Request Test Coverage Report for Build 16662599796

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 86.023%

Totals Coverage Status
Change from base Build 16627870999: 0.02%
Covered Lines: 8007
Relevant Lines: 9308

💛 - Coveralls

@benalleng benalleng force-pushed the diff-mutants branch 3 times, most recently from 1286515 to 3642002 Compare July 30, 2025 15:47
@benalleng
Copy link
Collaborator Author

benalleng commented Jul 30, 2025

I allowed this to create comments but not sure if we want that long term as we can just look into the failing action check.
benalleng#5 (comment)
I removed it already

@benalleng benalleng force-pushed the diff-mutants branch 4 times, most recently from 0ffb33b to 283f6cb Compare July 30, 2025 16:42
@benalleng benalleng changed the title Diff mutants Diff based cargo-mutants Jul 30, 2025
@benalleng benalleng force-pushed the diff-mutants branch 5 times, most recently from 3f97303 to 438cec4 Compare July 30, 2025 22:27
@benalleng benalleng requested a review from DanGould July 31, 2025 15:10
@benalleng
Copy link
Collaborator Author

@DanGould certainly this can vary the CI test time based on how complex the diff is but it does seem on par with our integration tests for most changes

@benalleng benalleng marked this pull request as ready for review July 31, 2025 15:11
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

Concept ACK - 3min 30s for an isolated change sounds reasonable. I guess the worst-case would be around 40min (based on the weekly job time) if every possible mutant was touched?

Comment on lines 34 to 36
- uses: dtolnay/rust-toolchain@master
with:
toolchain: beta
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use the stable toolchain to keep cache usage efficient:

Suggested change
- uses: dtolnay/rust-toolchain@master
with:
toolchain: beta
- uses: dtolnay/rust-toolchain@stable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did some additional cleanup to better match this workflow with the rest of our actions

Copy link
Contributor

Choose a reason for hiding this comment

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

How does this keep it efficient? Is it because we have a cache from using the stable toolchain already elsewhere?

Copy link
Collaborator Author

@benalleng benalleng Aug 1, 2025

Choose a reason for hiding this comment

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

Ok so It is intended to use the cache from the stable toolchain but looking closer at it I am a bit confused as to whether we are using it correctly, making a more pointed issue in #912

The cache here is specific to the Diff Mutants job so we should be able to save some time for the stable toolchain with subsequent runs of this job, stable is chosen so the hash doesn't change often

Copy link
Collaborator

Choose a reason for hiding this comment

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

See my reply here: #912 (comment)

save-if: false

- name: Run cargo-mutants on diff
run: >
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we update the output of this command to only print missed mutants?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer keeping the workflows separated by function rather than by tool, i.e. leave this file as-is (or rename to just cron-weekly.yml) and put the diff mutants job in rust.yml.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I like moving the diff mutant into the rust.yml it feels more correct as we use that for PR CI

This workflow is a planned replacement for the current weekly mutants
that run every sunday on the rust-payjoin codebase. This will hopefully
allow more continuous coverage without a weekly delay.
I added one additional test for mutation coverage on ohttp logic with my
plan to create more tests for full test coverage to follow.
@spacebear21
Copy link
Collaborator

Looks good to me, pending removal of the DO NOT MERGE commit.

@DanGould
Copy link
Contributor

DanGould commented Aug 1, 2025

I was confused at first that this might check the diff in mutants.out since we don't commit or cache a mutants.out for each commit on master after some reading, I realize that cargo mutants --in-diff actually checks for mutants in that actual diff and that this will work. neat! Seems very unlikely to change everything all at once except perhaps in some file moves or following formatting changes.

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

ACK aeba995

@spacebear21 spacebear21 merged commit a5d82d1 into payjoin:master Aug 1, 2025
10 checks passed
benalleng added a commit to benalleng/rust-payjoin that referenced this pull request Aug 3, 2025
There was a rebasing mistake on a previous commit as I created some
exclusions but their name was changed before payjoin#910 was merged and
they were not caught.
@benalleng benalleng mentioned this pull request Aug 3, 2025
benalleng added a commit to benalleng/rust-payjoin that referenced this pull request Aug 3, 2025
There was a rebasing mistake on a previous commit as I created some
exclusions but their name was changed before payjoin#910 was merged and
they were not caught.

There is one exclusion that is simply renamed but another I decided to
change the logic such that the exclusions are no longer possible.
spacebear21 added a commit that referenced this pull request Aug 4, 2025
Closes #917

There were some stale exclusions before #910 was merged, hopefully that
PR minimizes as many PRs like this one as possible.

I simply renamed the exclusion for one but decided to try and change the
logic to try and prevent a mutant in another
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.

4 participants