Skip to content
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

ci(darker): improve comparison refs for focused errors #5311

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

p2edwards
Copy link
Contributor

@p2edwards p2edwards commented Dec 2, 2024

πŸ‘€ Preview steps

  1. πŸ”΄ run darker on a branch with an old base ref.
  2. 🟒 after this fix
  3. 🟒 edit tasks.py to break a flake8 rule

Screenshots from test commits in #5295

  1. πŸ”΄πŸ–ΌοΈ unrelated files linted
  2. πŸŸ’πŸ–ΌοΈ no unrelated files linted
  3. πŸŸ’πŸ–ΌοΈ related file(s) linted

πŸ’­ Notes

Change which commits we compare in darker.yml so that their diffs don't include changes introduced by other branches.

More detailed explanation here

xref internal chat

@p2edwards p2edwards changed the title ci(darker): compare ci(darker): improve comparison refs for focused errors Dec 2, 2024
@p2edwards p2edwards added workflow Related to development process Back end labels Dec 2, 2024
@p2edwards p2edwards marked this pull request as ready for review December 2, 2024 16:42
@p2edwards p2edwards requested review from rgraber and removed request for bufke, jnm, magicznyleszek and noliveleger December 2, 2024 16:42
Base automatically changed from phil/ci-paths-filter to main December 2, 2024 17:31
An error occurred while trying to automatically change base from phil/ci-paths-filter to main December 2, 2024 17:31
@p2edwards p2edwards force-pushed the phil/ci-darker-base branch from f4b1663 to 1a5a78e Compare December 2, 2024 19:47
@rgraber
Copy link
Contributor

rgraber commented Dec 18, 2024

Repro steps:

  1. cut a branch off main (fake-main)
  2. cut a branch off fake-main (fake-innocent)
  3. cut another branch off fake-main (fake-problem)
  4. Commit code to fake-innocent that won't cause a linting error (eg a short comment)
  5. Push the code and open a PR for fake-innocent against fake-main
  6. Commit code to fake-problem that will cause a linting error in a different file than the one changed in fake-innocent. A comment over 88 characters will work
  7. Push the code and open a PR for fake-problem against fake-main
  8. The CI for fake-problem will fail. Merge it to fake-main anyway
  9. Make another change in fake-innocent (do not touch the file changed in fake-problem)
  10. Commit and push the change
  11. πŸ”΄ darker will fail on the PR for fake-innocent based on the problem introduced by fake-problem, even though fake-innocent did not modify those files
  12. check out this branch
  13. repeat steps 1-10, starting with this branch instead of main
  14. 🟒 darker should pass on the "innocent" branch

@rgraber
Copy link
Contributor

rgraber commented Dec 18, 2024

Note: this behavior was slightly different than expected. The old darker action looked at the latest commit to main when the PR was opened, regardless of when the branch was cut. When testing this fix, we expected it to look at the latest commit before the branch was cut. This means darker would only fail if a PR for the "innocent" branch was opened before the "problem" branch was merged.

Thus, to reproduce the bug, make sure you open the "innocent" PR first, then merge the "problem" PR, then re-run CI for the "innocent" PR.

Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

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

2 suggestions

.github/workflows/darker.yml Outdated Show resolved Hide resolved
.github/workflows/darker.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

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

LGTM

@p2edwards p2edwards merged commit b6a2829 into main Dec 18, 2024
4 checks passed
@p2edwards p2edwards deleted the phil/ci-darker-base branch December 18, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Back end workflow Related to development process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants