@@ -2,14 +2,17 @@ name: Verify
22
33on :
44 pull_request :
5+ merge_group :
56 workflow_dispatch :
67
78permissions :
89 contents : read
910
11+ # Each merge group has its own gh-readonly-queue ref, so queued groups never cancel each other; the
12+ # queue itself discards a group's run when it rebuilds the group.
1013concurrency :
11- group : verify-${{ github.workflow }}-${{ github.ref }}
12- cancel-in-progress : true
14+ group : verify-${{ github.workflow }}-${{ github.event.merge_group.head_ref || github. ref }}
15+ cancel-in-progress : ${{ github.event_name != 'merge_group' }}
1316
1417jobs :
1518 changes :
3235 id : scope
3336 env :
3437 EVENT_NAME : ${{ github.event_name }}
35- BASE_SHA : ${{ github.event.pull_request.base.sha }}
36- HEAD_SHA : ${{ github.event.pull_request.head.sha }}
38+ BASE_SHA : ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
39+ HEAD_SHA : ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
3740 run : |
3841 write_scope() {
3942 {
4851 } >> "${GITHUB_OUTPUT}"
4952 }
5053
51- if [[ "${EVENT_NAME}" != "pull_request" ]]; then
54+ if [[ "${EVENT_NAME}" != "pull_request" && "${EVENT_NAME}" != "merge_group" ]]; then
55+ write_scope true true true true true true true true
56+ exit 0
57+ fi
58+
59+ # A merge group's head is its base plus every queued pull request ahead of and including
60+ # this one, so the base..head diff covers the whole group. Anything that prevents an exact
61+ # diff runs everything rather than risk skipping a suite. Three dots compare with the merge
62+ # base, so changes that landed on main after a branch started are not counted as its own.
63+ changed_paths="${RUNNER_TEMP}/changed-paths"
64+ if [[ -z "${BASE_SHA}" || -z "${HEAD_SHA}" ]] || \
65+ ! git diff --name-only -z "${BASE_SHA}...${HEAD_SHA}" > "${changed_paths}"; then
66+ echo "Could not diff ${BASE_SHA:-<none>}...${HEAD_SHA:-<none>}; running every suite" >&2
5267 write_scope true true true true true true true true
5368 exit 0
5469 fi
@@ -135,9 +150,7 @@ jobs:
135150 broad=true
136151 ;;
137152 esac
138- # Three dots: compare with the merge base, so changes that landed on main after the branch
139- # started are not counted as this pull request's changes.
140- done < <(git diff --name-only -z "${BASE_SHA}...${HEAD_SHA}")
153+ done < "${changed_paths}"
141154
142155 if [[ "${changed}" != "true" ]]; then
143156 write_scope true true true true true true true true
@@ -590,7 +603,7 @@ jobs:
590603 - name : Check out the comparison base
591604 uses : actions/checkout@v4
592605 with :
593- ref : ${{ github.event.pull_request.base.sha || 'main' }}
606+ ref : ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || 'main' }}
594607 path : base
595608 - uses : astral-sh/setup-uv@v5
596609 with :
0 commit comments