-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat: merge-on-green bot #287
Conversation
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.
LGTM for a first pass, but I'd also like to see the general logic of the bot described on the README for anyone who discovers the bot and wants a quick overview of what's happening.
if (now - created > MAX_TEST_TIME) { | ||
console.warn(`deleting stale PR ${url}`); | ||
await handler.removePR(url); | ||
state = 'stop'; | ||
} |
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.
TODO: I'd prefer to not have a "list" method that has side effects - perhaps later refactor this to do the list, then have an explicit loop over the returned WatchPR
objects that removes the expired ones.
We can probably clean this up in a follow-up PR.
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.
Added this as a to-do in the code!
const branchProtectionArray = branchProtection.required_status_checks | ||
.contexts as string[]; | ||
const configProtectionArray = configProtection as string[]; | ||
handler.addPR = async function addPR(wp: WatchPR, url: string) { |
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.
TODO: we can likely split the database functionality into its own file and import these helper functions for use in the main bot event handling.
We can clean this up in a follow-up PR.
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.
Also added this as well.
packages/merge-on-green/README.md
Outdated
Once installed, this bot merges PRs once reviews have been approved and tests have passed. Briefly speaking, the bot does the following: | ||
|
||
-User kicks off a PR, adds an ‘automerge’ label | ||
-Bot listens to PR and checks to see if appropriate label was added. If so, the PR info is added to Datastore as an entry | ||
-** A cron job will run the logic below every four minutes, until it hits two hours. Once it hits two hours, the job will pass in a status called ‘stop’, which the logic will then use to determine an outcome ** | ||
-Merge-on-green begins by checking if there are any reviews on the bot. If there are any non-approved reviews, assigned reviews that have not been fulfilled, or if no one has reviewed the PR, the bot will fail its check | ||
-Merge-on-green then checks to see if there is at least one commit in the PR, if the PR has an ‘automerge’ label (i.e., if the user has removed it) | ||
-Merge-on-green will then see what checks are required by individual languages according to the file googleapis/sloth/required-checks.json, and will map the repo to the language using the sloth.json file. If any repo has any special requirements for status checks, it should note them in the required-checks.json file |
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.
This markdown isn't rendering correctly
338cce8 commit 338cce8 Author: sofisl <[email protected]> Date: Wed Feb 19 11:42:43 2020 -0800 feat: merge-on-green bot (#287)
This PR is a feature request for a bot that automatically updates branches and merges PRs once all tests have passed and reviewers have approved.