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

Run Nixpkgs diff on nixfmt commits merged into the base branch #241

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

infinisil
Copy link
Member

Previously the Nixpkgs diff script would first format the latest base branch commit, before formatting with each of the PRs commits. This however causes problems if the PR commits are on top of a much older commit that has bugs that aren't in the base branch anymore.

More visually, a PR branch graph looks like this:

gitGraph
  commit id:"B"
  branch pr
  checkout pr
  commit id:"P"
  commit id:"Q"
  checkout main
  commit id:"L"
Loading

Where

  • B: Earlier commit on the base branch off of which the PR is branched off (aka merge base)
  • L: Latest commit on the base branch, fixes a bug
  • P: First commit of the PR, doesn't contain the bug fix
  • Q: Second commit of the PR, also doesn't contain the bug fix

Previously CI ran:

  • Format with L, with bugfix
  • Format with P, without bugfix
  • Format with Q, without bugfix

With this change, CI runs:

  • Format with L, with bugfix
  • Format with (L merged with P), with bugfix
  • Format with (L merged with Q), with bugfix

This was discovered in #209 Nixpkgs diff check, which failed with problems that were already fixed (such as #217 and some idempotency bug): https://github.com/NixOS/nixfmt/actions/runs/10567042446/job/29275137031?pr=209


This work is sponsored by Antithesis

Previously the Nixpkgs diff script would first format the latest base
branch commit, before formatting with each of the PRs commits. This
however causes problems if the PR commits are on top of a much older
commit that has bugs that aren't in the base branch anymore.

More visually, a PR branch graph looks like this:

base: B --- L
       \
        \
PR:      P --- Q

Where
B: Earlier commit on the base branch off of which the PR is branched off (aka merge base)
L: Latest commit on the base branch, fixes a bug
P: First commit of the PR, doesn't contain the bug fix
Q: Second commit of the PR, also doesn't contain the bug fix

Previously CI ran:
- Format with L, with bugfix
- Format with P, without bugfix
- Format with Q, without bugfix

With this change, CI runs:
- Format with L, with bugfix
- Format with (L merged with P), with bugfix
- Format with (L merged with Q), with bugfix
Copy link

github-actions bot commented Aug 27, 2024

Nixpkgs diff

@infinisil
Copy link
Member Author

I successfully tested this locally on #209 with

./scripts/sync-pr.sh https://github.com/NixOS/nixfmt 209 https://github.com/infinisil/nixpkgs

(insert your own Nixpkgs fork there, it will push the result to its nixfmt-209 branch)

@dasJ dasJ merged commit 738abf3 into master Aug 29, 2024
2 checks passed
@dasJ dasJ deleted the fix-nixpkgs-diff-merging branch August 29, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants