From 5e7003886555f35f770a3b0d33a81e2a012e5e28 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 17:50:57 +0000 Subject: [PATCH 1/9] Initial plan From 9b19bc8b5e8206196c458dc678e2e803b0af6d1a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 17:59:19 +0000 Subject: [PATCH 2/9] Add merge_group trigger support to status-checks workflow Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 53 ++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index ac109335cb9..754da32b6eb 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -3,6 +3,8 @@ name: status-checks on: pull_request: types: [labeled, opened, reopened, synchronize] + merge_group: + types: [checks_requested] permissions: pull-requests: write @@ -11,7 +13,7 @@ permissions: jobs: github-ui: runs-on: ubuntu-latest - if: "${{ contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') }}" + if: "${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') || github.event_name == 'merge_group' }}" steps: - name: Generate token for primer id: generate_primer_token @@ -22,16 +24,45 @@ jobs: private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }} - name: Override status checks run: | - # Get the timeline event ID for the label being added - EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \ - --jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \ - | tail -n 1) - - # Construct the HTML URL from the event ID - if [ -n "$EVENT_ID" ]; then - TARGET_URL="${{ github.event.pull_request.html_url }}#event-$EVENT_ID" + # Determine SHA and PR number based on event type + if [ "${{ github.event_name }}" = "pull_request" ]; then + SHA="${{ github.event.pull_request.head.sha }}" + PR_NUMBER="${{ github.event.pull_request.number }}" + HTML_URL="${{ github.event.pull_request.html_url }}" else - TARGET_URL="${{ github.event.pull_request.html_url }}" + # For merge_group, extract PR number from head_ref + # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 + SHA="${{ github.event.merge_group.head_sha }}" + PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/.*\/pr-\([0-9]*\)-.*/\1/p') + HTML_URL="https://github.com/primer/react/pull/$PR_NUMBER" + fi + + # For merge_group events, check if the PR has the required label + if [ "${{ github.event_name }}" = "merge_group" ]; then + HAS_LABEL=$(gh api "/repos/primer/react/issues/$PR_NUMBER" \ + --jq '[.labels[].name] | contains(["integration-tests: skipped manually"])') + + if [ "$HAS_LABEL" != "true" ]; then + echo "PR #$PR_NUMBER does not have the required label. Skipping status override." + exit 0 + fi + fi + + # Get the timeline event ID for the label being added (only for pull_request events) + if [ "${{ github.event_name }}" = "pull_request" ]; then + EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \ + --jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \ + | tail -n 1) + + # Construct the HTML URL from the event ID + if [ -n "$EVENT_ID" ]; then + TARGET_URL="${HTML_URL}#event-$EVENT_ID" + else + TARGET_URL="${HTML_URL}" + fi + else + # For merge_group, just use the PR URL + TARGET_URL="${HTML_URL}" fi gh api -X POST "/repos/primer/react/statuses/$SHA" \ @@ -47,5 +78,3 @@ jobs: -f target_url="$TARGET_URL" env: GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} - SHA: ${{ github.event.pull_request.head.sha }} - PR_NUMBER: ${{ github.event.pull_request.number }} From 8106a23252f463a367009ad542a3307be8b30143 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:00:41 +0000 Subject: [PATCH 3/9] Add branches filter to merge_group trigger for consistency Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index 754da32b6eb..0b07cd5d23b 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -4,6 +4,8 @@ on: pull_request: types: [labeled, opened, reopened, synchronize] merge_group: + branches: + - main types: [checks_requested] permissions: From 69388aace6ae95951b3a107a2ad4f9ce7e90bcc7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:02:02 +0000 Subject: [PATCH 4/9] Add validation for PR number extraction in merge_group events Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index 0b07cd5d23b..a749f0f9419 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -36,6 +36,13 @@ jobs: # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 SHA="${{ github.event.merge_group.head_sha }}" PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/.*\/pr-\([0-9]*\)-.*/\1/p') + + # Validate PR_NUMBER extraction + if [ -z "$PR_NUMBER" ]; then + echo "Error: Failed to extract PR number from head_ref: ${{ github.event.merge_group.head_ref }}" + exit 1 + fi + HTML_URL="https://github.com/primer/react/pull/$PR_NUMBER" fi From 01463527166996570c375f22756f0e78550aa276 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:03:56 +0000 Subject: [PATCH 5/9] Improve code quality: add parentheses, better regex, and use github.repository Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index a749f0f9419..34071c34092 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -15,7 +15,7 @@ permissions: jobs: github-ui: runs-on: ubuntu-latest - if: "${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') || github.event_name == 'merge_group' }}" + if: "${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually')) || github.event_name == 'merge_group' }}" steps: - name: Generate token for primer id: generate_primer_token @@ -35,7 +35,7 @@ jobs: # For merge_group, extract PR number from head_ref # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 SHA="${{ github.event.merge_group.head_sha }}" - PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/.*\/pr-\([0-9]*\)-.*/\1/p') + PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/^refs\/heads\/gh-readonly-queue\/[^\/]*\/pr-\([0-9]*\)-.*/\1/p') # Validate PR_NUMBER extraction if [ -z "$PR_NUMBER" ]; then @@ -43,7 +43,7 @@ jobs: exit 1 fi - HTML_URL="https://github.com/primer/react/pull/$PR_NUMBER" + HTML_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" fi # For merge_group events, check if the PR has the required label From 8c0dbfa3775d1d4e3ef7e28a4e0c5b20ffda5c8e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:16:21 +0000 Subject: [PATCH 6/9] Split into separate jobs for pull_request and merge_group Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 103 ++++++++++++++++------------ 1 file changed, 58 insertions(+), 45 deletions(-) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index 34071c34092..79a92298328 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -13,9 +13,9 @@ permissions: statuses: write jobs: - github-ui: + github-ui-pull-request: runs-on: ubuntu-latest - if: "${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually')) || github.event_name == 'merge_group' }}" + if: "${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') }}" steps: - name: Generate token for primer id: generate_primer_token @@ -26,61 +26,74 @@ jobs: private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }} - name: Override status checks run: | - # Determine SHA and PR number based on event type - if [ "${{ github.event_name }}" = "pull_request" ]; then - SHA="${{ github.event.pull_request.head.sha }}" - PR_NUMBER="${{ github.event.pull_request.number }}" - HTML_URL="${{ github.event.pull_request.html_url }}" + # Get the timeline event ID for the label being added + EVENT_ID=$(gh api "/repos/primer/react/issues/${{ github.event.pull_request.number }}/timeline" \ + --jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \ + | tail -n 1) + + # Construct the HTML URL from the event ID + if [ -n "$EVENT_ID" ]; then + TARGET_URL="${{ github.event.pull_request.html_url }}#event-$EVENT_ID" else - # For merge_group, extract PR number from head_ref - # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 - SHA="${{ github.event.merge_group.head_sha }}" - PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/^refs\/heads\/gh-readonly-queue\/[^\/]*\/pr-\([0-9]*\)-.*/\1/p') - - # Validate PR_NUMBER extraction - if [ -z "$PR_NUMBER" ]; then - echo "Error: Failed to extract PR number from head_ref: ${{ github.event.merge_group.head_ref }}" - exit 1 - fi - - HTML_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" + TARGET_URL="${{ github.event.pull_request.html_url }}" fi - # For merge_group events, check if the PR has the required label - if [ "${{ github.event_name }}" = "merge_group" ]; then - HAS_LABEL=$(gh api "/repos/primer/react/issues/$PR_NUMBER" \ - --jq '[.labels[].name] | contains(["integration-tests: skipped manually"])') - - if [ "$HAS_LABEL" != "true" ]; then - echo "PR #$PR_NUMBER does not have the required label. Skipping status override." - exit 0 - fi - fi + gh api -X POST "/repos/primer/react/statuses/${{ github.event.pull_request.head.sha }}" \ + -f state='success' \ + -f context='github-ui / ci' \ + -f description='Skipped' \ + -f target_url="$TARGET_URL" - # Get the timeline event ID for the label being added (only for pull_request events) - if [ "${{ github.event_name }}" = "pull_request" ]; then - EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \ - --jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \ - | tail -n 1) + gh api -X POST "/repos/primer/react/statuses/${{ github.event.pull_request.head.sha }}" \ + -f state='success' \ + -f context='github-ui / projects' \ + -f description='Skipped' \ + -f target_url="$TARGET_URL" + env: + GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} - # Construct the HTML URL from the event ID - if [ -n "$EVENT_ID" ]; then - TARGET_URL="${HTML_URL}#event-$EVENT_ID" - else - TARGET_URL="${HTML_URL}" - fi - else - # For merge_group, just use the PR URL - TARGET_URL="${HTML_URL}" + github-ui-merge-queue: + runs-on: ubuntu-latest + if: "${{ github.event_name == 'merge_group' }}" + steps: + - name: Generate token for primer + id: generate_primer_token + uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 + with: + app-id: 902635 + owner: 'primer' + private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }} + - name: Override status checks + run: | + # Extract PR number from head_ref + # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 + PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/^refs\/heads\/gh-readonly-queue\/[^\/]*\/pr-\([0-9]*\)-.*/\1/p') + + # Validate PR_NUMBER extraction + if [ -z "$PR_NUMBER" ]; then + echo "Error: Failed to extract PR number from head_ref: ${{ github.event.merge_group.head_ref }}" + exit 1 fi - gh api -X POST "/repos/primer/react/statuses/$SHA" \ + # Check if the PR has the required label + HAS_LABEL=$(gh api "/repos/primer/react/issues/$PR_NUMBER" \ + --jq '[.labels[].name] | contains(["integration-tests: skipped manually"])') + + if [ "$HAS_LABEL" != "true" ]; then + echo "PR #$PR_NUMBER does not have the required label. Skipping status override." + exit 0 + fi + + # Use the PR URL as the target URL + TARGET_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" + + gh api -X POST "/repos/primer/react/statuses/${{ github.event.merge_group.head_sha }}" \ -f state='success' \ -f context='github-ui / ci' \ -f description='Skipped' \ -f target_url="$TARGET_URL" - gh api -X POST "/repos/primer/react/statuses/$SHA" \ + gh api -X POST "/repos/primer/react/statuses/${{ github.event.merge_group.head_sha }}" \ -f state='success' \ -f context='github-ui / projects' \ -f description='Skipped' \ From 59048df184fc3d863871ca1b7824a3429bf089cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:23:31 +0000 Subject: [PATCH 7/9] Combine into single job with conditional steps Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index 79a92298328..6301527202f 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -13,9 +13,9 @@ permissions: statuses: write jobs: - github-ui-pull-request: + github-ui: runs-on: ubuntu-latest - if: "${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') }}" + if: "${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually')) || github.event_name == 'merge_group' }}" steps: - name: Generate token for primer id: generate_primer_token @@ -24,7 +24,8 @@ jobs: app-id: 902635 owner: 'primer' private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }} - - name: Override status checks + - name: Override status checks for pull request + if: "${{ github.event_name == 'pull_request' }}" run: | # Get the timeline event ID for the label being added EVENT_ID=$(gh api "/repos/primer/react/issues/${{ github.event.pull_request.number }}/timeline" \ @@ -51,19 +52,8 @@ jobs: -f target_url="$TARGET_URL" env: GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} - - github-ui-merge-queue: - runs-on: ubuntu-latest - if: "${{ github.event_name == 'merge_group' }}" - steps: - - name: Generate token for primer - id: generate_primer_token - uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 - with: - app-id: 902635 - owner: 'primer' - private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }} - - name: Override status checks + - name: Override status checks for merge queue + if: "${{ github.event_name == 'merge_group' }}" run: | # Extract PR number from head_ref # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 From f71e44b1262de3631a1796f009b5bd989d741198 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:36:18 +0000 Subject: [PATCH 8/9] Refactor to use env variables and remove label check for merge queue Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> --- .github/workflows/status-checks.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index 6301527202f..a828eca996f 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -28,7 +28,7 @@ jobs: if: "${{ github.event_name == 'pull_request' }}" run: | # Get the timeline event ID for the label being added - EVENT_ID=$(gh api "/repos/primer/react/issues/${{ github.event.pull_request.number }}/timeline" \ + EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \ --jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \ | tail -n 1) @@ -39,19 +39,21 @@ jobs: TARGET_URL="${{ github.event.pull_request.html_url }}" fi - gh api -X POST "/repos/primer/react/statuses/${{ github.event.pull_request.head.sha }}" \ + gh api -X POST "/repos/primer/react/statuses/$SHA" \ -f state='success' \ -f context='github-ui / ci' \ -f description='Skipped' \ -f target_url="$TARGET_URL" - gh api -X POST "/repos/primer/react/statuses/${{ github.event.pull_request.head.sha }}" \ + gh api -X POST "/repos/primer/react/statuses/$SHA" \ -f state='success' \ -f context='github-ui / projects' \ -f description='Skipped' \ -f target_url="$TARGET_URL" env: GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + SHA: ${{ github.event.pull_request.head.sha }} - name: Override status checks for merge queue if: "${{ github.event_name == 'merge_group' }}" run: | @@ -65,15 +67,6 @@ jobs: exit 1 fi - # Check if the PR has the required label - HAS_LABEL=$(gh api "/repos/primer/react/issues/$PR_NUMBER" \ - --jq '[.labels[].name] | contains(["integration-tests: skipped manually"])') - - if [ "$HAS_LABEL" != "true" ]; then - echo "PR #$PR_NUMBER does not have the required label. Skipping status override." - exit 0 - fi - # Use the PR URL as the target URL TARGET_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" From a453468a34e880dce2e8cbeecae0aa4a15be674b Mon Sep 17 00:00:00 2001 From: Josh Black Date: Mon, 10 Nov 2025 11:03:26 -0600 Subject: [PATCH 9/9] Remove PR details from merge group job --- .github/workflows/status-checks.yml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index a828eca996f..4c5f2dbe559 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -57,29 +57,14 @@ jobs: - name: Override status checks for merge queue if: "${{ github.event_name == 'merge_group' }}" run: | - # Extract PR number from head_ref - # Format: refs/heads/gh-readonly-queue/main/pr-123-abc123 - PR_NUMBER=$(echo "${{ github.event.merge_group.head_ref }}" | sed -n 's/^refs\/heads\/gh-readonly-queue\/[^\/]*\/pr-\([0-9]*\)-.*/\1/p') - - # Validate PR_NUMBER extraction - if [ -z "$PR_NUMBER" ]; then - echo "Error: Failed to extract PR number from head_ref: ${{ github.event.merge_group.head_ref }}" - exit 1 - fi - - # Use the PR URL as the target URL - TARGET_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" - gh api -X POST "/repos/primer/react/statuses/${{ github.event.merge_group.head_sha }}" \ -f state='success' \ -f context='github-ui / ci' \ - -f description='Skipped' \ - -f target_url="$TARGET_URL" + -f description='Skipped' gh api -X POST "/repos/primer/react/statuses/${{ github.event.merge_group.head_sha }}" \ -f state='success' \ -f context='github-ui / projects' \ - -f description='Skipped' \ - -f target_url="$TARGET_URL" + -f description='Skipped' env: GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }}