-
Notifications
You must be signed in to change notification settings - Fork 214
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: force rebase and autosquash before merging #9794
Conversation
I'm confused, does this force a rebase on every PR that is labelled I also don't quite understand how the added condition for linear history helps triggering this 2, step merge process. |
@mhofman yes it forces a rebase on all PRs. this was done to ensure that the rebase action runs in every case scenario without fail.
This condition was added to avoid any PRs from going into the merge queue before being rebased by the rebase action |
Oh I didn't realize However, the Unless we ask mergify to implement an auto-squashable commit check, I think what we need is something like the following:
The main risk is an infinite rebase loop where |
@mhofman This is already handled by the when our The While this seperation of responsibilities between two rules is less than ideal, I think its more reliable than the alternative of writing our own CI job to handle this. |
To clarify, it does so because it forces a rebase of all Unless the rebase done by mergify does not change the commit in these cases (which would be wonderful), I think we can't afford a force rebase as it would force a re-run of all CI jobs when not necessary. If the commit does not change, there may still be the case of erroneous
Thanks for that video. FYI, the |
Deploying agoric-sdk with Cloudflare Pages
|
@mhofman no. fixup commits are already handled by the mergify config in master. this PR only adds the ability to handle merge commits on up to date PRs
As far as i have observed other than the case where there are no merge or fixup commits in a PR and the PR is up to date, the commit hashes are changed in all cases. This is true of our old way of doing things as well as our new method. In cases where the old method would not rebase a PR, the new method would not rebase a PR as well, hence the CI would not be re run To make things more clear and understandable, i've tested every possible scenario i can come up with and compiled them in this document. Let me know if theres anything ive missed in this. |
266e2e4
to
28f293d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor tweaks requested
82f8eb6
to
eb66d10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized we can avoid the separate rebase action in more cases.
.mergify.yml
Outdated
@@ -65,6 +77,7 @@ pull_request_rules: | |||
conditions: | |||
- base=master | |||
- label=automerge:rebase | |||
- linear-history |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this more, I think can get away with allowing non linear history PRs to enter the merge queue if they're not up to date
- linear-history | |
- or: | |
- '#commits-behind>0' | |
- linear-history |
.mergify.yml
Outdated
conditions: | ||
- base=master | ||
- label=automerge:rebase | ||
- -linear-history |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly we should be able to restrict how often this runs to cases not covered by the above
- -linear-history | |
- '#commits-behind=0' | |
- or: | |
- -linear-history | |
- check-failed=no-fixup-commits | |
- -draft |
@@ -65,6 +77,7 @@ pull_request_rules: | |||
conditions: | |||
- base=master | |||
- label=automerge:rebase | |||
- linear-history | |||
actions: | |||
queue: | |||
merge_method: merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is the default, but should we specify autosquash: true
here too to make things more obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that field is deprecated and will probably wont be supported in a few months time like the other deprecated fields
.github/workflows/mergify-ready.yml
Outdated
- name: Check for fixup commits | ||
id: fixup-commits | ||
run: | | ||
if [[ $(git rev-list "$BASE_SHA".."$HEAD_SHA" --grep="^fixup! " | wc -l) -eq 0 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we're only checking fixup!
commits here, and we should also check for squash!
and amend!
commits as well. As a drive-by, we should fix the linear-history
job above to include amend!
too
To summarize the requested change I think we'll end up with the following 3 cases when a non-draft PR has the
If I had time I'd make a diagram out of this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing all these! Were you be able to redo a round of validation on mergify-experiments with the newest changes? I'm only 95% confident in my suggestions ;)
eecb776
to
2dfc192
Compare
i validated all the main cases. especially verifying the new suggested parts |
Updates the changes from Agoric/agoric-sdk#9825 and Agoric/agoric-sdk#9794 to mergify experiments
refs: #8500
Description
This PR does the following:
linear-history
to the queuing rule for rebasing, so that only rebased PRs can be queued.Note: autosquash here refers to
--autosquash
flag used by thegit rebase
command. it is used to squash and combinefixup!
commits. it does not squash all commits into a single commit before mergingIt fixes the following problems in #8500
fixup!
commitslinear-history
check onautomerge:rebase
enqueue to always enforce a linear-history before mergingrebase and autosquash
rule in mergify also fails if the PR cannot be rebased without conflicts. The failure indicates to the user that the PR must be rebased manuallyExamples of use:
Testing rebase on PR that was up to date: frazarshad/mergify-experiements#2
Testing if a fixup with incorrect title stops the PR from merging: frazarshad#6
Fallback:
In case the new action does not work as expected and does not auto-rebase, the user can still manually rebase in order to use the
automerge:rebase
action. All otherautomerge
actions work as originally intended.In order to bypass the
no-fixup-commit
check, simply add abypass:linear-history
label to the PRComparison report:
This is a comparison made of the previous method for merging and the new method: https://drive.google.com/file/d/1kfIW-pVOORuYwBOQlxt-2cus0k9ynAfb/view?usp=drive_link
Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
Upgrade Considerations