Skip to content

Scheduling infrastructure for absolutely everyone.

ci: make E2E report jobs non-blocking by moving to separate workflow (#26157)

Keith Williams9256d306b9c7
diff --git a/.github/workflows/e2e-report.yml b/.github/workflows/e2e-report.yml
new file mode 100644
index 00000000000..b2f351934fb
--- /dev/null
+++ b/.github/workflows/e2e-report.yml
@@ -0,0 +1,208 @@
+name: E2E Report
+
+on:
+ workflow_run:
+ workflows: ["PR Update"]
+ types:
+ - completed
+ workflow_dispatch:
+ inputs:
+ pr_number:
+ description: 'The PR number to generate report for'
+ required: true
+ type: string
+
+jobs:
+ get-pr-info:
+ name: Get PR Info
+ runs-on: ubuntu-latest
+ # For workflow_run: only run if the triggering workflow failed
+ # For workflow_dispatch: always run (inputs are provided manually)
+ if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'failure' }}
+ permissions:
+ actions: read
+ pull-requests: read
+ outputs:
+ pr-number: ${{ steps.get-info.outputs.pr-number }}
+ head-branch: ${{ steps.get-info.outputs.head-branch }}
+ has-blob-reports: ${{ steps.get-info.outputs.has-blob-reports }}
+ source-run-id: ${{ steps.get-info.outputs.source-run-id }}
+ source-run-number: ${{ steps.get-info.outputs.source-run-number }}
+ source-run-attempt: ${{ steps.get-info.outputs.source-run-attempt }}
+ source-head-sha: ${{ steps.get-info.outputs.source-head-sha }}
+ steps:
+ - name: Get PR and run info
+ id: get-info
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const isDispatch = context.eventName === 'workflow_dispatch';
+
+ if (isDispatch) {
+ // For workflow_dispatch: look up everything from PR number
+ const prNumber = context.payload.inputs.pr_number;
+ console.log('Looking up PR:', prNumber);
+
+ // Get PR details
+ const { data: pr } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: parseInt(prNumber)
+ });
+
+ const headSha = pr.head.sha;
+ const headBranch = pr.head.ref;
+ console.log('PR head SHA:', headSha);
+ console.log('PR head branch:', headBranch);
+
+ // Find the "PR Update" workflow
+ const { data: workflows } = await github.rest.actions.listRepoWorkflows({
+ owner: context.repo.owner,
+ repo: context.repo.repo
+ });
+ const prUpdateWorkflow = workflows.workflows.find(w => w.name === 'PR Update');
+ if (!prUpdateWorkflow) {
+ core.setFailed('Could not find "PR Update" workflow');
+ return;
+ }
+ console.log('Found PR Update workflow ID:', prUpdateWorkflow.id);
+
+ // Find the most recent run for this SHA with blob-report artifacts
+ const { data: runs } = await github.rest.actions.listWorkflowRuns({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ workflow_id: prUpdateWorkflow.id,
+ head_sha: headSha,
+ per_page: 10
+ });
+
+ console.log('Found', runs.workflow_runs.length, 'runs for SHA');
+
+ // Find a run with blob-report artifacts
+ let selectedRun = null;
+ let hasBlobReports = false;
+
+ for (const run of runs.workflow_runs) {
+ console.log('Checking run', run.id, 'status:', run.status, 'conclusion:', run.conclusion);
+
+ const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ run_id: run.id
+ });
+
+ const blobReports = artifacts.artifacts.filter(a => a.name.startsWith('blob-report-'));
+ if (blobReports.length > 0) {
+ console.log('Found run with blob reports:', run.id, 'artifacts:', blobReports.map(a => a.name));
+ selectedRun = run;
+ hasBlobReports = true;
+ break;
+ }
+ }
+
+ if (!selectedRun) {
+ console.log('No runs found with blob-report artifacts');
+ core.setOutput('pr-number', prNumber);
+ core.setOutput('head-branch', headBranch);
+ core.setOutput('source-head-sha', headSha);
+ core.setOutput('has-blob-reports', 'false');
+ core.setOutput('source-run-id', '');
+ core.setOutput('source-run-number', '');
+ core.setOutput('source-run-attempt', '');
+ return;
+ }
+
+ core.setOutput('pr-number', prNumber);
+ core.setOutput('head-branch', headBranch);
+ core.setOutput('source-head-sha', headSha);
+ core.setOutput('source-run-id', selectedRun.id.toString());
+ core.setOutput('source-run-number', selectedRun.run_number.toString());
+ core.setOutput('source-run-attempt', selectedRun.run_attempt.toString());
+ core.setOutput('has-blob-reports', 'true');
+ return;
+ }
+
+ // For workflow_run: extract from payload
+ const workflowRun = context.payload.workflow_run;
+ const headSha = workflowRun.head_sha;
+ const headBranch = workflowRun.head_branch;
+
+ console.log('Head SHA:', headSha);
+ console.log('Head Branch:', headBranch);
+
+ // Set source run info
+ core.setOutput('source-run-id', workflowRun.id.toString());
+ core.setOutput('source-run-number', workflowRun.run_number.toString());
+ core.setOutput('source-run-attempt', workflowRun.run_attempt.toString());
+ core.setOutput('source-head-sha', headSha);
+
+ // Check for blob report artifacts
+ const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ run_id: workflowRun.id
+ });
+
+ const blobReports = artifacts.artifacts.filter(a => a.name.startsWith('blob-report-'));
+ console.log('Found blob reports:', blobReports.map(a => a.name));
+ core.setOutput('has-blob-reports', blobReports.length > 0 ? 'true' : 'false');
+
+ // Try to get PR number from workflow_run payload first
+ if (workflowRun.pull_requests && workflowRun.pull_requests.length > 0) {
+ const prNumber = workflowRun.pull_requests[0].number;
+ console.log('PR number from payload:', prNumber);
+ core.setOutput('pr-number', prNumber.toString());
+ core.setOutput('head-branch', headBranch);
+ return;
+ }
+
+ // Fall back to API lookup
+ try {
+ const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ commit_sha: headSha
+ });
+
+ if (prs.length === 0) {
+ console.log('No PRs found for commit');
+ core.setOutput('pr-number', '');
+ core.setOutput('head-branch', headBranch);
+ return;
+ }
+
+ // Find open PR or use first one
+ const openPr = prs.find(pr => pr.state === 'open') || prs[0];
+ console.log('PR number from API:', openPr.number);
+ core.setOutput('pr-number', openPr.number.toString());
+ core.setOutput('head-branch', openPr.head.ref);
+ } catch (e) {
+ console.log('Error fetching PR:', e);
+ core.setOutput('pr-number', '');
+ core.setOutput('head-branch', headBranch);
+ }
+
+ merge-reports:
+ name: Merge reports
+ needs: [get-pr-info]
+ if: ${{ needs.get-pr-info.outputs.has-blob-reports == 'true' && needs.get-pr-info.outputs.pr-number != '' }}
+ uses: ./.github/workflows/merge-reports.yml
+ with:
+ source_run_id: ${{ needs.get-pr-info.outputs.source-run-id }}
+ source_run_number: ${{ needs.get-pr-info.outputs.source-run-number }}
+ source_run_attempt: ${{ needs.get-pr-info.outputs.source-run-attempt }}
+ source_head_sha: ${{ needs.get-pr-info.outputs.source-head-sha }}
+ # No secrets: inherit - merge-reports only needs the default GITHUB_TOKEN for artifact download
+
+ publish-report:
+ name: Publish HTML report
+ needs: [get-pr-info, merge-reports]
+ if: ${{ needs.get-pr-info.outputs.pr-number != '' }}
+ uses: ./.github/workflows/publish-report.yml
+ with:
+ head_branch: ${{ needs.get-pr-info.outputs.head-branch }}
+ source_run_id: ${{ needs.get-pr-info.outputs.source-run-id }}
+ source_run_number: ${{ needs.get-pr-info.outputs.source-run-number }}
+ source_run_attempt: ${{ needs.get-pr-info.outputs.source-run-attempt }}
+ pr_number: ${{ needs.get-pr-info.outputs.pr-number }}
+ secrets: inherit
diff --git a/.github/workflows/merge-reports.yml b/.github/workflows/merge-reports.yml
index 7eab9cd5470..5c76bb9a0ed 100644
--- a/.github/workflows/merge-reports.yml
+++ b/.github/workflows/merge-reports.yml
@@ -1,17 +1,37 @@
# https://playwright.dev/docs/test-sharding#merging-reports-from-multiple-shards
on:
workflow_call:
+ inputs:
+ source_run_id:
+ description: 'The run ID to download artifacts from (for workflow_run triggered calls)'
+ required: true
+ type: string
+ source_run_number:
+ description: 'The run number for artifact naming'
+ required: true
+ type: string
+ source_run_attempt:
+ description: 'The run attempt for artifact naming'
+ required: true
+ type: string
+ source_head_sha:
+ description: 'The head SHA to checkout for Playwright version consistency'
+ required: true
+ type: string
jobs:
merge-reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: ./.github/actions/dangerous-git-checkout
+ with:
+ ref: ${{ inputs.source_head_sha }}
- uses: ./.github/actions/yarn-install
- uses: ./.github/actions/yarn-playwright-install
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
+ run-id: ${{ inputs.source_run_id }}
+ github-token: ${{ github.token }}
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
@@ -20,6 +40,6 @@ jobs:
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
- name: html-report--attempt-${{ github.run_number }}-${{ github.run_attempt }}
+ name: html-report--attempt-${{ inputs.source_run_number }}-${{ inputs.source_run_attempt }}
path: playwright-report
retention-days: 14
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 652c087d059..0491d624d04 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -228,35 +228,6 @@ jobs:
uses: ./.github/workflows/nextjs-bundle-analysis.yml
secrets: inherit
- merge-reports:
- name: Merge reports
- if: ${{ !cancelled() && needs.prepare.outputs.run-e2e == 'true' && needs.prepare.outputs.has-files-requiring-all-checks == 'true' && (needs.e2e.result == 'failure' || needs.e2e-embed.result == 'failure' || needs.e2e-embed-react.result == 'failure' || needs.e2e-app-store.result == 'failure') }}
- needs: [prepare, e2e, e2e-embed, e2e-embed-react, e2e-app-store]
- uses: ./.github/workflows/merge-reports.yml
- secrets: inherit
-
- publish-report:
- name: Publish HTML report
- if: ${{ !cancelled() && needs.prepare.outputs.run-e2e == 'true' && needs.prepare.outputs.has-files-requiring-all-checks == 'true' && (needs.e2e.result == 'failure' || needs.e2e-embed.result == 'failure' || needs.e2e-embed-react.result == 'failure' || needs.e2e-app-store.result == 'failure') }}
- permissions:
- contents: write
- issues: write
- pull-requests: write
- needs: [prepare, merge-reports, e2e, e2e-embed, e2e-embed-react, e2e-app-store]
- uses: ./.github/workflows/publish-report.yml
- secrets: inherit
-
- cleanup-report:
- name: Cleanup HTML report
- if: ${{ !cancelled() && needs.prepare.outputs.run-e2e == 'true' && (github.event.pull_request.merged == true || github.event.pull_request.state == 'closed') }}
- permissions:
- contents: write
- issues: write
- pull-requests: write
- needs: [prepare, publish-report]
- uses: ./.github/workflows/cleanup-report.yml
- secrets: inherit
-
required:
needs:
[
diff --git a/.github/workflows/publish-report.yml b/.github/workflows/publish-report.yml
index f3af9ee335f..24134f5b488 100644
--- a/.github/workflows/publish-report.yml
+++ b/.github/workflows/publish-report.yml
@@ -1,5 +1,26 @@
on:
workflow_call:
+ inputs:
+ head_branch:
+ description: 'The head branch name for report path'
+ required: true
+ type: string
+ source_run_id:
+ description: 'The source run ID for report path'
+ required: true
+ type: string
+ source_run_number:
+ description: 'The source run number for artifact naming and comment'
+ required: true
+ type: string
+ source_run_attempt:
+ description: 'The source run attempt for artifact naming and comment'
+ required: true
+ type: string
+ pr_number:
+ description: 'The PR number to post comment on'
+ required: true
+ type: string
permissions:
contents: write
issues: write
@@ -10,8 +31,8 @@ jobs:
continue-on-error: true
env:
# Unique URL path for each workflow run attempt
- HTML_REPORT_URL_PATH: reports/${{ github.head_ref }}/${{ github.run_id }}/${{ github.run_attempt }}
- BRANCH_REPORTS_DIR: reports/${{ github.head_ref }}
+ HTML_REPORT_URL_PATH: reports/${{ inputs.head_branch }}/${{ inputs.source_run_id }}/${{ inputs.source_run_attempt }}
+ BRANCH_REPORTS_DIR: reports/${{ inputs.head_branch }}
steps:
- name: Generate GitHub App token
id: generate-token
@@ -45,11 +66,11 @@ jobs:
run: |
rm -rf $BRANCH_REPORTS_DIR
git add .
- git commit -m "workflow: remove all reports for branch ${{ github.head_ref }}"
+ git commit -m "workflow: remove all reports for branch ${{ inputs.head_branch }}"
- name: Download zipped HTML report
uses: actions/download-artifact@v4
with:
- name: html-report--attempt-${{ github.run_number }}-${{ github.run_attempt }}
+ name: html-report--attempt-${{ inputs.source_run_number }}-${{ inputs.source_run_attempt }}
path: ${{ env.HTML_REPORT_URL_PATH }}
- name: Push HTML Report
timeout-minutes: 3
@@ -57,7 +78,7 @@ jobs:
# this is necessary when this job running at least twice at the same time (e.g. through two pushes at the same time)
run: |
git add .
- git commit -m "workflow: add HTML report for run-id ${{ github.run_id }} (attempt: ${{ github.run_attempt }})"
+ git commit -m "workflow: add HTML report for run-id ${{ inputs.source_run_id }} (attempt: ${{ inputs.source_run_attempt }})"
while true; do
git pull --rebase
@@ -82,18 +103,18 @@ jobs:
uses: peter-evans/find-comment@v2
id: fc
with:
- issue-number: ${{ github.event.pull_request.number }}
+ issue-number: ${{ inputs.pr_number }}
comment-author: "github-actions[bot]"
body-includes: <!-- GENERATED-E2E-RESULTS -->
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
with:
- issue-number: ${{ github.event.pull_request.number }}
+ issue-number: ${{ inputs.pr_number }}
body: |
<!-- GENERATED-E2E-RESULTS -->
## E2E results are ready!
- - [Workflow #${{ github.run_number }}.${{ github.run_attempt }} latest results](${{ steps.url.outputs.link }})
+ - [Workflow #${{ inputs.source_run_number }}.${{ inputs.source_run_attempt }} latest results](${{ steps.url.outputs.link }})
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
@@ -103,4 +124,4 @@ jobs:
body: |
<!-- GENERATED-E2E-RESULTS -->
## E2E results are ready!
- - [Workflow #${{ github.run_number }}.${{ github.run_attempt }} latest results](${{ steps.url.outputs.link }})
+ - [Workflow #${{ inputs.source_run_number }}.${{ inputs.source_run_attempt }} latest results](${{ steps.url.outputs.link }})