-
Notifications
You must be signed in to change notification settings - Fork 9
273 lines (273 loc) · 11.1 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
name: Continuous Integration and Delivery
on: [push, pull_request, workflow_dispatch]
env:
NODE_VERSION: 20.14.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-platform:
name: 'Building Platform'
needs: install
runs-on: ubuntu-latest
outputs:
version: ${{ steps.root-package-json.outputs.version }}
version-dasherized: ${{ steps.root-package-json.outputs.version-dasherized }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Reading package.json version of project root'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/package-json@master
id: root-package-json
with:
path: package.json
- name: 'Reading package.json version of scion/microfrontend-platform'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/package-json@master
id: microfrontend-platform-package-json
with:
path: projects/scion/microfrontend-platform/package.json
- name: 'Asserting package.json versions to be equal'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/equality-checker@master
with:
values: |
${{ steps.root-package-json.outputs.version }},
${{ steps.microfrontend-platform-package-json.outputs.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: 'Building @scion/microfrontend-platform'
run: npm run microfrontend-platform:build
- name: 'Building API Documentation (TypeDoc)'
run: npm run microfrontend-platform:typedoc
- name: 'Building Reference Documentation (Developer Guide)'
run: npm run microfrontend-platform:adoc -- -a revnumber=${{ steps.root-package-json.outputs.version }} -a revnumber-dasherized=${{ steps.root-package-json.outputs.version-dasherized }}
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
build-apps:
name: 'Building Apps'
needs: build-platform
runs-on: ubuntu-latest
strategy:
matrix:
app:
- name: microfrontend-platform-testing-app-vercel
cmd: npm run microfrontend-platform-testing-app-vercel:build
- name: microfrontend-platform-testing-app-ci
cmd: npm run microfrontend-platform-testing-app-ci:build
- name: microfrontend-platform-devtools-vercel
cmd: npm run microfrontend-platform-devtools-vercel: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 platform (dist)'
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- 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: 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 test:headless
analyze:
name: 'Analyzing'
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') }}
- name: 'Analyzing ''@scion/microfrontend-platform'' bundle in client application'
run: npm run microfrontend-platform:analyze:assert
e2e:
name: 'E2E Testing'
needs: [build-platform, build-apps]
runs-on: ubuntu-latest
strategy:
matrix:
shard: [ 1/10, 2/10, 3/10, 4/10, 5/10, 6/10, 7/10, 8/10, 9/10, 10/10 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Downloading platform (dist)'
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: 'Downloading app: microfrontend-platform-testing-app-ci (dist)'
uses: actions/download-artifact@v4
with:
name: microfrontend-platform-testing-app-ci
path: dist/microfrontend-platform-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 }}
release-guard:
name: 'Should release?'
if: github.ref == 'refs/heads/master'
needs:
- build-platform
- build-apps
- lint
- test
- analyze
- 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: v(.*)'
expected-version: ${{ needs.build-platform.outputs.version }}
release:
name: 'Releasing'
if: ${{ needs.release-guard.outputs.should-release == 'true' }}
needs: [release-guard, build-platform]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Downloading platform and documentation (dist)'
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: 'Downloading app: microfrontend-platform-testing-app-vercel (dist)'
uses: actions/download-artifact@v4
with:
name: microfrontend-platform-testing-app-vercel
path: dist/microfrontend-platform-testing-app-vercel
- name: 'Downloading app: microfrontend-platform-devtools-vercel (dist)'
uses: actions/download-artifact@v4
with:
name: microfrontend-platform-devtools-vercel
path: dist/microfrontend-platform-devtools-vercel
- name: 'Deploying microfrontend-platform-testing-app to Vercel'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/microfrontend-platform-testing-app-vercel/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_MICROFRONTEND_PLATFORM_TESTING_APP_PROJECT_ID }}
version: ${{ needs.build-platform.outputs.version }}
aliases: |
microfrontend-platform-testing-app.scion.vercel.app,
microfrontend-platform-testing-app1-v%v.scion.vercel.app,
microfrontend-platform-testing-app2-v%v.scion.vercel.app,
microfrontend-platform-testing-app3-v%v.scion.vercel.app,
microfrontend-platform-testing-app4-v%v.scion.vercel.app
- name: 'Deploying microfrontend-platform-devtools to Vercel'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/microfrontend-platform-devtools-vercel/browser
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_MICROFRONTEND_PLATFORM_DEVTOOLS_PROJECT_ID }}
version: ${{ needs.build-platform.outputs.version }}
aliases: |
microfrontend-platform-devtools.scion.vercel.app,
microfrontend-platform-devtools-v%v.scion.vercel.app
- name: 'Publishing API Documentation (TypeDoc) to Vercel'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/microfrontend-platform-api
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_MICROFRONTEND_PLATFORM_API_PROJECT_ID }}
version: ${{ needs.build-platform.outputs.version }}
aliases: |
microfrontend-platform-api.scion.vercel.app,
microfrontend-platform-api-v%v.scion.vercel.app
- name: 'Publishing Reference Documentation (Developer Guide) to Vercel'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/vercel-deploy@master
with:
dist-folder: dist/microfrontend-platform-developer-guide
vercel-token: ${{ secrets.VERCEL_TOKEN }}
org-id: ${{ secrets.VERCEL_ORG_ID }}
project-id: ${{ secrets.VERCEL_MICROFRONTEND_PLATFORM_DEVELOPER_GUIDE_PROJECT_ID }}
version: ${{ needs.build-platform.outputs.version }}
aliases: |
microfrontend-platform-developer-guide.scion.vercel.app,
microfrontend-platform-developer-guide-v%v.scion.vercel.app
- name: 'Releasing @scion/microfrontend-platform to NPM'
uses: SchweizerischeBundesbahnen/scion-toolkit/.github/actions/npm-publish@master
with:
dist-folder: dist/scion/microfrontend-platform
npm-token: ${{ secrets.NPM_TOKEN }}
dry-run: false
- name: 'Creating GitHub Release'
run: gh release create $VERSION --title $VERSION --notes-file CHANGELOG_LATEST.md --verify-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.build-platform.outputs.version }}