-
Notifications
You must be signed in to change notification settings - Fork 158
292 lines (257 loc) · 8.61 KB
/
e2e-tests-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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: e2e-tests-parallel
on:
push:
branches: [ main, release/*, feat/*, fix/content-updates ]
pull_request:
branches: [ main, release/*, feat/*, fix/content-updates ]
concurrency:
group: e2e-tests-parallel${{ github.ref }}
cancel-in-progress: true
jobs:
install-web-components:
strategy:
matrix:
os: [ macos-latest ]
node-version: [ 18.x ]
browser: [ chromium ]
runs-on: ${{ matrix.os }}
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- uses: actions/cache@v3
name: Download any existing cache
id: yarn-cache
with:
path: |
**/node_modules
/Users/runner/Library/Caches/Cypress
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- name: Installing dependencies (if not cached)
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable --immutable-cache
- name: Build project
run: yarn lerna run --stream --ignore @carbon/ibmdotcom-react build
- name: Set Cloud Masthead env var
uses: ./.github/actions/set-dotenv
with:
env-file: packages/web-components/.env
env:
DDS_CLOUD_MASTHEAD: true
DDS_FLAGS_ALL: true
- name: Build storybook
working-directory: packages/web-components
run: yarn build-storybook
- name: Save build folder
uses: actions/upload-artifact@v3
with:
name: storybook-build
path: packages/web-components/storybook-static
- name: Clear remnant failure files
uses: geekyeggo/delete-artifact@v2
with:
name: failure-wc.txt
web-components-tests:
runs-on: macos-latest
needs: install-web-components
continue-on-error: true
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6, 7]
os: [ macos-latest ]
node-version: [ 18.x ]
browser: [ chromium ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Download the build folders
uses: actions/download-artifact@v3
with:
name: storybook-build
path: packages/web-components/storybook-static
- uses: actions/cache@v3
name: Retrieve yarn cache
id: yarn-cache
with:
path: |
**/node_modules
/Users/runner/Library/Caches/Cypress
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- name: 'Run e2e tests (chromium)'
if: matrix.browser == 'chromium'
id: cypress-tests-wc
continue-on-error: true
working-directory: packages/web-components
run: yarn test:e2e-storybook:test:parallel
env:
CI_BUILD_ID: '${{ github.sha }}-${{ github.workflow }}-wc'
CYPRESS_API_URL: "https://sorry-cypress-director.qfl95m0zv01.us-east.codeengine.appdomain.cloud"
CYPRESS_CACHE_FOLDER: /Users/runner/Library/Caches/Cypress
- name: Create failure file if job failed
id: wc-no-tests-ran
if: steps.cypress-tests-wc.outcome == 'failure'
run: touch failure-wc.txt
- name: Save failure file
if: steps.cypress-tests-wc.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: failure-wc
path: failure-wc.txt
- name: Exit upon failure
if: steps.cypress-tests-wc.outcome == 'failure'
run: exit 1
wc-tests-completed:
if: always()
runs-on: ubuntu-20.04
needs: web-components-tests
steps:
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: failure-wc
- name: Check failure file existence
continue-on-error: true
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "failure-wc.txt"
- name: Failure file exists, exit with error
if: steps.check_files.outputs.files_exists == 'true'
run: exit 1
install-react:
strategy:
matrix:
os: [ ubuntu-20.04 ]
node-version: [ 18.x ]
browser: [ chromium ]
runs-on: ${{ matrix.os }}
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- uses: actions/cache@v3
name: Download any existing cache
id: yarn-cache
with:
path: |
**/node_modules
/home/runner/.cache/Cypress
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ matrix.os }}-yarn-v5${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ matrix.os }}-yarn
- name: Installing dependencies (if not cached)
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable --immutable-cache
- name: Build project
run: yarn lerna run --stream --ignore @carbon/ibmdotcom-web-components --ignore @carbon/ibmdotcom-services-store build
- name: Build storybook
working-directory: packages/react
run: yarn build-storybook
- name: Save build folder
uses: actions/upload-artifact@v3
with:
name: storybook-build
path: packages/react/storybook-static
- name: Clear remnant failure files
uses: geekyeggo/delete-artifact@v2
with:
name: failure-react.txt
react-tests:
runs-on: ubuntu-20.04
needs: install-react
continue-on-error: true
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5]
os: [ ubuntu-20.04 ]
node-version: [ 18.x ]
browser: [ chromium ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Download the build folders
uses: actions/download-artifact@v3
with:
name: storybook-build
path: packages/react/storybook-static
- uses: actions/cache@v3
name: Retrieve yarn cache
id: yarn-cache
with:
path: |
**/node_modules
/home/runner/.cache/Cypress
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ matrix.os }}-yarn-v5${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ matrix.os }}-yarn
- name: 'Run e2e tests (chromium)'
if: matrix.browser == 'chromium'
id: cypress-tests-react
continue-on-error: true
working-directory: packages/react
run: yarn test:e2e-storybook:test:parallel
env:
CI_BUILD_ID: '${{ github.sha }}-${{ github.workflow }}-wc'
CYPRESS_API_URL: "https://sorry-cypress-director.qfl95m0zv01.us-east.codeengine.appdomain.cloud"
CYPRESS_CACHE_FOLDER: /home/runner/.cache/Cypress
- name: Create failure file if job failed
id: react-no-tests-ran
if: steps.cypress-tests-react.outcome == 'failure'
run: touch failure-react.txt
- name: Save failure file
if: steps.cypress-tests-react.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: failure-react
path: failure-react.txt
- name: Exit upon failure
if: steps.cypress-tests-react.outcome == 'failure'
run: exit 1
react-tests-completed:
if: always()
runs-on: ubuntu-20.04
needs: react-tests
steps:
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: failure-react
- name: Check failure file existence
continue-on-error: true
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "failure-react.txt"
- name: Failure file exists, exit with error
if: steps.check_files.outputs.files_exists == 'true'
run: exit 1