Skip to content

Commit 5cf1a86

Browse files
committed
Re-enable cypress workflow
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent f6b1d97 commit 5cf1a86

2 files changed

Lines changed: 146 additions & 75 deletions

File tree

.github/workflows/cypress.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Cypress
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
- stable*
10+
11+
env:
12+
# Adjust APP_NAME if your repository name is different
13+
APP_NAME: ${{ github.event.repository.name }}
14+
15+
# This represents the server branch to checkout.
16+
# Usually it's the base branch of the PR, but for pushes it's the branch itself.
17+
# e.g. 'main', 'stable27' or 'feature/my-feature
18+
# n.b. server will use head_ref, as we want to test the PR branch.
19+
BRANCH: ${{ github.base_ref || github.ref_name }}
20+
21+
jobs:
22+
init:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
26+
npmVersion: ${{ steps.versions.outputs.npmVersion }}
27+
28+
steps:
29+
- name: Checkout app
30+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
31+
32+
- name: Check composer.json
33+
id: check_composer
34+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
35+
with:
36+
files: "composer.json"
37+
38+
- name: Install composer dependencies
39+
if: steps.check_composer.outputs.files_exists == 'true'
40+
run: composer install --no-dev
41+
42+
- name: Read package.json node and npm engines version
43+
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
44+
id: versions
45+
with:
46+
fallbackNode: "^20"
47+
fallbackNpm: "^9"
48+
49+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
50+
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
51+
with:
52+
node-version: ${{ steps.versions.outputs.nodeVersion }}
53+
54+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
55+
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
56+
57+
- name: Install node dependencies & build app
58+
run: |
59+
npm ci
60+
TESTING=true npm run build --if-present
61+
62+
- name: Save context
63+
uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
64+
with:
65+
key: cypress-context-${{ github.run_id }}
66+
path: ./
67+
68+
cypress:
69+
runs-on: ubuntu-latest
70+
needs: init
71+
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
# Run multiple copies of the current job in parallel
76+
# Please increase the number or runners as your tests suite grows
77+
containers: [1, 2, 3]
78+
79+
name: runner ${{ matrix.containers }}
80+
81+
steps:
82+
- name: Restore context
83+
uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
84+
with:
85+
fail-on-cache-miss: true
86+
key: cypress-context-${{ github.run_id }}
87+
path: ./
88+
89+
- name: Set up node ${{ needs.init.outputs.nodeVersion }}
90+
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
91+
with:
92+
node-version: ${{ needs.init.outputs.nodeVersion }}
93+
94+
- name: Set up npm ${{ needs.init.outputs.npmVersion }}
95+
run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
96+
97+
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
98+
uses: cypress-io/github-action@db1693016f23ccf9043f4b2428f9b04e5d502a73 # v5.8.1
99+
with:
100+
record: true
101+
parallel: true
102+
# cypress run type
103+
component: ${{ matrix.containers == 'component' }}
104+
group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
105+
# cypress env
106+
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
107+
tag: ${{ github.event_name }}
108+
env:
109+
# Needs to be prefixed with CYPRESS_
110+
CYPRESS_BRANCH: ${{ env.BRANCH }}
111+
# https://github.com/cypress-io/github-action/issues/124
112+
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
113+
# Needed for some specific code workarounds
114+
TESTING: true
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
117+
118+
- name: Upload snapshots
119+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
120+
if: always()
121+
with:
122+
name: snapshots_${{ matrix.containers }}
123+
path: cypress/snapshots
124+
125+
- name: Extract NC logs
126+
if: failure() && matrix.containers != 'component'
127+
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
128+
129+
- name: Upload NC logs
130+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
131+
if: failure() && matrix.containers != 'component'
132+
with:
133+
name: nc_logs_${{ matrix.containers }}
134+
path: nextcloud.log
135+
136+
summary:
137+
runs-on: ubuntu-latest
138+
needs: [init, cypress]
139+
140+
if: always()
141+
142+
name: cypress-summary
143+
144+
steps:
145+
- name: Summary status
146+
run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi

.github/workflows/cypress.yml.txt

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)