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
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b58797c
feature: first stab at merge-on-green
sofisl Jan 13, 2020
4b7fba3
fix: run lint
sofisl Jan 14, 2020
29ff527
fix: add merge-on-green label
sofisl Jan 22, 2020
63d675d
fix: remove dev
sofisl Jan 14, 2020
c691089
commit up to here
sofisl Jan 23, 2020
4f5a628
fix: add more tests, clean up code
sofisl Jan 17, 2020
7a19326
fix: run tests
sofisl Feb 5, 2020
c943760
first stab at script getting check runs from a commit from another ch…
sofisl Jan 18, 2020
6e411f3
refactored to test better
sofisl Feb 6, 2020
951fff3
include devdependencies in dev branch
sofisl Jan 18, 2020
b2e4d35
feature: finalize merge-on-green logic
sofisl Feb 6, 2020
e652dc8
fix: hide env variables
sofisl Jan 22, 2020
bbdc966
chore: add DB bits to mog
bcoe Feb 6, 2020
056a5f0
feat: continue to flesh out logic
sofisl Feb 12, 2020
42907ae
chore: code review of mog
bcoe Feb 13, 2020
b64ffbc
chore: fix up deployment
bcoe Feb 13, 2020
7c71c0c
getting config file, fixed return types and checking for return types…
sofisl Feb 13, 2020
babc2c5
save first draft of test
sofisl Feb 14, 2020
1f69320
a few fixes made during review today
bcoe Feb 14, 2020
9b98a39
a couple small bug fixes
bcoe Feb 14, 2020
688b2bf
Merge branch 'master' of github.com:googleapis/repo-automation-bots i…
sofisl Feb 14, 2020
79a4d14
Merge remote-tracking branch 'upstream/mog-2' into mog-2
sofisl Feb 14, 2020
74ba0e8
feature: merge-on-green bot
sofisl Feb 14, 2020
bac1853
fix: remove testing file
sofisl Feb 14, 2020
e1863da
remove coverage line in package json
sofisl Feb 14, 2020
1350977
fix: addressing code reviews
sofisl Feb 14, 2020
8bd845c
Merge branch 'master' into mog-2
sofisl Feb 14, 2020
d8af459
addressing comments, adding in special config file logic
sofisl Feb 14, 2020
1164b7c
fix: removing merge-on-green from being excluded for redeployment
sofisl Feb 14, 2020
f402ee4
npm run lint
sofisl Feb 14, 2020
563c5ab
fix: typo
sofisl Feb 14, 2020
b4d15cb
fix: address some comments
sofisl Feb 15, 2020
5537c08
fix: comments
sofisl Feb 15, 2020
65614bb
Merge branch 'master' into mog-2
sofisl Feb 18, 2020
dc7ba24
fix: further review
sofisl Feb 18, 2020
5ba3658
Merge branch 'mog-2' of github.com:sofisl/repo-automation-bots into m…
sofisl Feb 18, 2020
e69cf17
fix: npm run lint
sofisl Feb 19, 2020
c101d81
fix: npm run lint
sofisl Feb 19, 2020
d6059e4
fix: changing the way we notify of failure from checkParam to comment
sofisl Feb 19, 2020
a9a92d0
fix: re-remove package-lock
sofisl Feb 19, 2020
392527f
fix: bug that would prevent merging on final execution of retry
sofisl Feb 19, 2020
3853f84
fix: add readme
sofisl Feb 19, 2020
803b7cd
fix: added to-dos
sofisl Feb 19, 2020
cf17b25
fix: npm run lint
sofisl Feb 19, 2020
5eaa295
Merge branch 'master' into mog-2
sofisl Feb 19, 2020
457f26f
fix: markdown
sofisl Feb 19, 2020
bd30e11
Merge branch 'mog-2' of github.com:sofisl/repo-automation-bots into m…
sofisl Feb 19, 2020
e64f144
fix: markdown rendering
sofisl Feb 19, 2020
c58a366
fix: markdown
sofisl Feb 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 218 additions & 102 deletions package-lock.json

Large diffs are not rendered by default.

68 changes: 21 additions & 47 deletions packages/gcf-utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions packages/merge-on-green/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

Instructions are provided in [googleapis/repo-automation-bots](https://github.com/googleapis/repo-automation-bots/blob/master/README.md) for deploying and testing your bots.

This bot uses nock for mocking requests to GitHub, and snap-shot-it for capturing responses; This allows updates to the API surface to be treated as a visual diff, rather than tediously asserting against each field.
This bot uses nock for mocking requests to GitHub.

## Running tests:

`npm run test`

## To update snapshots:
## Installing:

`npm i`

## How it works

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
- Merge-on-green will look for the required checks in the statuses that have run. If it can’t find a given check in the statuses, it will also check under ‘check runs’ as github has two concepts to describe status checks. If it cannot find them,or if any has failed, MOG will fail the Status Check
- Three statuses that can result:
- Success: Merge
- If all steps above come out as ‘true’, the bot will update the branch the PR was called from, merge the PR, and remove the Datastore entry so that the bot no longer tries to merge that PR
- Fail: Keep Checking
- If one of the steps fail, then the Datastore entry will remain, and the bot will keep checking the variables above until they become true or the cron job times out
- Fail: Delete
- Once the cron job times out, it will pass a ‘stop’ state to the logic above. If this flag is set to ‘stop’, the bot will post a failed check-run on the PR and ask the user to try again. The bot will also delete the entry from Datastore so it does not keep checking the logic

`npm run test:snap`

## Contributing
If you have suggestions for how merge-on-green could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
Expand Down
6 changes: 3 additions & 3 deletions packages/merge-on-green/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"lint": "gts check"
},
"dependencies": {
"gcf-utils": "1.6.1",
"probot": "9.9.4",
"@octokit/rest": "16.41.2"
"@google-cloud/datastore": "^5.0.4",
"@octokit/rest": "16.41.2",
"gcf-utils": "1.6.1"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
Expand Down
Loading