From da974ef14171ca6662ad1e345232853b1e06befb Mon Sep 17 00:00:00 2001 From: pulimsr Date: Mon, 30 Mar 2026 22:36:43 -0400 Subject: [PATCH 1/3] updating the github workflow --- .github/workflows/pull-request-build.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index 59c8b3e694fe..cda39faeedc1 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -30,17 +30,18 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - BASE_SHA="${{ github.event.merge_group.base_sha }}" - BASE_REF="${{ github.event.merge_group.base_ref }}" - # base_ref is in refs/heads/ format, strip prefix for API call - BRANCH_NAME="${BASE_REF#refs/heads/}" - TARGET_SHA=$(gh api repos/${{ github.repository }}/git/ref/heads/${BRANCH_NAME} --jq '.object.sha') - if [ "$BASE_SHA" == "$TARGET_SHA" ]; then + MERGE_GROUP_BASE_SHA="${{ github.event.merge_group.base_sha }}" + HEAD_REF="${{ github.event.merge_group.head_ref }}" + PR_NUM=$(echo "$HEAD_REF" | grep -oP 'pr-\K[0-9]+') + PR_BASE_SHA=$(gh api repos/${{ github.repository }}/pulls/$PR_NUM --jq '.base.sha') + echo "Merge group base SHA: $MERGE_GROUP_BASE_SHA" + echo "PR #$PR_NUM base SHA: $PR_BASE_SHA" + if [ "$MERGE_GROUP_BASE_SHA" == "$PR_BASE_SHA" ]; then echo "skip=true" >> "$GITHUB_OUTPUT" - echo "First in queue — PR build already validated this combination, skipping." + echo "Merge group base matches PR base — PR build already validated this, skipping." else echo "skip=false" >> "$GITHUB_OUTPUT" - echo "Not first in queue — merge group includes changes from other PRs, build needed." + echo "Merge group base differs from PR base — other PRs ahead or base moved, build needed." fi - name: Configure AWS Credentials if: steps.queue-check.outputs.skip != 'true' From d55fba8e16d57b4c5a18e93e56741b9ca117c52c Mon Sep 17 00:00:00 2001 From: pulimsr Date: Tue, 31 Mar 2026 01:54:06 -0400 Subject: [PATCH 2/3] Strip refs/heads/ prefix from merge group head_ref and add skip logic --- .github/workflows/pull-request-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index cda39faeedc1..2809b42b9db8 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -66,6 +66,7 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number || '0' }} RUN_ID: ${{ github.run_id }} run: | + HEAD_REF="${HEAD_REF#refs/heads/}" ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION \ --repo "$REPO" \ --branch "$HEAD_REF" \ From 0e0e8bf6557078be0e54849930465d3351042ad5 Mon Sep 17 00:00:00 2001 From: pulimsr Date: Tue, 31 Mar 2026 02:35:05 -0400 Subject: [PATCH 3/3] base_sha --- .github/workflows/pull-request-build.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index 2809b42b9db8..445f035971a1 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -24,24 +24,29 @@ jobs: pull-requests: write contents: read steps: + - name: Checkout merge group (shallow) + if: github.event_name == 'merge_group' + uses: actions/checkout@v4 + with: + fetch-depth: 2 - name: Check if merge queue build is needed if: github.event_name == 'merge_group' id: queue-check env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - MERGE_GROUP_BASE_SHA="${{ github.event.merge_group.base_sha }}" HEAD_REF="${{ github.event.merge_group.head_ref }}" PR_NUM=$(echo "$HEAD_REF" | grep -oP 'pr-\K[0-9]+') PR_BASE_SHA=$(gh api repos/${{ github.repository }}/pulls/$PR_NUM --jq '.base.sha') - echo "Merge group base SHA: $MERGE_GROUP_BASE_SHA" + PARENT_SHA=$(git rev-parse HEAD~1) echo "PR #$PR_NUM base SHA: $PR_BASE_SHA" - if [ "$MERGE_GROUP_BASE_SHA" == "$PR_BASE_SHA" ]; then + echo "Merge group HEAD~1: $PARENT_SHA" + if [ "$PARENT_SHA" == "$PR_BASE_SHA" ]; then echo "skip=true" >> "$GITHUB_OUTPUT" - echo "Merge group base matches PR base — PR build already validated this, skipping." + echo "First in queue, same base — PR build already validated this, skipping." else echo "skip=false" >> "$GITHUB_OUTPUT" - echo "Merge group base differs from PR base — other PRs ahead or base moved, build needed." + echo "Other PRs ahead or base moved — build needed." fi - name: Configure AWS Credentials if: steps.queue-check.outputs.skip != 'true'