Skip to content

Commit e2de72a

Browse files
committed
fix(golden): listen on merge_group event so gate posts status under merge queue
This repo uses GitHub's merge queue (per build.yml's existing merge_group trigger). When a PR enters the queue, GitHub dispatches a merge_group event against an ephemeral ref, not pull_request. A required check that only declares on.pull_request never reports a status on the merge_group event, so the merge queue treats it as missing/pending and blocks the merge — the same skipped-but-required failure mode the path-filter pitfall was about, just under a different trigger. Mirror build.yml's pattern: listen on both pull_request and merge_group with the same branch filters. The check_semver_bump.py script's self-gating (exit 0 when no expected.*.yaml changed) only helps when the workflow runs at all; this fix makes it run. Add a small "resolve base ref" step because the two event types expose the target branch differently: pull_request sets github.base_ref to the bare branch name; merge_group leaves base_ref empty and exposes the full ref at github.event.merge_group.base_ref (e.g. "refs/heads/develop"), which we strip to match the pull_request shape before passing to check_semver_bump.py. Caught by review on PR #9057.
1 parent f17c4c5 commit e2de72a

1 file changed

Lines changed: 38 additions & 8 deletions

File tree

.github/workflows/golden-semver-gate.yml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
name: Golden Templates Semver Gate
22

3-
# Always run on PRs to develop / feat branches. The check_semver_bump.py
3+
# Run on every PR AND on every merge_group event. The check_semver_bump.py
44
# script self-gates: it returns exit 0 when no expected.*.yaml files
55
# changed, so an unconditional run is cheap and posts a definitive
6-
# status on every PR. Do NOT use `on.pull_request.paths:` filtering —
7-
# path filtering skips the whole workflow when no path matches, which
8-
# means no status is posted, which means branch protection treats a
9-
# required check as missing/pending and blocks the PR. Self-gating in
10-
# the script is the canonical fix for the "skipped but required check"
11-
# pitfall.
6+
# status on every event.
7+
#
8+
# Two pitfalls this trigger configuration avoids — both flavors of the
9+
# "skipped but required check" problem:
10+
#
11+
# 1. on.pull_request.paths: filtering would skip the workflow entirely
12+
# when no matching path changed, posting no status, which branch
13+
# protection treats as missing/pending. We self-gate in the script
14+
# instead so the status always posts.
15+
#
16+
# 2. listening on pull_request alone would skip the workflow when a PR
17+
# enters the merge queue (which dispatches merge_group, not
18+
# pull_request). The merge queue would then treat the required
19+
# check as missing/pending and block the merge. We listen on both
20+
# events to match build.yml.
1221
on:
1322
pull_request:
1423
branches:
1524
- develop
1625
- "feat/*"
1726
- "feat-*"
27+
merge_group:
28+
types: [checks_requested]
29+
branches:
30+
- develop
31+
- "feat/*"
32+
- "feat-*"
1833

1934
permissions:
2035
contents: read
@@ -30,9 +45,24 @@ jobs:
3045
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
3146
with:
3247
python-version: "3.11"
48+
- name: Resolve base ref
49+
id: baseref
50+
env:
51+
# github.base_ref is set on pull_request events. On merge_group
52+
# events it's empty and the target branch lives at
53+
# github.event.merge_group.base_ref as a full ref ("refs/heads/develop");
54+
# strip the prefix to match the bare branch name pull_request emits.
55+
PR_BASE_REF: ${{ github.base_ref }}
56+
MG_BASE_REF: ${{ github.event.merge_group.base_ref }}
57+
run: |
58+
if [ -n "$PR_BASE_REF" ]; then
59+
echo "base=$PR_BASE_REF" >> "$GITHUB_OUTPUT"
60+
else
61+
echo "base=${MG_BASE_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
62+
fi
3363
- name: Run semver gate
3464
env:
35-
BASE_REF: ${{ github.base_ref }}
65+
BASE_REF: ${{ steps.baseref.outputs.base }}
3666
run: |
3767
python tests/golden/check_semver_bump.py \
3868
--base "origin/${BASE_REF}" \

0 commit comments

Comments
 (0)