# [RFC] Merge Bot

## Summary

PRs authors must currently wait for changes to be manually merged by a 
committer clicking the "merge" button. A large amount of time can often elapse 
between CI going green, a PR being approved, and this merge button being 
pressed. This RFC proposes a safe, self-service mechanism to allow PR authors 
to merge their own PRs. This mechanism will also ensure better commit messages 
than GitHub's UI provides.

## Motivation

The PR process currently looks something like this:

1. Develop and submit code

2. Request and wait for reviews

3. Iterate and address comments

4. Wait for CI

5. Ask a committer to merge the PR

This RFC addresses steps 4 and 5. It is commonplace for TVM developers to have 
to ask a committer to merge a PR that has already been approved by someone 
else. Imagine if a simple PR was submitted and a reviewer accepts it minutes 
after it was posted. A committer will have to revisit this PR in the future, 
requiring another sync and more time out of their day, to mindlessly merge the 
PR (since it has already been accepted). It has also happened in the course of 
development that PRs that need to be monitored after merging (especially CI 
infrastructure changes) are merged at inopportune times for the author. 
Allowing users who are not committers to merge their own PRs solves this issue.

TVM's commit messages are also poor. This is due to the fact that GitHub’s 
squash-and-merge strategy uses a commit message made by concatenating the first 
lines of all commits in a PR’s branch. These commits are often named irrelevant 
or nonsense things which do not belong in the history. Meanwhile, the first 
message in a PR thread often has a thoughtful and descriptive message which is 
usually more appropriate. This gets lost behind a level of indirection and is 
unavailable without a connection to GitHub. GitHub has no solution for this as 
can be seen in [this 
thread](https://github.community/t/how-to-change-the-default-squash-merge-commit-message/1155).
 See examples:

- 
[https://github.com/apache/tvm/commit/dace8b72e3a8173704a689a7074df4c6f36bda4a](https://github.com/apache/tvm/commit/dace8b72e3a8173704a689a7074df4c6f36bda4a)

- 
[https://github.com/apache/tvm/commit/73cf51b8246f1f0b5c0bff6fa206d154e053199b](https://github.com/apache/tvm/commit/73cf51b8246f1f0b5c0bff6fa206d154e053199b)

## Reference

A bot implemented as a GitHub Actions workflow will listen for comments on PRs 
that match a pattern similar to:

```

@tvm-bot merge this

```

It will then check that the PR has been accepted by a valid reviewer / 
committer in its latest version. If so, it will rebase the PR on `main`, using 
the GitHub PR's body and title as the commit message and `push` to the `main` 
branch using a committer API key. If this fails (perhaps due to a push to 
`main` that happened in the meantime), it will re-attempt until successful. It 
will then leave a comment on the PR:

```

This PR has been merged with commit <commit short hash>.

```

or relevant information for debugging and who to contact if failed. The merge 
button on PRs could be effectively disabled by restricting the `main` branch to 
admin-only access.

## Prior Art

PyTorch does this

## Disadvantages

- This would be a non-standard flow, adding another piece of overhead to the 
TVM PR process that is outside of the typical process one would expect on 
GitHub.

- Something to maintain - this would be another piece of automation for us to 
build. Given that we have dedicated resources for the CI though, this is 
manageable.

## Alternatives

- Do nothing - continue with bad commit messages and slow PR merging. 
Maintaining the status quo is certainly an option, but given the pains felt by 
PR authors something probably needs to happen.

- Make more people committers - This should happen anyway given the rising 
number of TVM contributors but there will always be people that aren't. In 
addition, the commit message issue persists even if people can merge their own 
PRs on GitHub.





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/allow-merging-via-pr-comments/12220/1) 
to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.apache.org/email/unsubscribe/64440d86be8d618dd8dc598086a6e899083a4db5de604288c629f5ad7770cdea).

Reply via email to