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

Added core functionality to auto-merge PRs #5

Merged
merged 40 commits into from
Sep 27, 2023
Merged

Conversation

Bullrich
Copy link
Collaborator

@Bullrich Bullrich commented Sep 26, 2023

Created base of the bot, with the ability to comment on a PR and to enable/disable auto-merge.

You can find a working example in paritytech-stg#1

This resolves #1

The bot can enable auto-merge, disable it and show the available commands.

If the user is not a member of the org or the author of the PR, the bot will not work. This is to stop external parties of enabling/disabling the bot.

This is a required step to solve polkadot-fellows/runtimes#41

@Bullrich Bullrich requested a review from a team as a code owner September 26, 2023 15:09
@Bullrich Bullrich self-assigned this Sep 26, 2023
return;
}

if (this.pr.state === "closed") {

Choose a reason for hiding this comment

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

should we check against draft too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The state object only has closed or open.

I would say no anyways because it still needs to have the reviews. You can always set a project to auto-merge even if it is in draft state.

What do you think?

break;
case "cancel":
await this.commentsApi.reactToComment(this.comment.id, "+1");
await merger.disableAutoMerge();

Choose a reason for hiding this comment

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

will it be okay if it's not enabled?
or if you enable - that it's already enabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I tested that out and it doesn't change the state if it is already set. Here you have an example where I called cancel even tho it isn't enabled.

src/bot.ts Outdated Show resolved Hide resolved
src/bot.ts Show resolved Hide resolved
Bullrich and others added 2 commits September 27, 2023 11:06
Co-authored-by: Przemek Rzad <roopert7@gmail.com>
also updated worflow to have the same effect
set-auto-merge:
runs-on: ubuntu-latest
# Important! This forces the job to run only on Pull Requests
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/bot') }}

Choose a reason for hiding this comment

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

I guess, it's the right time to question /bot part, and consider /merge

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I left this for a future task: #8

As I need to change a couple of things and thought it would be better there

@Bullrich Bullrich merged commit 24f7c79 into main Sep 27, 2023
4 checks passed
@Bullrich Bullrich deleted the first-development branch September 28, 2023 09:11
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.

Allow to auto merge
4 participants