name: Trigger Full Suite on: pull_request_target: types: [labeled, synchronize] permissions: contents: read pull-requests: read actions: read concurrency: group: full-suite-${{ github.event.pull_request.number }} cancel-in-progress: false jobs: trigger: if: >- (github.event.action == 'labeled' && github.event.label.name == 'ready') || github.event.action == 'synchronize' runs-on: ubuntu-latest # Gate below may wait for cheap checks (up to MAX_WAIT_SECS = 25 min). timeout-minutes: 35 steps: - name: Check ready label id: check uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: | const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number, }); const hasReady = pr.labels.some(l => l.name === 'ready'); core.setOutput('has_ready', String(hasReady)); if (!hasReady) core.info('No ready label — skipping Full Suite trigger.'); - name: Cancel previous Buildkite builds if: steps.check.outputs.has_ready == 'true' env: BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_API_TOKEN }} PR_BRANCH: ${{ github.event.pull_request.head.ref }} run: | # Find running builds for this branch with TEST_SCOPE=full and cancel them builds=$(curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \ "https://api.buildkite.com/v2/organizations/${{ vars.BUILDKITE_ORG_SLUG }}/pipelines/${{ vars.BUILDKITE_PIPELINE_SLUG }}/builds?branch=${PR_BRANCH}&state=running,scheduled" \ | jq -r '.[] | select(try (.env.TEST_SCOPE == "full") catch false) | .number') for build_num in $builds; do echo "Cancelling Buildkite build #$build_num" curl -sS -X PUT -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \ "https://api.buildkite.com/v2/organizations/${{ vars.BUILDKITE_ORG_SLUG }}/pipelines/${{ vars.BUILDKITE_PIPELINE_SLUG }}/builds/${build_num}/cancel" done # Checks out the BASE branch (default for pull_request_target), so PR # authors cannot tamper with the gate script. - name: Checkout gate script if: steps.check.outputs.has_ready == 'true' uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Wait for pre-commit and docs build if: steps.check.outputs.has_ready == 'true' env: GH_TOKEN: ${{ github.token }} PR_SHA: ${{ github.event.pull_request.head.sha }} PR_NUMBER: ${{ github.event.pull_request.number }} run: bash .github/scripts/gate_full_suite.sh - name: Trigger Buildkite Full Suite if: steps.check.outputs.has_ready == 'true' env: BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_API_TOKEN }} PR_SHA: ${{ github.event.pull_request.head.sha }} PR_BRANCH: ${{ github.event.pull_request.head.ref }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_TITLE: ${{ github.event.pull_request.title }} BK_ORG: ${{ vars.BUILDKITE_ORG_SLUG }} BK_PIPELINE: ${{ vars.BUILDKITE_PIPELINE_SLUG }} run: | curl -sS --fail-with-body -X POST \ "https://api.buildkite.com/v2/organizations/${BK_ORG}/pipelines/${BK_PIPELINE}/builds" \ -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \ -H "Content-Type: application/json" \ --data-raw "$(jq -n \ --arg commit "$PR_SHA" \ --arg branch "$PR_BRANCH" \ --arg message "Full Suite for PR #${PR_NUMBER}" \ --arg pr_title "$PR_TITLE" \ --argjson pr_id "$PR_NUMBER" \ '{ commit: $commit, branch: $branch, message: $message, ignore_pipeline_branch_filters: true, pull_request_id: $pr_id, pull_request_base_branch: "main", env: { TEST_SCOPE: "full", FULL_SUITE: "true", PR_NUMBER: ($pr_id | tostring), PR_TITLE: $pr_title } }')"