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

feat: merge-on-green bot #287

Merged
merged 49 commits into from
Feb 19, 2020
Merged

feat: merge-on-green bot #287

merged 49 commits into from
Feb 19, 2020

Conversation

sofisl
Copy link
Contributor

@sofisl sofisl commented Feb 14, 2020

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.

@sofisl sofisl changed the title Mog 2 Feature: merge-on-green bot Feb 14, 2020
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 14, 2020
@sofisl sofisl requested a review from bcoe February 14, 2020 22:12
@bcoe bcoe requested a review from chingor13 February 14, 2020 22:16
@bcoe bcoe changed the title Feature: merge-on-green bot feat: merge-on-green bot Feb 14, 2020
Copy link
Contributor

@chingor13 chingor13 left a 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.

Comment on lines +44 to 48
if (now - created > MAX_TEST_TIME) {
console.warn(`deleting stale PR ${url}`);
await handler.removePR(url);
state = 'stop';
}
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

@chingor13 chingor13 Feb 19, 2020

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.

Copy link
Contributor Author

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.

Comment on lines 17 to 24
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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants