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

Setup a PR review bot #30816

Closed
wants to merge 22 commits into from
Closed

Setup a PR review bot #30816

wants to merge 22 commits into from

Conversation

guhitb
Copy link

@guhitb guhitb commented Dec 20, 2023

Created a PR review bot. It does the following:

  1. Marks new PRs with the bot-review label and sets it to draft status.
  2. Checks to see if the PR contains the elements of a PR Template (from .github/pull_request_template.md).
  3. If PR matches a template, it removes the bot-review label and removes the PR from draft status.

The bot determines if a template has been used by looking at the **bolded headings**. It checks each known template against the body of the pull request.

Editing the pull request body causes the PR review bot to run again.

Issue: #30715

@jnewb1
Copy link
Contributor

jnewb1 commented Dec 20, 2023

do you have some examples of it working on your fork?

@guhitb
Copy link
Author

guhitb commented Dec 20, 2023

Here are some examples.

No template found, PR failed

openpilot-.2.mp4

Template found, PR passed

openpilot-.4.mp4

PR is edited, status is updated

openpilot.mp4

@jnewb1
Copy link
Contributor

jnewb1 commented Dec 20, 2023

does pygithub have an api for doing stuff like converting to draft, getting pull request id, etc?

@guhitb
Copy link
Author

guhitb commented Dec 20, 2023

As far as I could discover, draft status cannot be be modified by the REST endpoint that PyGithub uses internally.

Only the GraphQL endpoint can convert a PR to and from a draft. The required pull request id can only be obtained through the GraphQL endpoint.

PyGithub only handles labels, I could remove it as a dependency and do everything through the GraphQL endpoint. What do you think?

Copy link
Contributor

@adeebshihadeh adeebshihadeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

This is bigger and more custom than I was expecting. This is pretty generic stuff, and it's important that it has basically no maintenance cost (i.e. in the next year, we don't have to touch it to get it working again because some endpoint changed or something). Are there existing Actions we can use instead? The ideal thing is a single action, but perhaps there's a few different ones we can chain together. There's also github-script which I imagine would simplify this a bit.

@adeebshihadeh adeebshihadeh marked this pull request as draft January 10, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants