88
99name : Cypress
1010
11- on : pull_request
11+ on :
12+ pull_request :
13+ types :
14+ - opened
15+ - synchronize
16+ - reopened
17+ - ready_for_review
18+ - labeled
19+ - unlabeled
20+ pull_request_review :
21+ types :
22+ - submitted
23+ - dismissed
1224
1325concurrency :
1426 group : cypress-${{ github.head_ref || github.run_id }}
2234 # Usually it's the base branch of the PR, but for pushes it's the branch itself.
2335 # e.g. 'main', 'stable27' or 'feature/my-feature'
2436 # n.b. server will use head_ref, as we want to test the PR branch.
25- BRANCH : ${{ github.base_ref || github.ref_name }}
26-
37+ BRANCH : ${{ github.event.pull_request.base.ref || github.base_ref || github.ref_name }}
2738
2839permissions :
2940 contents : read
41+ pull-requests : read
3042
3143jobs :
44+ gate :
45+ runs-on : ubuntu-latest
46+ outputs :
47+ should_run : ${{ steps.evaluate.outputs.should_run }}
48+ reason : ${{ steps.evaluate.outputs.reason }}
49+ steps :
50+ - name : Evaluate e2e tests execution conditions
51+ id : evaluate
52+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
53+ with :
54+ script : |
55+ const pr = context.payload.pull_request
56+
57+ const hasSpecialLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
58+ const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
59+ const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
60+
61+ const files = await github.paginate(github.rest.pulls.listFiles, {
62+ owner: context.repo.owner,
63+ repo: context.repo.repo,
64+ pull_number: pr.number,
65+ per_page: 100,
66+ })
67+ const cypressTouched = files.some((file) => file.filename.startsWith('cypress'))
68+
69+ core.setOutput('should_run', String(hasSpecialLabel || hasToReviewLabel || hasToReleaseLabel || cypressTouched))
70+
3271 init :
3372 runs-on : ubuntu-latest
73+ needs : gate
74+ if : needs.gate.outputs.should_run == 'true'
3475 outputs :
3576 nodeVersion : ${{ steps.versions.outputs.nodeVersion }}
3677 npmVersion : ${{ steps.versions.outputs.npmVersion }}
5293 id : check_composer
5394 uses : andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
5495 with :
55- files : ' composer.json'
96+ files : " composer.json"
5697
5798 - name : Install composer dependencies
5899 if : steps.check_composer.outputs.files_exists == 'true'
62103 uses : skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
63104 id : versions
64105 with :
65- fallbackNode : ' ^24'
66- fallbackNpm : ' ^11.3'
106+ fallbackNode : " ^24"
107+ fallbackNpm : " ^11.3"
67108
68109 - name : Set up node ${{ steps.versions.outputs.nodeVersion }}
69110 uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -98,14 +139,15 @@ jobs:
98139
99140 cypress :
100141 runs-on : ubuntu-latest
101- needs : init
142+ needs : [gate, init]
143+ if : needs.gate.outputs.should_run == 'true'
102144
103145 strategy :
104146 fail-fast : false
105147 matrix :
106148 # Run multiple copies of the current job in parallel
107149 # Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
108- containers : [' setup', '0', '1', '2', '3', '4', '5', '6', '7' ]
150+ containers : [" setup", "0", "1", "2", "3", "4", "5", "6", "7" ]
109151 # Hack as strategy.job-total includes the "setup" and GitHub does not allow math expressions
110152 # Always align this number with the total of e2e runners (max. index + 1)
111153 total-containers : [8]
@@ -115,7 +157,7 @@ jobs:
115157 # Only start mysql if we are running the setup tests
116158 image : ${{matrix.containers == 'setup' && 'ghcr.io/nextcloud/continuous-integration-mysql-8.4:latest' || ''}} # zizmor: ignore[unpinned-images]
117159 ports :
118- - ' 3306/tcp'
160+ - " 3306/tcp"
119161 env :
120162 MYSQL_ROOT_PASSWORD : rootpassword
121163 MYSQL_USER : oc_autotest
@@ -127,7 +169,7 @@ jobs:
127169 # Only start mariadb if we are running the setup tests
128170 image : ${{matrix.containers == 'setup' && 'mariadb:11.4' || ''}} # zizmor: ignore[unpinned-images]
129171 ports :
130- - ' 3306/tcp'
172+ - " 3306/tcp"
131173 env :
132174 MYSQL_ROOT_PASSWORD : rootpassword
133175 MYSQL_USER : oc_autotest
@@ -139,7 +181,7 @@ jobs:
139181 # Only start postgres if we are running the setup tests
140182 image : ${{matrix.containers == 'setup' && 'ghcr.io/nextcloud/continuous-integration-postgres-17:latest' || ''}} # zizmor: ignore[unpinned-images]
141183 ports :
142- - ' 5432/tcp'
184+ - " 5432/tcp"
143185 env :
144186 POSTGRES_USER : root
145187 POSTGRES_PASSWORD : rootpassword
@@ -150,10 +192,10 @@ jobs:
150192 # Only start oracle if we are running the setup tests
151193 image : ${{matrix.containers == 'setup' && 'ghcr.io/gvenzl/oracle-free:23' || ''}} # zizmor: ignore[unpinned-images]
152194 ports :
153- - ' 1521'
195+ - " 1521"
154196 env :
155197 ORACLE_PASSWORD : oracle
156- options : --health-cmd healthcheck.sh --health-interval 20s --health-timeout 10s --health-retries 10
198+ options : --health-cmd healthcheck.sh --health-interval 20s --health-timeout 10s --health-retries 10
157199
158200 name : runner ${{ matrix.containers }}
159201
@@ -178,7 +220,7 @@ jobs:
178220 if : steps.cache.outputs.cache-hit != 'true'
179221 uses : andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
180222 with :
181- files : ' composer.json'
223+ files : " composer.json"
182224
183225 - name : Install composer dependencies
184226 if : steps.check_composer.outputs.files_exists == 'true' && steps.cache.outputs.cache-hit != 'true'
@@ -252,9 +294,9 @@ jobs:
252294
253295 summary :
254296 runs-on : ubuntu-latest-low
255- needs : [init, cypress]
297+ needs : [gate, init, cypress]
256298
257- if : always()
299+ if : always() && needs.gate.outputs.should_run == 'true'
258300
259301 name : cypress-summary
260302
0 commit comments