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
1220
1321concurrency :
1422 group : cypress-${{ github.head_ref || github.run_id }}
2432 # n.b. server will use head_ref, as we want to test the PR branch.
2533 BRANCH : ${{ github.base_ref || github.ref_name }}
2634
27-
2835permissions :
2936 contents : read
37+ pull-requests : read
3038
3139jobs :
40+ gate :
41+ runs-on : ubuntu-latest-low
42+ outputs :
43+ should_run : ${{ steps.evaluate.outputs.should_run }}
44+ reason : ${{ steps.evaluate.outputs.reason }}
45+ steps :
46+ - name : Evaluate e2e tests execution conditions
47+ id : evaluate
48+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
49+ with :
50+ script : |
51+ const pr = context.payload.pull_request
52+
53+ const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
54+ const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
55+ const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
56+
57+ const files = await github.paginate(github.rest.pulls.listFiles, {
58+ owner: context.repo.owner,
59+ repo: context.repo.repo,
60+ pull_number: pr.number,
61+ per_page: 100,
62+ })
63+ const cypressTouched = files.some((file) => file.filename.startsWith('cypress'))
64+
65+ if (pr.draft || !(hasForceLabel || hasToReviewLabel || hasToReleaseLabel || cypressTouched)) {
66+ core.setFailed('Skipping Cypress: draft state, missing labels or no cypress path changes.')
67+ } else {
68+ return
69+ }
70+
3271 init :
3372 runs-on : ubuntu-latest
73+ needs : gate
3474 outputs :
3575 nodeVersion : ${{ steps.versions.outputs.nodeVersion }}
3676 npmVersion : ${{ steps.versions.outputs.npmVersion }}
5292 id : check_composer
5393 uses : andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
5494 with :
55- files : ' composer.json'
95+ files : " composer.json"
5696
5797 - name : Install composer dependencies
5898 if : steps.check_composer.outputs.files_exists == 'true'
62102 uses : skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
63103 id : versions
64104 with :
65- fallbackNode : ' ^24'
66- fallbackNpm : ' ^11.3'
105+ fallbackNode : " ^24"
106+ fallbackNpm : " ^11.3"
67107
68108 - name : Set up node ${{ steps.versions.outputs.nodeVersion }}
69109 uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -98,14 +138,14 @@ jobs:
98138
99139 cypress :
100140 runs-on : ubuntu-latest
101- needs : init
141+ needs : [gate, init]
102142
103143 strategy :
104144 fail-fast : false
105145 matrix :
106146 # Run multiple copies of the current job in parallel
107147 # 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' ]
148+ containers : [" setup", "0", "1", "2", "3", "4", "5", "6" ]
109149 # Hack as strategy.job-total includes the "setup" and GitHub does not allow math expressions
110150 # Always align this number with the total of e2e runners (max. index + 1)
111151 total-containers : [7]
@@ -115,7 +155,7 @@ jobs:
115155 # Only start mysql if we are running the setup tests
116156 image : ${{matrix.containers == 'setup' && 'ghcr.io/nextcloud/continuous-integration-mysql-8.4:latest' || ''}} # zizmor: ignore[unpinned-images]
117157 ports :
118- - ' 3306/tcp'
158+ - " 3306/tcp"
119159 env :
120160 MYSQL_ROOT_PASSWORD : rootpassword
121161 MYSQL_USER : oc_autotest
@@ -127,7 +167,7 @@ jobs:
127167 # Only start mariadb if we are running the setup tests
128168 image : ${{matrix.containers == 'setup' && 'mariadb:11.4' || ''}} # zizmor: ignore[unpinned-images]
129169 ports :
130- - ' 3306/tcp'
170+ - " 3306/tcp"
131171 env :
132172 MYSQL_ROOT_PASSWORD : rootpassword
133173 MYSQL_USER : oc_autotest
@@ -139,7 +179,7 @@ jobs:
139179 # Only start postgres if we are running the setup tests
140180 image : ${{matrix.containers == 'setup' && 'ghcr.io/nextcloud/continuous-integration-postgres-17:latest' || ''}} # zizmor: ignore[unpinned-images]
141181 ports :
142- - ' 5432/tcp'
182+ - " 5432/tcp"
143183 env :
144184 POSTGRES_USER : root
145185 POSTGRES_PASSWORD : rootpassword
@@ -150,10 +190,10 @@ jobs:
150190 # Only start oracle if we are running the setup tests
151191 image : ${{matrix.containers == 'setup' && 'ghcr.io/gvenzl/oracle-free:23' || ''}} # zizmor: ignore[unpinned-images]
152192 ports :
153- - ' 1521'
193+ - " 1521"
154194 env :
155195 ORACLE_PASSWORD : oracle
156- options : --health-cmd healthcheck.sh --health-interval 20s --health-timeout 10s --health-retries 10
196+ options : --health-cmd healthcheck.sh --health-interval 20s --health-timeout 10s --health-retries 10
157197
158198 name : runner ${{ matrix.containers }}
159199
@@ -178,7 +218,7 @@ jobs:
178218 if : steps.cache.outputs.cache-hit != 'true'
179219 uses : andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
180220 with :
181- files : ' composer.json'
221+ files : " composer.json"
182222
183223 - name : Install composer dependencies
184224 if : steps.check_composer.outputs.files_exists == 'true' && steps.cache.outputs.cache-hit != 'true'
0 commit comments