forked from cypress-io/cypress-example-kitchensink
-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (189 loc) · 7.37 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# 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-latest
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 env variables
run: |
npm i -g @bahmutov/print-env
print-env GITHUB
print-env BUILD
print-env ACTIONS
cat $GITHUB_EVENT_PATH
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#contexts
- name: Print job object
run: echo '${{ toJson(job) }}'
- name: Print steps object
run: echo '${{ toJson(steps) }}'
- name: Print runner object
run: echo '${{ toJson(runner) }}'
- name: Print strategy object
run: echo '${{ toJson(strategy) }}'
- name: Print matrix object
run: echo '${{ toJson(matrix) }}'
# 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
- 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 }}-
- 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 }}-
# 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
# 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-latest
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-${{ 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
# We can use the workflow name and commit SHA to tie multiple jobs together
- name: Cypress tests
run: |
npm start &
npx cypress run --record --parallel --group "Parallel 2x" --ci-build-id "$GITHUB_WORKFLOW-$GITHUB_SHA"
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-latest
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
# We can use the workflow name and commit SHA to tie multiple jobs together
- name: Cypress tests
run: |
npm start &
npx cypress run --record --parallel --group "Parallel 2x" --ci-build-id "$GITHUB_WORKFLOW-$GITHUB_SHA"
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