Scheduling infrastructure for absolutely everyone.
chore: streamline ready-for-e2e label check for PRs (#15545)
Keith Williams47a8ba1eaac3
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.ymlindex a2895b1b2ef..698f03458fa 100644--- a/.github/workflows/pr.yml+++ b/.github/workflows/pr.yml@@ -41,71 +41,75 @@ jobs:name: Check for E2E labeloutputs:run-e2e: ${{ steps.check-if-pr-has-label.outputs.run-e2e == 'true' && (github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'ready-for-e2e')) }}- run-jobs: ${{ github.event.action != 'labeled' }}steps:- name: Check if PR exists with ready-for-e2e label for this SHAid: check-if-pr-has-labeluses: actions/github-script@v7with:script: |- console.log('github.event.action', '${{ github.event.action }}');- try {- const sha = '${{ needs.changes.outputs.commit-sha }}';- console.log('sha', sha);- const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({- owner: context.repo.owner,- repo: context.repo.repo,- commit_sha: sha- });-- if (prs.length === 0) {+ let labels = [];++ if (context.payload.pull_request) {+ labels = context.payload.pull_request.labels;+ } else {+ try {+ const sha = '${{ needs.changes.outputs.commit-sha }}';+ console.log('sha', sha);+ const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({+ owner: context.repo.owner,+ repo: context.repo.repo,+ commit_sha: sha+ });++ if (prs.length === 0) {+ core.setOutput('run-e2e', false);+ console.log(`No pull requests found for commit SHA ${sha}`);+ return;+ }++ const pr = prs[0];+ console.log(`PR number: ${pr.number}`);+ console.log(`PR title: ${pr.title}`);+ console.log(`PR state: ${pr.state}`);+ console.log(`PR URL: ${pr.html_url}`);++ labels = pr.labels;+ }+ catch (e) {core.setOutput('run-e2e', false);- console.log(`No pull requests found for commit SHA ${sha}`);- return;+ console.log(e);}-- const pr = prs[0];- console.log(`PR number: ${pr.number}`);- console.log(`PR title: ${pr.title}`);- console.log(`PR state: ${pr.state}`);- console.log(`PR URL: ${pr.html_url}`);-- const labels = pr.labels.map(label => label.name);- const labelFound = labels.includes('ready-for-e2e');- console.log('PR #', pr.number);- console.log('Found the label?', labelFound);- core.setOutput('run-e2e', labelFound);- }- catch (e) {- core.setOutput('run-e2e', false);- console.log(e);}+ const labelFound = labels.map(l => l.name).includes('ready-for-e2e');+ console.log('Found the label?', labelFound);+ core.setOutput('run-e2e', labelFound);+type-check:name: Type checkneeds: [changes, check-label]- if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}+ if: ${{ github.event.action != 'labeled' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}uses: ./.github/workflows/check-types.ymlsecrets: inheritlint:name: Lintersneeds: [changes, check-label]- if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}+ if: ${{ github.event.action != 'labeled' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}uses: ./.github/workflows/lint.ymlsecrets: inheritunit-test:name: Testsneeds: [changes, check-label]- if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}+ if: ${{ github.event.action != 'labeled' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}uses: ./.github/workflows/unit-tests.ymlsecrets: inheritintegration-test:name: Testsneeds: [changes, check-label]- if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}+ if: ${{ github.event.action != 'labeled' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}uses: ./.github/workflows/integration-tests.ymlsecrets: inherit@@ -166,7 +170,6 @@ jobs:required:needs: [changes, lint, type-check, unit-test, integration-test, check-label, build, build-api-v1, build-api-v2, e2e, e2e-embed, e2e-embed-react, e2e-app-store]- if: ${{ needs.check-label.outputs.run-e2e == 'true' }}runs-on: buildjet-2vcpu-ubuntu-2204steps:- name: fail if conditional jobs failed