-
Notifications
You must be signed in to change notification settings - Fork 441
Add mergify for PR automation #940
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
Conversation
Submitted as a draft for discussion. Also, if folks like this, I need to configure the app against the repo and then validate the configuration in Mergify's dashboard before merging this. |
Here's an emaple PR that was auto-merged in the bot repo: instructlab/instructlab-bot#276 |
@russellb IIRC when Mergify was discussed before it was raised that it could take over/replace the |
Yes, it can do auto-labeling! There's no harm in just leaving what you have working already, though. The option to do it in this config would look something like this (not tested, but hopefully you get the idea): pull_request_rules:
- name: Auto label documentation PRs that change md files
conditions:
- files~=.*\.md$
actions:
label:
toggle:
- documentation |
Fine either way - happy to swap them later but if it's simple to implement now I'm not opposed to simplifying our infra |
Having more in the single tool is a bit simpler, to me, but it's only worth it if we're going to use Mergify for more (like auto-merging). |
@russellb I want to run a scenario by you that has to do with these 3 conditions just to make sure I understand them.
Say I open up a PR related to a part of the codebase that's Maintainer A's specialty and request their review. Maintainer A requests many changes and I do most of them but leave a few unresolved. Some time after, Maintainer B comes by and approves the PR. If I resolve the last few requested changes from Maintainer A by hand, and remove Maintainer A's review request would the PR automatically merge (assuming the remaining conditions you've outlined in the draft are fine)? |
I'm not positive on this one. I think we need to test the scenario. I know that you can drop requests for reviews. If someone has requested changes, I don't think you can do anything to those. They would block until that person comes back and either approves, or at least drops the "request changes" status of their review. We need to test it to validate that's true for sure. There's also the ability for maintainers to bypass the bot and merge manually if the need arises, like if that maintainer that requested changes went on several weeks of vacation. |
This PR introduces configuration for [Mergify](https://docs.mergify.com), with an initial configuration that will automatically merge PRs once they meet a set of defined criteria. What I like about this proposed configuration is that it allows the repo maintainers to manage the explicit merge rules in a file in the repo itself and then allow a tool to enforce them. The rules configured in this PR would be: - At least one mainatiner has approved the PR - There are no outstanding review requests - There are no requested changes outstanding - A `hold` label is not on the PR - The DCO check passes - Other CI jobs (actionlint, lint, test) are required based on which files were changed in the PR. Ideally once this configuration is in place, it should be incredibly rare that anyone hits the "merge" button manually. There are several other things that can be automated with Mergify - check out the docs for more if you're interested. Signed-off-by: Russell Bryant <rbryant@redhat.com>
The `hold` label is already in use, so I didn't remove that one. Both labels can be used to hold a PR for now. Signed-off-by: Russell Bryant <rbryant@redhat.com>
This will remove merged branches after merging them, providing automatic clenaup to forks since merged branches aren't important to keep around. Signed-off-by: Russell Bryant <rbryant@redhat.com>
I took it off of draft, as I think this is ready for final review and approval. However, I would prefer it's not actually merged and instead let me work on configuring the application on the repo first before merging the configuration. I can handle the merge when the timing is right. |
- name: auto-merge | ||
description: automatic merge for main with > 1 approved reviews, all requested reviews have given feedback, not held, and CI is successful | ||
conditions: | ||
- "#approved-reviews-by>=1" |
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 think we should set this to 2 to begin with and if we think that's too much friction bump it down to 1. I've been doing that with the PRs I've been reviewing over the last day and I think having that second set of eyes works well.
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.
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.
Need to change the policy first, so I say proceed as-is and if we want to change the policy that needs to be a separate PR to dev-docs
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.
Imo The number of approved-by reviewers for a PR shouldn't be uniform across the entire org, it should be on a repo by repo basis especially since that repo isn't public. If I have to open up a separate PR there I will, but I think that's separate from the 1 vs 2 approved-by reviews decision.
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's still a policy decision you need to propose - we shouldn't diverge this PR based on that. Automation needs to enforce existing policy.
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.
Yes - that was my thinking - enforce current policy, which then allows a PR workflow to propose and discuss changes from there
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.
and adding on -- I would expect maintainers to use their own judgment to decide when they feel additional reviews are needed. It's super easy to do. If you add another person to the list of requested reviewers, the PR can not merge until they all review it.
commit 6f2ee09
Author: Russell Bryant rbryant@redhat.com
Date: Fri Apr 19 10:59:41 2024 -0400
Add mergify for PR automation
This PR introduces configuration for
Mergify, with an initial configuration
that will automatically merge PRs once they meet a set of defined
criteria.
What I like about this proposed configuration is that it allows the
repo maintainers to manage the explicit merge rules in a file in the
repo itself and then allow a tool to enforce them. The rules
configured in this PR would be:
hold
label is not on the PRfiles were changed in the PR.
Ideally once this configuration is in place, it should be incredibly
rare that anyone hits the "merge" button manually.
There are several other things that can be automated with Mergify -
check out the docs for more if you're interested.
Signed-off-by: Russell Bryant rbryant@redhat.com