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

automerge: run on failed merge_group events #173010

Merged
merged 1 commit into from
May 31, 2024
Merged

Conversation

carlocab
Copy link
Member

@carlocab carlocab commented May 28, 2024

Closes #172999 (maybe)

@carlocab carlocab requested review from MikeMcQuaid and a team as code owners May 28, 2024 10:15
@github-actions github-actions bot added workflows PR modifies GitHub Actions workflow files automerge-skip `brew pr-automerge` will skip this pull request labels May 28, 2024
@carlocab
Copy link
Member Author

This depends a lot on Homebrew/actions/find-related-workflow-run-id, and whether it can find the associated PR based on the merge_group run.

Copy link
Member

@ZhongRuoyu ZhongRuoyu left a comment

Choose a reason for hiding this comment

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

So the logic is: click "merge when ready", merge group CI fails, then automerge is run where the real merge happens?

The "merge group CI fails" part could be a bit counterintuitive, but I guess this does work provided merge group CI fails in appropriate cases.

@MikeMcQuaid
Copy link
Member

The "merge group CI fails" part could be a bit counterintuitive

I think this is probably unavoidable given that:

  • you cannot commit to a PR inside a merge group itself and have those commits merged as part of the same merge group
  • the hook for the "merge when ready" button is the merge group event

I'd be happy with this as a solution 👍🏻

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Makes sense to me! Worth a try, thanks for this @carlocab!

@Bo98
Copy link
Member

Bo98 commented May 28, 2024

Is there a risk of an infinite loop here?

@carlocab
Copy link
Member Author

Is there a risk of an infinite loop here?

Possibly, yes. It seemed like a possibility to me as I was writing this down, but I haven't yet worked out definitively either way.

@MikeMcQuaid
Copy link
Member

@carlocab could consider applying a label at some stage as a marker to avoid this?

@carlocab
Copy link
Member Author

carlocab commented May 30, 2024

I had to rework this.

This depends a lot on Homebrew/actions/find-related-workflow-run-id, and whether it can find the associated PR based on the merge_group run.

Unfortunately, find-related-workflow-run-id cannot find the associated PR based on the merge_group run.

This meant I had to write a new GraphQL query that does find the associated PR. I've also written another query that checks the PR timeline for removed-from-merge-queue events so that we can exit with an error when we see too many of those (in order to avoid infinite loops).

However, there is still quite a bit of overlap with the automerge.yml workflow. I'd be happy to see the overlap deduplicated, but I've already exceeded the time I allocated to this PR. I'd appreciate if someone else picked that up. (Or I can return to it at a later date.)

@carlocab carlocab requested a review from a team May 30, 2024 03:39
@carlocab
Copy link
Member Author

@carlocab could consider applying a label at some stage as a marker to avoid this?

I took the more direct approach of checking the PR timeline for too many removed-from-merge-queue events.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great work @carlocab!

@carlocab carlocab added this pull request to the merge queue May 31, 2024
Merged via the queue into master with commit f0e135e May 31, 2024
17 checks passed
@carlocab carlocab deleted the merge_group-automerge branch May 31, 2024 08:24
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge-skip `brew pr-automerge` will skip this pull request outdated PR was locked due to age workflows PR modifies GitHub Actions workflow files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make "Merge when ready" button always "work"
5 participants