@@ -5,16 +5,54 @@ name: Playwright Tests
55
66on :
77 pull_request :
8- branches : [ master ]
8+ branches : [master]
9+ types :
10+ - opened
11+ - synchronize
12+ - reopened
13+ - ready_for_review
14+ - labeled
915
1016permissions :
1117 contents : read
1218
1319jobs :
20+ gate :
21+ runs-on : ubuntu-latest-low
22+ outputs :
23+ should_run : ${{ steps.evaluate.outputs.should_run }}
24+ reason : ${{ steps.evaluate.outputs.reason }}
25+ steps :
26+ - name : Evaluate e2e tests execution conditions
27+ id : evaluate
28+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
29+ with :
30+ script : |
31+ const pr = context.payload.pull_request
32+
33+ const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
34+ const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
35+ const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
36+
37+ const files = await github.paginate(github.rest.pulls.listFiles, {
38+ owner: context.repo.owner,
39+ repo: context.repo.repo,
40+ pull_number: pr.number,
41+ per_page: 100,
42+ })
43+ const playwrightTouched = files.some((file) => file.filename.startsWith('tests/playwright'))
44+
45+ if (hasForceLabel || hasToReviewLabel || hasToReleaseLabel || playwrightTouched) {
46+ return
47+ } else {
48+ core.setFailed('Skipping Playwright: draft state, missing labels or no playwright path changes.')
49+ }
50+
1451 playwright-setup :
1552 timeout-minutes : 15
1653 name : Playwright setup
1754 runs-on : ubuntu-latest
55+ needs : gate
1856 steps :
1957 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2058 with :
4078 path : ./
4179
4280 playwright-tests :
43- needs : [playwright-setup]
81+ needs : [gate, playwright-setup]
4482 timeout-minutes : 60
4583 name : Playwright tests ${{ matrix.shardIndex }} / ${{ matrix.shardTotal }}
4684 runs-on : ubuntu-latest
@@ -115,7 +153,7 @@ jobs:
115153 merge-reports :
116154 # Merge reports after playwright-tests, even if some shards have failed
117155 if : ${{ !cancelled() }}
118- needs : [playwright-tests]
156+ needs : [gate, playwright-tests]
119157
120158 runs-on : ubuntu-latest-low
121159 steps :
@@ -171,7 +209,7 @@ jobs:
171209 permissions :
172210 contents : none
173211 runs-on : ubuntu-latest-low
174- needs : [playwright-tests]
212+ needs : [gate, playwright-tests]
175213
176214 if : always()
177215
0 commit comments