forked from cypress-io/cypress-example-kitchensink
-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (178 loc) · 6.95 KB
/
parallel.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# GitHub Actions
# https://help.github.com/en/articles/configuring-a-workflow
# good list of examples at http://www.thedreaming.org/2019/09/10/github-ci/
name: Cypress parallel tests
on: push
jobs:
install:
name: Install NPM and Cypress
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
# install a specific version of Node using
# https://github.com/actions/setup-node
- name: Use Node.js v12
uses: actions/setup-node@v1
with:
node-version: 12
# just so we learn about available environment variables GitHub provides
- name: Print CI env variables
run: |
npm i -g @bahmutov/print-env@2
print-env GITHUB BUILD ACTIONS || true
# Restore the previous NPM modules and Cypress binary archives.
# Any updated archives will be saved automatically after the entire
# workflow successfully finishes.
# See https://github.com/actions/cache
# we use exact restore key to avoid NPM module snowballing
# https://glebbahmutov.com/blog/do-not-let-npm-cache-snowball/
- name: Cache central NPM modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ github.ref }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ github.ref }}-${{ hashFiles('**/package-lock.json') }}
# we use the exact restore key to avoid Cypress binary snowballing
# https://glebbahmutov.com/blog/do-not-let-cypress-cache-snowball/
- name: Cache Cypress binary
uses: actions/cache@v1
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}
# Cache local node_modules to pass to testing jobs
- name: Cache local node_modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ github.ref }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.ref }}-
- name: install dependencies and verify Cypress
env:
# make sure every Cypress install prints minimal information
CI: 1
run: |
npm ci
npx cypress cache path
npx cypress cache list
npx cypress verify
npx cypress info
# Duplicate job definitions - GitHub YAML does not support
# anchor definitions yet, thus we cannot put same steps into a template object yet
test1:
name: Cypress test 1
runs-on: ubuntu-18.04
needs: install
steps:
- uses: actions/checkout@master
# install a specific version of Node using
# https://github.com/actions/setup-node
- name: Use Node.js v12
uses: actions/setup-node@v1
with:
node-version: 12
# Restore just local node_modules and the Cypress binary archives.
- name: Cache Cypress binary
uses: actions/cache@v1
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}
- name: Cache local node_modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ github.ref }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.ref }}-
# check the restored Cypress binary
- name: Check binary
run: |
npx cypress cache path
npx cypress cache list
# Starts local server, then runs Cypress tests and records results on the dashboard
- name: Cypress tests
run: |
npm start &
npx cypress run --record --parallel --group "Parallel 2x"
env:
# place your secret record key at
# https://github.com/cypress-io/cypress-example-kitchensink/settings/secrets
CYPRESS_RECORD_KEY: ${{ secrets.dashboardRecordKey }}
TERM: xterm
# Save videos and screenshots as test artifacts
# https://github.com/actions/upload-artifact
- uses: actions/upload-artifact@master
# there might be no screenshots created when:
# - there are no test failures
# so only upload screenshots if previous step has failed
if: failure()
with:
name: screenshots
path: cypress/screenshots
# video should always be generated
- uses: actions/upload-artifact@master
with:
name: videos
path: cypress/videos
test2:
name: Cypress test 2
runs-on: ubuntu-18.04
needs: install
steps:
- uses: actions/checkout@master
# install a specific version of Node using
# https://github.com/actions/setup-node
- name: Use Node.js v12
uses: actions/setup-node@v1
with:
node-version: 12
# Restore just local node_modules and the Cypress binary archives.
- name: Cache Cypress binary
uses: actions/cache@v1
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/package.json') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-${{ github.ref }}-
- name: Cache local node_modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ github.ref }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
# check the restored Cypress binary
- name: Check binary
run: |
npx cypress cache path
npx cypress cache list
# Starts local server, then runs Cypress tests and records results on the dashboard
- name: Cypress tests
run: |
npm start &
npx cypress run --record --parallel --group "Parallel 2x"
env:
# place your secret record key at
# https://github.com/cypress-io/cypress-example-kitchensink/settings/secrets
CYPRESS_RECORD_KEY: ${{ secrets.dashboardRecordKey }}
TERM: xterm
# Save videos and screenshots as test artifacts
# https://github.com/actions/upload-artifact
- uses: actions/upload-artifact@master
# there might be no screenshots created when:
# - there are no test failures
# so only upload screenshots if previous step has failed
if: failure()
with:
name: screenshots
path: cypress/screenshots
# video should always be generated
- uses: actions/upload-artifact@master
with:
name: videos
path: cypress/videos