Skip to content

Commit b540ee6

Browse files
authored
ci: Skip merge queue if pull request is up-to-date (#3786)
This adds a new action which determines whether a pull request in the merge queue is up-to-date, meaning: - The pull request is based on the latest commit on `main`. - The pull request is the first in the merge queue. In this case, all status checks have already passed on the branch, and running in the merge queue would be redundant, meaning we can skip the merge queue checks. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a job to detect up-to-date PRs in merge groups and conditionally skip subsequent checks, adjusting dependencies and final pass gating accordingly. > > - **CI Workflow (`.github/workflows/main.yml`)** > - **New job**: `check-skip-merge-queue` to detect up-to-date PRs during `merge_group` using `MetaMask/github-tools/.../check-skip-merge-queue@v1`. > - **Conditional execution**: `check-workflows` now `needs: check-skip-merge-queue` and is skipped in `merge_group` when `skip-merge-queue` is `true`. > - **Final gating**: `all-jobs-pass` now depends on both `all-jobs-complete` and `check-skip-merge-queue`, passing if either all jobs passed or `skip-merge-queue` is `true`. > - Minor wiring: checkout only during `merge_group` for the new job; propagate `skip-merge-queue` via job outputs. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 390987f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3624460 commit b540ee6

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,26 @@ concurrency:
1212
cancel-in-progress: ${{ !contains(github.ref, 'refs/heads/main') }}
1313

1414
jobs:
15+
check-skip-merge-queue:
16+
name: Check if pull request can skip merge queue
17+
runs-on: ubuntu-latest
18+
outputs:
19+
skip-merge-queue: ${{ steps.check-skip-merge-queue.outputs.up-to-date }}
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v6
23+
if: github.event_name == 'merge_group'
24+
25+
- name: Check pull request merge queue status
26+
id: check-skip-merge-queue
27+
if: github.event_name == 'merge_group'
28+
uses: MetaMask/github-tools/.github/actions/check-skip-merge-queue@v1
29+
1530
check-workflows:
1631
name: Check workflows
1732
runs-on: ubuntu-latest
33+
needs: check-skip-merge-queue
34+
if: github.event_name != 'merge_group' || needs.check-skip-merge-queue.outputs.skip-merge-queue != 'true'
1835
steps:
1936
- name: Checkout repository
2037
uses: actions/checkout@v6
@@ -126,11 +143,14 @@ jobs:
126143
name: All jobs pass
127144
if: ${{ always() }}
128145
runs-on: ubuntu-latest
129-
needs: all-jobs-complete
146+
needs:
147+
- all-jobs-complete
148+
- check-skip-merge-queue
130149
steps:
131150
- name: Check that all jobs have passed
151+
env:
152+
PASSED: ${{ needs.all-jobs-complete.outputs.passed == 'true' || needs.check-skip-merge-queue.outputs.skip-merge-queue == 'true' }}
132153
run: |
133-
passed="${{ needs.all-jobs-complete.outputs.passed }}"
134-
if [[ $passed != "true" ]]; then
154+
if [[ "$PASSED" != "true" ]]; then
135155
exit 1
136156
fi

0 commit comments

Comments
 (0)