-
Notifications
You must be signed in to change notification settings - Fork 10
398 lines (398 loc) · 16.7 KB
/
workflow.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
name: Continuous Integration and Delivery
on: [push, pull_request, workflow_dispatch]
env:
NODE_VERSION: 22.11.0
jobs:
install:
name: 'Installing NPM modules'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Caching NPM modules if necessary'
uses: actions/cache@v4
id: node-modules-cache
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci
lint:
name: 'Linting'
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- run: npm run lint
build-libs:
name: 'Building Libs'
needs: install
runs-on: ubuntu-latest
outputs:
workbench-version: ${{ steps.workbench-package-json.outputs.version }}
workbench-client-version: ${{ steps.workbench-client-package-json.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Reading package.json version of scion/workbench'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/package-json@master
id: workbench-package-json
with:
path: projects/scion/workbench/package.json
- name: 'Reading package.json version of scion/workbench-client'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/package-json@master
id: workbench-client-package-json
with:
path: projects/scion/workbench-client/package.json
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Building @scion/workbench-client'
run: npm run workbench-client:build
- name: 'Uploading dist/scion/workbench-client'
uses: actions/upload-artifact@v4
with:
name: workbench-client-dist
path: dist/scion/workbench-client
- name: 'Building @scion/workbench'
run: npm run workbench:build
- name: 'Uploading dist/scion/workbench'
uses: actions/upload-artifact@v4
with:
name: workbench-dist
path: dist/scion/workbench
- name: 'Building TypeDoc for @scion/workbench-client'
run: npm run workbench-client:typedoc
- name: 'Uploading dist/workbench-client-api'
uses: actions/upload-artifact@v4
with:
name: workbench-client-api
path: dist/workbench-client-api
build-apps:
name: 'Building Apps'
needs: build-libs
runs-on: ubuntu-latest
strategy:
matrix:
app:
- name: workbench-testing-app-ci
cmd: npm run workbench-testing-app:ci:build
- name: workbench-testing-app-basehref
cmd: npm run workbench-testing-app:basehref:build
- name: workbench-testing-app-basehref-webpack
cmd: npm run workbench-testing-app:basehref-webpack:build
- name: workbench-testing-app-vercel-latest
cmd: npm run workbench-testing-app:vercel-latest:build
- name: workbench-testing-app-vercel-release
cmd: npm run workbench-testing-app:vercel-release:build
- name: workbench-client-testing-app-vercel-latest
cmd: npm run workbench-client-testing-app:vercel-latest:build
- name: workbench-client-testing-app-vercel-release
cmd: npm run workbench-client-testing-app:vercel-release:build
- name: workbench-client-testing-app-ci
cmd: npm run workbench-client-testing-app:ci:build
- name: workbench-getting-started-app
cmd: npm run workbench-getting-started-app:build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Downloading dist/scion/workbench'
uses: actions/download-artifact@v4
with:
name: workbench-dist
path: dist/scion/workbench
- name: 'Downloading dist/scion/workbench-client'
uses: actions/download-artifact@v4
with:
name: workbench-client-dist
path: dist/scion/workbench-client
- name: 'Building ${{ matrix.app.name }}'
run: ${{ matrix.app.cmd }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.app.name }}
path: dist/${{ matrix.app.name }}
test:
name: 'Unit Testing'
needs: build-libs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Downloading dist/scion/workbench'
uses: actions/download-artifact@v4
with:
name: workbench-dist
path: dist/scion/workbench
- name: 'Downloading dist/scion/workbench-client'
uses: actions/download-artifact@v4
with:
name: workbench-client-dist
path: dist/scion/workbench-client
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- run: npm run test:headless
e2e:
name: 'E2E Testing'
needs: [ build-libs, build-apps ]
runs-on: ubuntu-latest
strategy:
matrix:
shard: [ 1/15, 2/15, 3/15, 4/15, 5/15, 6/15, 7/15, 8/15, 9/15, 10/15, 11/15, 12/15, 13/15, 14/15, 15/15 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Downloading dist/scion/workbench'
uses: actions/download-artifact@v4
with:
name: workbench-dist
path: dist/scion/workbench
- name: 'Downloading dist/scion/workbench-client'
uses: actions/download-artifact@v4
with:
name: workbench-client-dist
path: dist/scion/workbench-client
- name: 'Downloading app: workbench-testing-app-ci (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-testing-app-ci
path: dist/workbench-testing-app-ci
- name: 'Downloading app: workbench-testing-app-basehref (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-testing-app-basehref
path: dist/workbench-testing-app-basehref
- name: 'Downloading app: workbench-testing-app-basehref-webpack (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-testing-app-basehref-webpack
path: dist/workbench-testing-app-basehref-webpack
- name: 'Downloading app: workbench-client-testing-app-ci (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-client-testing-app-ci
path: dist/workbench-client-testing-app-ci
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- run: npm run e2e:headless -- --shard=${{ matrix.shard }}
workbench-release-guard:
name: 'Should release @scion/workbench?'
if: github.ref == 'refs/heads/master'
needs:
- build-libs
- build-apps
- lint
- test
- e2e
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.tag-release-commit.outputs.is-release-commit }}
steps:
- uses: actions/checkout@v4
- name: 'If release commit present, add release tag'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/tag-release-commit@master
id: tag-release-commit
with:
release-commit-message-pattern: 'release\(workbench\): v(.*)'
expected-version: ${{ needs.build-libs.outputs.workbench-version }}
workbench-client-release-guard:
name: 'Should release @scion/workbench-client?'
if: github.ref == 'refs/heads/master'
needs:
- build-libs
- build-apps
- lint
- test
- e2e
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.tag-release-commit.outputs.is-release-commit }}
steps:
- uses: actions/checkout@v4
- name: 'If release commit present, add release tag'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/tag-release-commit@master
id: tag-release-commit
with:
release-commit-message-pattern: 'release\(workbench-client\): v(.*)'
expected-version: ${{ needs.build-libs.outputs.workbench-client-version }}
git-tag: workbench-client-%v
deploy-apps:
name: 'Deploying Applications'
if: github.ref == 'refs/heads/master'
needs:
- workbench-release-guard
- workbench-client-release-guard
- build-libs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Downloading app: workbench-testing-app-vercel-latest (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-testing-app-vercel-latest
path: dist/workbench-testing-app-vercel-latest
- name: 'Downloading app: workbench-client-testing-app-vercel-latest (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-client-testing-app-vercel-latest
path: dist/workbench-client-testing-app-vercel-latest
- name: 'Downloading app: workbench-testing-app-vercel-release (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-testing-app-vercel-release
path: dist/workbench-testing-app-vercel-release
- name: 'Downloading app: workbench-client-testing-app-vercel-release (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-client-testing-app-vercel-release
path: dist/workbench-client-testing-app-vercel-release
- name: 'Downloading app: workbench-getting-started-app (dist)'
uses: actions/download-artifact@v4
with:
name: workbench-getting-started-app
path: dist/workbench-getting-started-app
- name: 'Deploying workbench-testing-app to Vercel (latest)'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/workbench-testing-app-vercel-latest/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_WORKBENCH_TESTING_APP_PROJECT_ID }}
aliases: workbench-testing-app.scion.vercel.app
- name: 'Deploying workbench-client-testing-app to Vercel (latest)'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/workbench-client-testing-app-vercel-latest/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_WORKBENCH_CLIENT_TESTING_APP_PROJECT_ID }}
aliases: |
workbench-client-testing-app1.scion.vercel.app,
workbench-client-testing-app2.scion.vercel.app
- name: 'Deploying workbench-testing-app to Vercel (release)'
if: ${{ needs.workbench-release-guard.outputs.should-release == 'true' || needs.workbench-client-release-guard.outputs.should-release == 'true' }}
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/workbench-testing-app-vercel-release/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_WORKBENCH_TESTING_APP_PROJECT_ID }}
version: ${{ needs.build-libs.outputs.workbench-version }}
aliases: workbench-testing-app-v%v.scion.vercel.app
- name: 'Deploying workbench-client-testing-app to Vercel (release)'
if: ${{ needs.workbench-release-guard.outputs.should-release == 'true' || needs.workbench-client-release-guard.outputs.should-release == 'true' }}
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/workbench-client-testing-app-vercel-release/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_WORKBENCH_CLIENT_TESTING_APP_PROJECT_ID }}
version: ${{ needs.build-libs.outputs.workbench-version }}
aliases: |
workbench-client-testing-app1-v%v.scion.vercel.app,
workbench-client-testing-app2-v%v.scion.vercel.app
- name: 'Deploying workbench-getting-started-app to Vercel'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/workbench-getting-started-app/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_WORKBENCH_GETTING_STARTED_APP_PROJECT_ID }}
aliases: workbench-getting-started.scion.vercel.app
release-workbench:
name: 'Releasing @scion/workbench'
if: ${{ needs.workbench-release-guard.outputs.should-release == 'true' }}
needs:
- build-libs
- workbench-release-guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Downloading dist/scion/workbench'
uses: actions/download-artifact@v4
with:
name: workbench-dist
path: dist/scion/workbench
- name: 'Publishing @scion/workbench to NPM'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/npm-publish@master
with:
dist-folder: dist/scion/workbench
npm-token: ${{ secrets.NPM_TOKEN }}
dry-run: false
- name: 'Creating GitHub Release'
run: gh release create $VERSION --title "$VERSION (@scion/workbench)" --notes-file CHANGELOG_WORKBENCH_LATEST.md --verify-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.build-libs.outputs.workbench-version }}
release-workbench-client:
name: 'Releasing @scion/workbench-client'
if: ${{ needs.workbench-client-release-guard.outputs.should-release == 'true' }}
needs:
- build-libs
- workbench-client-release-guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Downloading dist/scion/workbench-client'
uses: actions/download-artifact@v4
with:
name: workbench-client-dist
path: dist/scion/workbench-client
- name: 'Downloading dist/workbench-client-api'
uses: actions/download-artifact@v4
with:
name: workbench-client-api
path: dist/workbench-client-api
- name: 'Publishing TypeDoc for @scion/workbench-client to Vercel'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/workbench-client-api
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_WORKBENCH_CLIENT_API_PROJECT_ID }}
version: ${{ needs.build-libs.outputs.workbench-client-version }}
aliases: |
workbench-client-api.scion.vercel.app,
workbench-client-api-v%v.scion.vercel.app
- name: 'Publishing @scion/workbench-client to NPM'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/npm-publish@master
with:
dist-folder: dist/scion/workbench-client
npm-token: ${{ secrets.NPM_TOKEN }}
dry-run: false
- name: 'Creating GitHub Release'
run: gh release create workbench-client-$VERSION --title "$VERSION (@scion/workbench-client)" --notes-file CHANGELOG_WORKBENCH_CLIENT_LATEST.md --verify-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.build-libs.outputs.workbench-client-version }}