Skip to content

Commit 16c7c07

Browse files
committed
chore: update cypress workflow from templates
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent 772aa81 commit 16c7c07

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

.github/workflows/cypress.yml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ on:
44
pull_request:
55
push:
66
branches:
7+
- main
78
- master
89
- stable*
910

1011
env:
11-
APP_NAME: server
12-
BRANCH: ${{ github.base_ref || github.ref_name }}
13-
TESTING: true
12+
# Adjust APP_NAME if your repository name is different
13+
APP_NAME: ${{ github.event.repository.name }}
14+
# Server requires head_ref instead of base_ref, as we want to test the PR branch
15+
BRANCH: ${{ github.head_ref || github.ref_name }}
1416

1517
jobs:
1618
init:
@@ -23,6 +25,16 @@ jobs:
2325
- name: Checkout app
2426
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2527

28+
- name: Check composer.json
29+
id: check_composer
30+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
31+
with:
32+
files: "composer.json"
33+
34+
- name: Install composer dependencies
35+
if: steps.check_composer.outputs.files_exists == 'true'
36+
run: composer install --no-dev
37+
2638
- name: Read package.json node and npm engines version
2739
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
2840
id: versions
@@ -33,19 +45,18 @@ jobs:
3345
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
3446
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
3547
with:
36-
cache: 'npm'
3748
node-version: ${{ steps.versions.outputs.nodeVersion }}
3849

3950
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
4051
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
4152

42-
- name: Install dependencies & build app
53+
- name: Install node dependencies & build app
4354
run: |
4455
npm ci
4556
TESTING=true npm run build --if-present
4657
4758
- name: Save context
48-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
59+
uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
4960
with:
5061
key: cypress-context-${{ github.run_id }}
5162
path: ./
@@ -57,14 +68,15 @@ jobs:
5768
strategy:
5869
fail-fast: false
5970
matrix:
60-
# run multiple copies of the current job in parallel
71+
# Run multiple copies of the current job in parallel
72+
# Please increase the number or runners as your tests suite grows
6173
containers: ["component", 1, 2]
6274

6375
name: runner ${{ matrix.containers }}
6476

6577
steps:
6678
- name: Restore context
67-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
79+
uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
6880
with:
6981
fail-on-cache-miss: true
7082
key: cypress-context-${{ github.run_id }}
@@ -73,13 +85,11 @@ jobs:
7385
- name: Set up node ${{ needs.init.outputs.nodeVersion }}
7486
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
7587
with:
76-
cache: 'npm'
7788
node-version: ${{ needs.init.outputs.nodeVersion }}
7889

7990
- name: Set up npm ${{ needs.init.outputs.npmVersion }}
8091
run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
8192

82-
8393
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
8494
uses: cypress-io/github-action@db1693016f23ccf9043f4b2428f9b04e5d502a73 # v5.8.1
8595
with:
@@ -90,7 +100,7 @@ jobs:
90100
group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
91101
# cypress env
92102
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
93-
tag: ${{ github.event_name }}t
103+
tag: ${{ github.event_name }}
94104
env:
95105
# Needs to be prefixed with CYPRESS_
96106
CYPRESS_BRANCH: ${{ env.BRANCH }}
@@ -101,9 +111,16 @@ jobs:
101111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102112
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
103113

114+
- name: Upload snapshots
115+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
116+
if: always()
117+
with:
118+
name: snapshots_${{ matrix.containers }}
119+
path: cypress/snapshots
120+
104121
- name: Extract NC logs
105122
if: failure() && matrix.containers != 'component'
106-
run: docker logs nextcloud-cypress-tests-server > nextcloud.log
123+
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
107124

108125
- name: Upload NC logs
109126
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2

0 commit comments

Comments
 (0)