Skip to content

Conversation

@Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Nov 11, 2025

Explanation

This adds the merge_group target and adds a check for releases, so we can safely enable the merge queue.

The release check will check for any differences on main or in the merge queue compared to the release branch. If any conflicts are detected, the release will be rejected from the merge queue, and will need to be updated with the latest changes first.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Add merge queue support and a release-conflict check action integrated into the main workflow for release PRs.

  • CI/Workflows:
    • Add merge_group trigger to .github/workflows/main.yml.
    • Introduce check-release job to detect PR/merge-queue releases and run conflict checks.
      • Uses MetaMask/action-is-release to detect release PRs and extracts PR number (supports merge queue refs).
      • Wires results into overall job dependencies (all-jobs-complete now needs check-release).
  • New Composite Action:
    • Add .github/actions/check-release/action.yml to detect release conflicts across packages.
      • Identifies packages with version bumps vs main, computes changed files ahead of the PR/merge group target, and errors on conflicts.
      • Supports pull_request and merge_group events; fetches PR branch via gh and compares against calculated target.

Written by Cursor Bugbot for commit babd67a. This will update automatically on new commits. Configure here.

needs: check-workflows
runs-on: ubuntu-latest
steps:
- name: Check if the commit or pull request is a release
Copy link
Member Author

Choose a reason for hiding this comment

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

I considered reusing the is-release job below, but it adds a little bit of complexity around the conditionals, and we don't need the extra options below for merged commits.

Copy link
Member

@Gudahtt Gudahtt Nov 12, 2025

Choose a reason for hiding this comment

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

Nit: We could maybe skip this for push events? Just because it wouldn't be relevant anymore for push, and this might make it a bit more clear why we have to similarly-named jobs

Copy link
Member Author

Choose a reason for hiding this comment

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

We could skip the individual steps on push, but not the job itself, since that would cause all-jobs-complete to be skipped.

uses: MetaMask/action-is-release@d063725cd15ee145d7e795a2e77db31a3e3f2c92
with:
commit-starts-with: 'Release [version],Release v[version],Release/[version],Release/v[version],Release `[version]`'
commit-message: ${{ github.event.pull_request.title }}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is used so we can determine if an unmerged pull request is a release pull request. github.event.pull_request.title is not defined for other events (push and merge_group), so doesn't affect those.

with:
commit-starts-with: 'Release [version],Release v[version],Release/[version],Release/v[version],Release `[version]`'
commit-message: ${{ github.event.pull_request.title }}
before: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
Copy link
Member Author

Choose a reason for hiding this comment

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

github.event.before is only defined on push, not on pull_request or merge_group, so I had to add this.

Copy link
Member

@Gudahtt Gudahtt Nov 12, 2025

Choose a reason for hiding this comment

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

base.sha doesn't seem correct here.

In the action-is-release action, we used github.event.before to get the diff of what changed in a given commit, to check whether the version number had changed. For the push event, the diff betweeen github.event.before and the current commit would only include changes from that push event.

Whereas base.sha refers to the commit on the base branch that the PR was originally branched from. It does not get updated when the branch is updated with a merge commit. That means if a core release goes out while a PR is open, github.event.pull_request.base.sha..HEAD will include a version bump from the unrelated core release on main.

Instead I think we need the merge-base here, between the base branch and the current commit

Copy link
Member

Choose a reason for hiding this comment

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

Either that, or get the merge-base in action-is-release instead

needs: check-workflows
uses: ./.github/workflows/lint-build-test.yml

check-release:
Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't add a conditional here, but only to the step below. This way we can add check-release as dependency to all-jobs-complete. Otherwise, if check-release (the job) is skipped, all-jobs-complete would be skipped too.

done
# Get all files changed ahead of this PR.
git diff --name-only "$BEFORE..$(git merge-base HEAD refs/remotes/origin/main)" > changed-files.txt
Copy link
Member Author

Choose a reason for hiding this comment

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

