@@ -20,12 +20,52 @@ concurrency:
2020permissions : {}
2121
2222jobs :
23+ # Analyzes the list of files modified in a pull request to detect any changes that could
24+ # potentially impact E2E tests. A series of ignore patterns are used in place of an include
25+ # list to ensure tests run even if the list of filters happens to become stale.
26+ detect-relevant-changes :
27+ name : Detect changes relevant to E2E tests
28+ runs-on : ' ubuntu-24.04'
29+ timeout-minutes : 5
30+ permissions :
31+ pull-requests : read
32+ outputs :
33+ relevant : ${{ steps.filter.outputs.relevant }}
34+ steps :
35+ - name : Check for changes that may impact E2E test results
36+ id : filter
37+ if : ${{ github.event_name == 'pull_request' }}
38+ uses : dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
39+ with :
40+ predicate-quantifier : ' every'
41+ filters : |
42+ relevant:
43+ # Start from every file, then exclude what cannot change a test result.
44+ - '**'
45+ # Documentation.
46+ - '!**/*.md'
47+ - '!{backport-changelog,docs,phpunit,storybook}/**'
48+ # Other test suites, which cannot affect this one.
49+ - '!test/{integration,performance,php,storybook-playwright,unit}/**'
50+ - '!{packages,tools}/**/{test,tests}/**'
51+ # Development tooling and its configuration.
52+ - '!packages/{create-block,docgen,eslint-plugin,jest-*,npm-package-json-lint-config,prettier-config,project-management-automation,stylelint-config}/**'
53+ - '!tools/{docs,eslint,stylelint,validation}/**'
54+ - '!{eslint,lint-staged,prettier,syncpack}.config*'
55+ - '!{phpcs,phpunit}*'
56+ # Repository metadata.
57+ - '!{changelog,readme}.txt'
58+ - '!.{editorconfig,gitignore,prettierrc*,stylelintrc*}'
59+ # Other workflows, and everything under .github that this one does not use.
60+ - '!.github/{*,!(workflows|setup-node|setup-playwright)/**,workflows/!(end2end-test.yml)}'
61+
2362 build :
2463 name : Build
2564 runs-on : ${{ vars.RUNNERS_NAME || 'ubuntu-24.04' }}
65+ needs : [detect-relevant-changes]
2666 permissions :
2767 contents : read
28- if : ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
68+ if : ${{ ( github.repository == 'WordPress/gutenberg' && github.event_name != 'pull_request' ) || ( github.event_name == 'pull_request' && needs.detect-relevant-changes.outputs.relevant == 'true' ) }}
2969 timeout-minutes : 30
3070
3171 steps :
@@ -211,8 +251,13 @@ jobs:
211251
212252 merge-artifacts :
213253 name : Merge Artifacts
214- if : ${{ !cancelled() }}
215- needs : [e2e-playwright, e2e-playwright-rtc-websocket]
254+ if : ${{ ! cancelled() && ( github.event_name != 'pull_request' || needs.detect-relevant-changes.outputs.relevant == 'true' ) }}
255+ needs :
256+ [
257+ detect-relevant-changes,
258+ e2e-playwright,
259+ e2e-playwright-rtc-websocket,
260+ ]
216261 runs-on : ' ubuntu-24.04'
217262 permissions :
218263 contents : read
@@ -331,3 +376,41 @@ jobs:
331376 body-path : pr-meta/body.md
332377 commit-sha : ${{ github.event.pull_request.head.sha }}
333378 run-url : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
379+
380+ # Runs on every event so it can serve as the workflow's only required status check while the
381+ # preceding jobs are path-filtered away.
382+ #
383+ # GitHub Actions can only be configured as required status checks on a per job basis using the
384+ # job's `name`. When the `name` changes PRs are temporarily blocked from being merged until
385+ # a privileged user can update the status checks, a process which is also error prone.
386+ #
387+ # The script reads every job in the run, so `needs` is only about waiting: it must cover
388+ # every job that would otherwise still be running when the script looks. `--ignore` then
389+ # names the jobs whose results do not count. Here that is this job itself, and the
390+ # housekeeping that runs alongside it.
391+ e2e-status-check :
392+ name : End-to-End Tests - Status Check
393+ runs-on : ' ubuntu-24.04'
394+ timeout-minutes : 5
395+ permissions :
396+ contents : read
397+ actions : read
398+ needs :
399+ [
400+ detect-relevant-changes,
401+ e2e-playwright,
402+ e2e-playwright-rtc-websocket,
403+ ]
404+ if : ${{ ! cancelled() && ( github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' ) }}
405+ steps :
406+ - name : Checkout repository
407+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
408+ with :
409+ sparse-checkout : .github/workflows/scripts
410+ show-progress : ${{ runner.debug == '1' && 'true' || 'false' }}
411+ persist-credentials : false
412+
413+ - name : Check for any failures of required jobs
414+ env :
415+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
416+ run : node .github/workflows/scripts/ci-status-check.js --ignore 'End-to-End Tests - Status Check,Merge Artifacts,Update PR meta comment'
0 commit comments