-
Notifications
You must be signed in to change notification settings - Fork 0
340 lines (316 loc) · 12.4 KB
/
ui-base.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
name: FOLIO UI Workflows
on:
workflow_call:
inputs:
# node/yarn configuration
node-version:
required: false
type: string
default: '20.x'
# It should be straightforward to add a customizable Yarn version via a simple `yarn set version 3.x` or similar
# https://yarnpkg.com/cli/set/version
folio-npm-registry:
required: false
type: string
default: null # set in set-shared-variables
yarn-lock-retention-days:
required: false
type: number
default: 1
# linting
allow-lint-errors:
required: false
type: boolean
default: true
# unit tests (Jest)
jest-enabled:
required: false
type: boolean
default: true
jest-test-command:
required: false
type: string
default: yarn test
jest-junit-output-dir:
required: false
type: string
default: artifacts/jest-junit
jest-coverage-report-dir:
required: false
type: string
default: artifacts/coverage-jest/
# unit tests (Bigtest)
bigtest-enabled:
required: false
type: boolean
default: false
bigtest-test-command:
required: false
type: string
default: yarn test
bigtest-junit-output-dir:
required: false
type: string
default: artifacts/runTest
bigtest-coverage-report-dir:
required: false
type: string
default: artifacts/coverage/
# sonar
sonar-enabled:
required: false
type: boolean
default: true
sonar-sources:
required: false
type: string
default: ./src
sonar-exclusions:
required: false
type: string
default: >
docs/**,
examples/**,
**/*.md,
**/stories/*,
**/.stories.*,
LICENSE,
artifacts/**,
ci/**,
node_modules/**,
**/tests/**,
**/test/**,
resources/bigtest/interactors/**,
resources/bigtest/network/**,
**/*-test.*,
**/*.test.*,
karma.conf.*,
jest.config.*,
**/*.css,
**/*.json
# translations
compile-translations:
required: false
type: boolean
default: true
# module descriptor
generate-module-descriptor:
required: false
type: boolean
default: true
publish-module-descriptor:
required: false
type: boolean
default: true
module-descriptor-registry:
required: false
type: string
default: https://folio-registry.dev.folio.org
# module publishing
folio-npm-registry-auth:
required: false
type: string
default: null # set in set-shared-variables
install-before-publish:
required: false
type: boolean
default: false
publish-exclusions:
required: false
type: string
default: |
artifacts
.github
.scannerwork
secrets:
# these need to be non-required to allow anything here for forks
# however, the sub-workflows will fail appropriately if these are not present, as applicable
SONAR_TOKEN:
required: false
DOCKER_USER:
required: false
DOCKER_PASSWORD:
required: false
NPM_TOKEN:
required: false
FOLIO_REGISTRY_USERNAME:
required: false
FOLIO_REGISTRY_PASSWORD:
required: false
jobs:
set-shared-variables:
name: Set shared variables
runs-on: ubuntu-latest
outputs:
# unfortunately we can only output strings, so this is "True" or "False"
is-release: ${{ steps.logic.outputs.is-release }}
folio-npm-registry: ${{ steps.logic.outputs.folio-npm-registry }}
folio-npm-registry-auth: ${{ steps.logic.outputs.folio-npm-registry-auth }}
steps:
- id: logic
name: Determine default values
shell: python # quicker to use than node, since node would require a longer installation step
run: |
# if these strings contain " there's likely a much larger problem...
ref = "${{ github.ref }}"
current_npm_registry = "${{ inputs.folio-npm-registry }}"
current_npm_registry_auth = "${{ inputs.folio-npm-registry-auth }}"
import re
print("We are on ref:", ref)
if re.match(r'^refs/tags/v\d+\..+', ref):
print(" We are on a tag vX.Y")
is_release = True
else:
print(" We are not on a version tag")
is_release = False
print("Current npm registry:", current_npm_registry)
print("Current npm registry auth:", current_npm_registry_auth)
if current_npm_registry == "":
print(" No npm registry provided, using default")
if is_release:
current_npm_registry = "https://repository.folio.org/repository/npm-folio/"
else:
current_npm_registry = "https://repository.folio.org/repository/npm-folioci/"
if current_npm_registry_auth == "":
print(" No npm registry auth provided, using default")
if is_release:
current_npm_registry_auth = "//repository.folio.org/repository/npm-folio/"
else:
current_npm_registry_auth = "//repository.folio.org/repository/npm-folioci/"
import os
output = open(os.environ['GITHUB_OUTPUT'], 'a')
output.write("is-release=" + str(is_release) + "\n")
output.write("folio-npm-registry=" + current_npm_registry + "\n")
output.write("folio-npm-registry-auth=" + current_npm_registry_auth + "\n")
output.close()
# this job is responsible for printing install information and publishing yarn.lock if debug is enabled
install-and-lint:
name: Install and lint
needs: [set-shared-variables]
uses: folio-org/.github/.github/workflows/ui-install-and-lint.yml
with:
node-version: ${{ inputs.node-version }}
folio-npm-registry: ${{ needs.set-shared-variables.outputs.folio-npm-registry }}
allow-lint-errors: ${{ inputs.allow-lint-errors }}
yarn-lock-retention-days: ${{ inputs.yarn-lock-retention-days }}
jest-tests:
name: Run Jest tests
needs: [set-shared-variables]
if: ${{ inputs.jest-enabled }}
uses: folio-org/.github/.github/workflows/ui-tests-jest.yml
with:
node-version: ${{ inputs.node-version }}
folio-npm-registry: ${{ needs.set-shared-variables.outputs.folio-npm-registry }}
jest-test-command: ${{ inputs.jest-test-command }}
jest-junit-output-dir: ${{ inputs.jest-junit-output-dir }}
jest-coverage-report-dir: ${{ inputs.jest-coverage-report-dir }}
bigtest-tests:
name: Run Bigtest tests
needs: [set-shared-variables]
if: ${{ inputs.bigtest-enabled }}
uses: folio-org/.github/.github/workflows/ui-tests-bigtest.yml
with:
node-version: ${{ inputs.node-version }}
folio-npm-registry: ${{ needs.set-shared-variables.outputs.folio-npm-registry }}
bigtest-test-command: ${{ inputs.bigtest-test-command }}
bigtest-junit-output-dir: ${{ inputs.bigtest-junit-output-dir }}
bigtest-coverage-report-dir: ${{ inputs.bigtest-coverage-report-dir }}
translations:
name: Compile translations
needs: [set-shared-variables]
if: ${{ inputs.compile-translations }}
uses: folio-org/.github/.github/workflows/ui-translations.yml
with:
node-version: ${{ inputs.node-version }}
folio-npm-registry: ${{ needs.set-shared-variables.outputs.folio-npm-registry }}
sonarcloud:
name: SonarCloud analysis
needs: [jest-tests, bigtest-tests]
# run even if tests fail
if: ${{ !cancelled() && inputs.sonar-enabled }}
uses: folio-org/.github/.github/workflows/ui-sonarcloud.yml
with:
sonar-sources: ${{ inputs.sonar-sources }}
sonar-exclusions: ${{ inputs.sonar-exclusions }}
bigtest-enabled: ${{ inputs.bigtest-enabled }}
bigtest-coverage-report-dir: ${{ inputs.bigtest-coverage-report-dir }}
jest-enabled: ${{ inputs.jest-enabled }}
jest-coverage-report-dir: ${{ inputs.jest-coverage-report-dir }}
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
version-number:
# used for module descriptor and publishing to NPM
needs: [set-shared-variables]
uses: folio-org/.github/.github/workflows/ui-version-number.yml
with:
is-release: ${{ needs.set-shared-variables.outputs.is-release }}
generate-module-descriptor:
name: Generate module descriptor
needs: [set-shared-variables, version-number]
if: ${{ inputs.generate-module-descriptor }}
uses: folio-org/.github/.github/workflows/ui-module-descriptor-generate.yml
with:
node-version: ${{ inputs.node-version }}
folio-npm-registry: ${{ needs.set-shared-variables.outputs.folio-npm-registry }}
package-version: ${{ needs.version-number.outputs.version-number }}
okapi-dependency-check:
name: Okapi dependency check (main branch/release only)
needs: [set-shared-variables, generate-module-descriptor]
if: ${{ inputs.generate-module-descriptor && needs.set-shared-variables.outputs.is-release == 'True' }}
uses: folio-org/.github/.github/workflows/ui-module-descriptor-verify.yml
with:
okapi-pull-contents: '{"urls": ["https://folio-registry.dev.folio.org"]}'
secrets:
docker-username: ${{ secrets.DOCKER_USER }}
docker-password: ${{ secrets.DOCKER_PASSWORD }}
publish-module-descriptor:
name: Publish module descriptor (main branch/release only)
needs: [set-shared-variables, generate-module-descriptor, okapi-dependency-check]
# okapi-dependency-check is optional, but if it's enabled, we want to require it for tag releases
if: |
!cancelled() &&
inputs.generate-module-descriptor && inputs.publish-module-descriptor &&
(needs.okapi-dependency-check.result == 'success' || needs.okapi-dependency-check.result == 'skipped') &&
(github.ref_name == github.event.repository.default_branch || needs.set-shared-variables.outputs.is-release == 'True')
uses: folio-org/.github/.github/workflows/ui-module-descriptor-publish.yml
with:
module-descriptor-registry: ${{ inputs.module-descriptor-registry }}
secrets:
registry-username: ${{ secrets.FOLIO_REGISTRY_USERNAME }}
registry-password: ${{ secrets.FOLIO_REGISTRY_PASSWORD }}
publish-module:
name: Publish module (main branch/release only)
needs:
- set-shared-variables
- install-and-lint
- version-number
- generate-module-descriptor
- okapi-dependency-check
- translations
- jest-tests
- bigtest-tests
# we want to run this iff module descriptor/tests/etc succeed or are skipped (e.g. no bigtests are present means bigtest-tests is skipped)
# by default, if a needed job is skipped, this job is skipped too. So we have to say
# always (!cancelled), and then check specifically.
if: |
!cancelled() &&
needs.install-and-lint.result == 'success' &&
needs.version-number.result == 'success' &&
(needs.generate-module-descriptor.result == 'success' || needs.generate-module-descriptor.result == 'skipped') &&
(needs.okapi-dependency-check.result == 'success' || needs.okapi-dependency-check.result == 'skipped') &&
(needs.translations.result == 'success' || needs.translations.result == 'skipped') &&
(needs.jest-tests.result == 'success' || needs.jest-tests.result == 'skipped') &&
(needs.bigtest-tests.result == 'success' || needs.bigtest-tests.result == 'skipped') &&
(github.ref_name == github.event.repository.default_branch || needs.set-shared-variables.outputs.is-release == 'True')
uses: ./.github/workflows/ui-publish-module.yml
with:
node-version: ${{ inputs.node-version }}
folio-npm-registry: ${{ needs.set-shared-variables.outputs.folio-npm-registry }}
folio-npm-registry-auth: ${{ needs.set-shared-variables.outputs.folio-npm-registry-auth }}
package-version: ${{ needs.version-number.outputs.version-number }}
publish-exclusions: ${{ inputs.publish-exclusions }}
module-descriptor-available: ${{ inputs.generate-module-descriptor }}
compiled-translations-available: ${{ inputs.compile-translations }}
install-before-publish: ${{ inputs.install-before-publish }}
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}