-
Notifications
You must be signed in to change notification settings - Fork 38
416 lines (333 loc) · 10.6 KB
/
build.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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
name: CI
on:
workflow_dispatch:
push:
branches:
- main
- dev
pull_request:
merge_group:
jobs:
install:
name: Install node modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
audit:
name: Audit node modules
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- run: pnpm audit
build:
name: Build and lint packages
needs: install
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint
- run: pnpm lint:copyright
- run: pnpm run build --filter="{./packages/*}..."
apps:
name: Build website and playgrounds
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build --filter=website --filter="{./playgrounds/*}..."
deploy-gh-pages:
name: Push static files to github pages
needs: install
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
base_folder: ${{ github.event.number || github.ref_name != 'main' && github.ref_name || '' }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- name: Build css-workshop
run: pnpm run build --filter=css-workshop
- name: Build portal
run: pnpm --filter portal build --base "/iTwinUI/${{ env.base_folder }}"
- name: Build react-workshop
run: pnpm run build --filter=react-workshop
- name: Build vite-playground
run: pnpm run build --filter=vite-playground
- name: List folders to preserve (open PRs and 'legacy')
id: clean_exclude_folders
uses: actions/github-script@v4
with:
result-encoding: string
script: |
return ['legacy', ...((await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
})).data.map(pr => pr.number))].join('\n')
- name: Host portal under / or /legacy
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
single-commit: true
folder: ${{ github.workspace }}/apps/portal/dist
target-folder: ${{ env.base_folder }}
clean-exclude: ${{ steps.clean_exclude_folders.outputs.result }}
git-config-name: github-actions[bot]
git-config-email: github-actions[bot]@users.noreply.github.com
- name: Host css-workshop under /css
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ github.workspace }}/apps/css-workshop/dist
target-folder: ${{ env.base_folder }}/css
git-config-name: github-actions[bot]
git-config-email: github-actions[bot]@users.noreply.github.com
- name: Host react-workshop under /react
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ github.workspace }}/apps/react-workshop/build
target-folder: ${{ env.base_folder }}/react
git-config-name: github-actions[bot]
git-config-email: github-actions[bot]@users.noreply.github.com
- name: Host vite-playground under /vite
if: github.ref != 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ github.workspace }}/playgrounds/vite/dist
target-folder: ${{ env.base_folder }}/vite
git-config-name: github-actions[bot]
git-config-email: github-actions[bot]@users.noreply.github.com
- name: Post deploy preview link under Checks
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' && always()
uses: actions/github-script@v6
with:
script: |
github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: '${{ github.event.pull_request.head.sha }}',
conclusion: 'neutral',
name: 'Deploy preview',
output: {
title: 'Live preview of the current branch',
summary: '',
text: `\
- [css-workshop](https://itwin.github.io/iTwinUI/${{ github.event.number }}/css)
- [react-workshop](https://itwin.github.io/iTwinUI/${{ github.event.number }}/react)
- [docs website](https://deploy-preview-${{ github.event.number }}--itwinui-previews.netlify.app/)
- [vite-playground](https://itwin.github.io/iTwinUI/${{ github.event.number }}/vite)`
}
})
unit-test:
name: Run unit tests
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- run: pnpm --filter @itwin/itwinui-react test
- name: Publish test results
uses: EnricoMi/[email protected]
if: always()
with:
files: 'packages/itwinui-react/coverage/junit.xml'
comment_mode: off
check_name: 'Test results'
fail_on: 'nothing'
visual-test-css:
name: Run visual tests (css)
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- name: pnpm run test --filter=css-workshop
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 2
retry_on: timeout
command: pnpm run test --filter=css-workshop
- name: Publish test results artifact
if: failure()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: 'backstop_test_results'
path: '${{ github.workspace }}/apps/css-workshop/backstop/results/'
overwrite: true
visual-test-react:
name: Run visual tests (react)
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- run: pnpm run test --filter=react-workshop
- name: Publish test results artifact
if: failure()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: 'cypress-visual-screenshots'
path: '${{ github.workspace }}/apps/react-workshop/cypress-visual-screenshots'
overwrite: true
a11y:
name: Test for a11y violations
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- name: Install Cypress binary if not found
run: pnpx [email protected] install
- name: Run a11y tests
run: pnpm run test --filter=a11y
e2e:
name: Run e2e tests
needs: install
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Use Node 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build --filter=e2e
- name: Run Playwright tests
run: pnpm run test --filter=e2e
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-report
path: testing/e2e/playwright-report/
retention-days: 30
veracode:
name: Zip and Upload files to Veracode
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Zip files for veracode
shell: bash
run: |
sourceDirs=("apps" "packages")
outputFile="itdw-veracode.zip"
excludedPaths=(
".git/*"
"**/backstop/*"
"**/cypress*/*"
)
zipCommand="zip -r $outputFile"
for dir in "${sourceDirs[@]}"; do
zipCommand+=" $dir"
done
for path in "${excludedPaths[@]}"; do
zipCommand+=" -x \"$path\""
done
eval $zipCommand
if [[ $? -eq 0 ]]; then
echo "Zip file created successfully"
else
echo "An error occurred while creating the zip file"
exit 1
fi
- name: Upload & scan
uses: veracode/[email protected]
with:
appname: 'iTwinUI - UX (ITDW - 3418)'
filepath: 'itdw-veracode.zip'
vid: ${{ secrets.VERACODE_ID }}
vkey: ${{ secrets.VERACODE_SECRET_KEY }}