@@ -5,16 +5,51 @@ 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+ steps :
23+ - name : Evaluate e2e tests execution conditions
24+ id : gate-e2e
25+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
26+ with :
27+ script : |
28+ const pr = context.payload.pull_request
29+
30+ const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
31+ const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
32+ const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
33+
34+ const files = await github.paginate(github.rest.pulls.listFiles, {
35+ owner: context.repo.owner,
36+ repo: context.repo.repo,
37+ pull_number: pr.number,
38+ per_page: 100,
39+ })
40+ const playwrightTouched = files.some((file) => file.filename.startsWith('tests/playwright'))
41+
42+ if (hasForceLabel || hasToReviewLabel || hasToReleaseLabel || playwrightTouched) {
43+ return
44+ } else {
45+ core.setFailed('Skipping Playwright: draft state, missing labels or no playwright path changes.')
46+ }
47+
1448 playwright-setup :
1549 timeout-minutes : 15
1650 name : Playwright setup
1751 runs-on : ubuntu-latest
52+ needs : gate
1853 steps :
1954 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2055 with :
4075 path : ./
4176
4277 playwright-tests :
43- needs : [playwright-setup]
78+ needs : [gate, playwright-setup]
4479 timeout-minutes : 60
4580 name : Playwright tests ${{ matrix.shardIndex }} / ${{ matrix.shardTotal }}
4681 runs-on : ubuntu-latest
@@ -115,7 +150,7 @@ jobs:
115150 merge-reports :
116151 # Merge reports after playwright-tests, even if some shards have failed
117152 if : ${{ !cancelled() }}
118- needs : [playwright-tests]
153+ needs : [gate, playwright-tests]
119154
120155 runs-on : ubuntu-latest-low
121156 steps :
@@ -171,7 +206,7 @@ jobs:
171206 permissions :
172207 contents : none
173208 runs-on : ubuntu-latest-low
174- needs : [playwright-tests]
209+ needs : [gate, playwright-tests]
175210
176211 if : always()
177212
0 commit comments