Skip to content

Commit

Permalink
[ci] Add GitHub Actions bot to merge PRs on demand
Browse files Browse the repository at this point in the history
This implements https://discuss.tvm.apache.org/t/rfc-allow-merging-via-pr-comments/12220. The bot can be invoked from a top-level review comment or via a regular PR comment. The text `@tvm-bot merge` anywhere in the body will trigger the bot. Right now it checks that the latest commit is reviewed and that all CI jobs that have run on that commit are successful. If it fails, it will leave a comment on the PR with the reason.

This is just a start and some features are left for followups:
* Various TODOs throughout the code
* "Scheduled" merges that happen once CI finishes
* Allowing committers to merge without getting a fresh review for changes after an approval
  • Loading branch information
driazati committed Mar 31, 2022
1 parent 8813d0a commit a47c9f5
Show file tree
Hide file tree
Showing 9 changed files with 1,127 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

name: Merge
on:
status:
pull_request_review:
types:
- submitted
issue_comment:

concurrency:
group: merge-${{ github.event.pull_request.number }}-${{ github.event.issue.number }}
cancel-in-progress: true

jobs:
maybe-merge:
if: github.repository == 'driazati/tvm'
# if: github.repository == 'apache/tvm' # TODO: uncomment after testing
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Merge if requested and possible
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -eux
python tests/scripts/github_mergebot.py --pr "$PR_NUMBER" --run-url "$RUN_URL"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,5 @@ tvm-site/
# Generated docs files
gallery/how_to/work_with_microtvm/micro_tvmc.py

# Test sample data files
!tests/python/ci/sample_prs/*.json
123 changes: 123 additions & 0 deletions tests/python/ci/sample_prs/pr10786-badci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"title": "[Hexagon] 2-d allocation cleanup",
"body": "- Added device validity check in allocation. HexagonDeviceAPI should only be called for CPU/Hexagon types.\r\n\r\n- Check for \"global.vtcm\" scope instead of \"vtcm\". The ccope of N-d allocations produced by `LowerVtcmAlloc` should be `\"global.vtcm\"`. The previous check allowed unsupported scope such as `\"local.vtcm\"`.\r\n\r\n- Remove `vtcmallocs` entry after calling free. Previously, the vtcm allocation map kept dangling pointers to `HexagonBuffer` objects after they had been freed.\r\n\r\n- Rename N-d alloc and free packed functions. Since most of the similar device functions use snake case, renaming `*.AllocND` to `*.alloc_nd` and `*.FreeND` to `*.free_nd`.\r\n\r\nCo-authored-by: Adam Straw <[email protected]>",
"state": "OPEN",
"comments": {
"pageInfo": {
"hasPreviousPage": false
},
"nodes": []
},
"authorCommits": {
"nodes": [
{
"commit": {
"authors": {
"nodes": [
{
"name": "Eric Lunderberg",
"email": "[email protected]"
},
{
"name": "Adam Straw",
"email": "[email protected]"
}
]
}
}
}
]
},
"commits": {
"nodes": [
{
"commit": {
"oid": "6f04bcf57d07f915a98fd91178f04d9e92a09fcd",
"statusCheckRollup": {
"contexts": {
"pageInfo": {
"hasNextPage": false
},
"nodes": [
{
"name": "MacOS",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "CI"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945392"
},
{
"name": "cc-reviewers",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "PR"
}
}
},
"status": "COMPLETED",
"conclusion": "FAILED",
"url": "https://github.com/apache/tvm/runs/5694945029"
},
{
"name": "tag-teams",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "Teams"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945030"
},
{
"name": "Windows",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "CI"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945524"
},
{
"state": "SUCCESS",
"context": "tvm-ci/pr-merge",
"targetUrl": "https://ci.tlcpack.ai/job/tvm/job/PR-10786/1/display/redirect"
}
]
}
}
}
}
]
},
"reviewDecision": "APPROVED",
"reviews": {
"pageInfo": {
"hasPreviousPage": false
},
"nodes": [
{
"body": "@tvm-bot merge",
"updatedAt": "2022-03-25T22:13:50Z",
"authorCanPushToRepository": true,
"commit": {
"oid": "6f04bcf57d07f915a98fd91178f04d9e92a09fcd"
},
"state": "APPROVED"
}
]
}
}
123 changes: 123 additions & 0 deletions tests/python/ci/sample_prs/pr10786-merges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"title": "[Hexagon] 2-d allocation cleanup",
"body": "- Added device validity check in allocation. HexagonDeviceAPI should only be called for CPU/Hexagon types.\r\n\r\n- Check for \"global.vtcm\" scope instead of \"vtcm\". The ccope of N-d allocations produced by `LowerVtcmAlloc` should be `\"global.vtcm\"`. The previous check allowed unsupported scope such as `\"local.vtcm\"`.\r\n\r\n- Remove `vtcmallocs` entry after calling free. Previously, the vtcm allocation map kept dangling pointers to `HexagonBuffer` objects after they had been freed.\r\n\r\n- Rename N-d alloc and free packed functions. Since most of the similar device functions use snake case, renaming `*.AllocND` to `*.alloc_nd` and `*.FreeND` to `*.free_nd`.\r\n\r\nCo-authored-by: Adam Straw <[email protected]>",
"state": "OPEN",
"comments": {
"pageInfo": {
"hasPreviousPage": false
},
"nodes": []
},
"authorCommits": {
"nodes": [
{
"commit": {
"authors": {
"nodes": [
{
"name": "Eric Lunderberg",
"email": "[email protected]"
},
{
"name": "Adam Straw",
"email": "[email protected]"
}
]
}
}
}
]
},
"commits": {
"nodes": [
{
"commit": {
"oid": "6f04bcf57d07f915a98fd91178f04d9e92a09fcd",
"statusCheckRollup": {
"contexts": {
"pageInfo": {
"hasNextPage": false
},
"nodes": [
{
"name": "MacOS",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "CI"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945392"
},
{
"name": "cc-reviewers",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "PR"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945029"
},
{
"name": "tag-teams",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "Teams"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945030"
},
{
"name": "Windows",
"checkSuite": {
"workflowRun": {
"workflow": {
"name": "CI"
}
}
},
"status": "COMPLETED",
"conclusion": "SUCCESS",
"url": "https://github.com/apache/tvm/runs/5694945524"
},
{
"state": "SUCCESS",
"context": "tvm-ci/pr-merge",
"targetUrl": "https://ci.tlcpack.ai/job/tvm/job/PR-10786/1/display/redirect"
}
]
}
}
}
}
]
},
"reviewDecision": "APPROVED",
"reviews": {
"pageInfo": {
"hasPreviousPage": false
},
"nodes": [
{
"body": "@tvm-bot merge",
"updatedAt": "2022-03-25T22:13:50Z",
"authorCanPushToRepository": true,
"commit": {
"oid": "6f04bcf57d07f915a98fd91178f04d9e92a09fcd"
},
"state": "APPROVED"
}
]
}
}
Loading

0 comments on commit a47c9f5

Please sign in to comment.