1+ # This workflow is provided via the organization template repository
2+ #
3+ # https://github.com/nextcloud/.github
4+ # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+ #
6+ # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
7+ # SPDX-License-Identifier: MIT
8+
19name : Cypress
210
3- on :
4- pull_request :
5- push :
6- branches :
7- - master
8- - stable*
11+ on : pull_request
12+
13+ concurrency :
14+ group : cypress-${{ github.head_ref || github.run_id }}
15+ cancel-in-progress : true
916
1017env :
11- APP_NAME : photos
12- BRANCH : ${{ github.base_ref }}
18+ # Adjust APP_NAME if your repository name is different
19+ APP_NAME : ${{ github.event.repository.name }}
20+
21+ # This represents the server branch to checkout.
22+ # Usually it's the base branch of the PR, but for pushes it's the branch itself.
23+ # e.g. 'main', 'stable27' or 'feature/my-feature'
24+ # n.b. server will use head_ref, as we want to test the PR branch.
25+ BRANCH : ${{ github.base_ref || github.ref_name }}
1326
1427jobs :
1528 init :
1629 runs-on : ubuntu-latest
30+ outputs :
31+ nodeVersion : ${{ steps.versions.outputs.nodeVersion }}
32+ npmVersion : ${{ steps.versions.outputs.npmVersion }}
33+
34+ env :
35+ PUPPETEER_SKIP_DOWNLOAD : true
1736
1837 steps :
38+ - name : Disabled on forks
39+ if : ${{ github.event.pull_request.head.repo.full_name != github.repository }}
40+ run : |
41+ echo 'Can not run cypress on forks'
42+ exit 1
43+
1944 - name : Checkout app
20- uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
45+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46+ with :
47+ persist-credentials : false
2148
22- - name : Install server dependencies
23- run : composer install
49+ - name : Check composer.json
50+ id : check_composer
51+ uses : andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
52+ with :
53+ files : " composer.json"
54+
55+ - name : Install composer dependencies
56+ if : steps.check_composer.outputs.files_exists == 'true'
57+ run : composer install --no-dev
2458
2559 - name : Read package.json node and npm engines version
26- uses : skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
60+ uses : skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
2761 id : versions
2862 with :
29- fallbackNode : " ^14 "
30- fallbackNpm : " ^7 "
63+ fallbackNode : " ^20 "
64+ fallbackNpm : " ^10 "
3165
3266 - name : Set up node ${{ steps.versions.outputs.nodeVersion }}
33- uses : actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
67+ uses : actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
3468 with :
35- cache : " npm"
3669 node-version : ${{ steps.versions.outputs.nodeVersion }}
3770
3871 - name : Set up npm ${{ steps.versions.outputs.npmVersion }}
39- run : npm i -g npm@" ${{ steps.versions.outputs.npmVersion }}"
72+ run : npm i -g ' npm@${{ steps.versions.outputs.npmVersion }}'
4073
4174 - name : Install node dependencies & build app
4275 run : |
4376 npm ci
4477 TESTING=true npm run build --if-present
78+
4579 - name : Save context
46- uses : actions /cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
80+ uses : buildjet /cache/save@v4
4781 with :
4882 key : cypress-context-${{ github.run_id }}
4983 path : ./
@@ -55,37 +89,39 @@ jobs:
5589 strategy :
5690 fail-fast : false
5791 matrix :
58- # run multiple copies of the current job in parallel
59- containers : ["component", 1, 2]
92+ # Run multiple copies of the current job in parallel
93+ # Please increase the number or runners as your tests suite grows
94+ containers : ['1', '2', '3']
6095
6196 name : runner ${{ matrix.containers }}
6297
6398 steps :
6499 - name : Restore context
65- uses : actions /cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
100+ uses : buildjet /cache/restore@v4
66101 with :
67102 fail-on-cache-miss : true
68103 key : cypress-context-${{ github.run_id }}
69104 path : ./
70105
71106 - name : Set up node ${{ needs.init.outputs.nodeVersion }}
72- uses : actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
107+ uses : actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
73108 with :
74- cache : " npm"
75109 node-version : ${{ needs.init.outputs.nodeVersion }}
76110
77111 - name : Set up npm ${{ needs.init.outputs.npmVersion }}
78- run : npm i -g npm@" ${{ needs.init.outputs.npmVersion }}"
112+ run : npm i -g ' npm@${{ needs.init.outputs.npmVersion }}'
79113
80114 - name : Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
81-
82- uses : cypress-io/github-action@db1693016f23ccf9043f4b2428f9b04e5d502a73 # v5.8.1
115+ uses : cypress-io/github-action@57b70560982e6a11d23d4b8bec7f8a487cdbb71b # v6.7.8
83116 with :
84- record : true
85- parallel : true
117+ record : ${{ secrets.CYPRESS_RECORD_KEY && true }}
118+ parallel : ${{ secrets.CYPRESS_RECORD_KEY && true }}
119+ # cypress run type
120+ component : ${{ matrix.containers == 'component' }}
121+ group : ${{ secrets.CYPRESS_RECORD_KEY && env.CYPRESS_GROUP }}
86122 # cypress env
87- ci-build-id : ${{ github.sha }}-${{ github.run_number }}
88- tag : ${{ github.event_name }}
123+ ci-build-id : ${{ secrets.CYPRESS_RECORD_KEY && env.CYPRESS_BUILD_ID }}
124+ tag : ${{ secrets.CYPRESS_RECORD_KEY && github.event_name }}
89125 env :
90126 # Needs to be prefixed with CYPRESS_
91127 CYPRESS_BRANCH : ${{ env.BRANCH }}
@@ -95,27 +131,29 @@ jobs:
95131 TESTING : true
96132 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
97133 CYPRESS_RECORD_KEY : ${{ secrets.CYPRESS_RECORD_KEY }}
134+ CYPRESS_BUILD_ID : ${{ github.sha }}-${{ github.run_number }}
135+ CYPRESS_GROUP : Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
98136
99137 - name : Upload snapshots
100- uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
138+ uses : actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
101139 if : always()
102140 with :
103141 name : snapshots_${{ matrix.containers }}
104142 path : cypress/snapshots
105143
106144 - name : Extract NC logs
107- if : always()
108- run : docker-compose --project-directory cypress logs > nextcloud.log
145+ if : failure() && matrix.containers != 'component'
146+ run : docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
109147
110148 - name : Upload NC logs
111- uses : actions/upload-artifact@v3
112- if : always()
149+ uses : actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
150+ if : failure() && matrix.containers != 'component'
113151 with :
114152 name : nc_logs_${{ matrix.containers }}
115153 path : nextcloud.log
116154
117155 summary :
118- runs-on : ubuntu-latest
156+ runs-on : ubuntu-latest-low
119157 needs : [init, cypress]
120158
121159 if : always()
0 commit comments