Skip to content

Commit fa99e2a

Browse files
ci: share one build cache scope across merge groups and pass the base ref down
Each merge group has a unique ref name, so keying the buildx cache on it wrote a scope nothing reads again. The upgrade-from script derived the base branch on its own from the same empty variable, so it now receives the one the action resolved. Signed-off-by: Nicholas Bucher <behappy54321@gmail.com>
1 parent 5cc9a8a commit fa99e2a

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

.github/actions/upgrade-test-setup/action.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ runs:
3131
id: resolve
3232
shell: bash
3333
env:
34-
MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref }}
34+
# A merge group has no base_ref; its ref name is gh-readonly-queue/<base>/pr-N-<sha>.
35+
BASE_REF: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref_name }}
3536
run: |
36-
# A merge group has no GITHUB_BASE_REF; its ref name is gh-readonly-queue/<base>/pr-N-<sha>.
37-
base_ref="${GITHUB_BASE_REF:-${MERGE_GROUP_BASE_REF#refs/heads/}}"
38-
base_ref="${base_ref:-${GITHUB_REF_NAME:-}}"
37+
base_ref="${BASE_REF#refs/heads/}"
3938
is_release_line=false
4039
if [[ "$base_ref" =~ ^release/v[0-9]+\.[0-9]+\.x$ ]]; then
4140
is_release_line=true
@@ -45,7 +44,7 @@ runs:
4544
# prev-stable = the previous minor line's latest published version.
4645
# Before that line has a final release, use its latest prerelease so
4746
# main keeps upgrade coverage after the release branch is cut.
48-
V="$(./scripts/prev-stable-version.sh)"
47+
V="$(CURRENT_REF="$base_ref" ./scripts/prev-stable-version.sh)"
4948
if [ -z "$V" ]; then
5049
echo "no published version on the previous release line; skipping prev-stable leg."
5150
echo "skip=true" >> "$GITHUB_OUTPUT"

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ concurrency:
1919
env:
2020
# Cache key components for better organization
2121
CACHE_KEY_PREFIX: kagent-v2
22-
BRANCH_CACHE_KEY: ${{ github.head_ref || github.ref_name }}
22+
# Merge groups share one cache scope; their ref names are unique and would each write a throwaway one.
23+
BRANCH_CACHE_KEY: ${{ github.head_ref || (github.event.merge_group.base_ref && 'merge-queue') || github.ref_name }}
2324
# Consistent builder configuration
2425
BUILDX_BUILDER_NAME: kagent-builder-v0.23.0
2526
BUILDX_VERSION: v0.23.0

.github/workflows/migration-immutability.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717

1818
- name: Fail if any existing migration file was modified
1919
env:
20+
# A merge group has no base_ref; it only exposes the base branch as refs/heads/<branch>.
2021
BASE_REF: ${{ github.base_ref || github.event.merge_group.base_ref }}
2122
run: |
2223
BASE=$(git merge-base HEAD "origin/${BASE_REF#refs/heads/}")

0 commit comments

Comments
 (0)