From my understanding, git merge-base HEAD refs/remotes/origin/main finds the common ancestor between HEAD (i.e., the current commit), and origin/main. We can then diff $BEFORE with that to find any differences on main not included in the current branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an action rather than a workflow to support the uses syntax in a step, rather than as a job. It's related to this comment.

@Mrtenz Mrtenz marked this pull request as ready for review November 12, 2025 14:40
@Mrtenz Mrtenz requested a review from a team as a code owner November 12, 2025 14:40
@Mrtenz Mrtenz force-pushed the mrtenz/merge-queue-release-validation branch from d677951 to 56f08cb Compare November 12, 2025 14:40
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
echo "TARGET=$(git merge-base HEAD refs/remotes/origin/main)" >> "$GITHUB_OUTPUT"
Copy link

Choose a reason for hiding this comment

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

Bug: Wrong Target Prevents PR Conflict Detection

For pull_request events, TARGET is set to the merge-base of HEAD and main, but it should be the current state of main itself. Since BEFORE (line 64) is also a merge-base, the diff comparison at line 65 will compare two merge-bases that are likely identical, resulting in an empty diff that fails to detect conflicts with changes that landed on main after the PR was created.

Fix in Cursor Fix in Web

Copy link
Member

Choose a reason for hiding this comment

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

The merge-base of HEAD and main should nearly always be identical to main, except in the case where the a new commit was made to main since the workflow began. In that scenario, the merge base of HEAD is correct here.

elif [ "$EVENT_NAME" = "merge_group" ]; then
echo "TARGET=$(git rev-parse HEAD^)" >> "$GITHUB_OUTPUT"
else
echo "::error::This action only supports `pull_request` and `merge_group` events."
Copy link
Member

Choose a reason for hiding this comment

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

When running this through shellcheck.net, it's suggesting that Bash is trying to execute what's in these backticks. Escaping it should ensure they don't get interpreted as a command.

Alternatively we could use a single quotes here instead

Suggested change
echo "::error::This action only supports `pull_request` and `merge_group` events."
echo "::error::This action only supports \`pull_request\` and \`merge_group\` events."

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, fixed in 375f5ed.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Looks great! Just one minor suggestion

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@Mrtenz Mrtenz force-pushed the mrtenz/merge-queue-release-validation branch from 375f5ed to babd67a Compare November 13, 2025 21:39
@Mrtenz Mrtenz changed the title ci: Check if any PRs in the merge queue affect a release ci: Check if any changes made ahead of PR affect a release to support merge queue Nov 13, 2025
@Mrtenz Mrtenz merged commit af8b97b into main Nov 13, 2025
272 checks passed
@Mrtenz Mrtenz deleted the mrtenz/merge-queue-release-validation branch November 13, 2025 22:07
Mrtenz added a commit that referenced this pull request Nov 17, 2025
…7162)

## Explanation

This adds some logic to #7114 to add a comment to a pull request if a
conflict was detected, either in the pull request checks or in the merge
queue. Old comments will be hidden automatically as well:

<img width="933" height="475" alt="image"
src="https://github.com/user-attachments/assets/94153654-9aea-4b97-b67a-19205f8fdb7c"
/>

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Enhances the release-conflict check to post a PR comment (minimizing
old ones), expose outputs for conflicted package names, and
conditionally fail; updates workflow permissions.
> 
> - **CI / Release conflict checks**:
> - **Action `check-release`**
(`.github/actions/check-release/action.yml`):
> - Emits outputs `package-names` and `has-conflicts` instead of exiting
immediately upon conflicts; final separate step now fails when conflicts
exist.
>     - Adds `id: check-release` to expose outputs.
> - Posts a PR comment listing conflicted packages and notes merge-queue
context; hides previous such comments via GraphQL minimization.
>   - **Workflow** (`.github/workflows/main.yml`):
> - Grants `contents: read` and `pull-requests: write` permissions to
`check-release` job to allow commenting.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3fe207d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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