Repository navigation
321 lines (310 loc) · 11.8 KB
/
Copy pathbuild.yml
File metadata and controls
321 lines (310 loc) · 11.8 KB
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
name: Build
on:
push:
branches:
- develop
- main
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# web-dist artifact and cache content; the artifact root is packages/
WEB_DIST_PATHS: |
packages/alphatab/dist
packages/lsp/dist
packages/monaco/dist
packages/webpack/dist
packages/vite/dist
packages/react/dist
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
core: ${{ steps.areas.outputs.core }}
webpkgs: ${{ steps.areas.outputs.webpkgs }}
csharp: ${{ steps.areas.outputs.csharp }}
kotlin: ${{ steps.areas.outputs.kotlin }}
player: ${{ steps.areas.outputs.player }}
website: ${{ steps.areas.outputs.website }}
playground: ${{ steps.areas.outputs.playground }}
github: ${{ steps.areas.outputs.github }}
lint: ${{ steps.areas.outputs.lint }}
lint_workspaces: ${{ steps.areas.outputs.lint_workspaces }}
build_web: ${{ steps.areas.outputs.build_web }}
build_website: ${{ steps.areas.outputs.build_website }}
test_web: ${{ steps.areas.outputs.test_web }}
web_tests: ${{ steps.areas.outputs.web_tests }}
steps:
- uses: actions/checkout@v7
with:
# pull requests diff the merge commit against its first parent
fetch-depth: 2
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
- id: areas
run: node scripts/ci-areas.mts --event "$EVENT_NAME" --before "$BEFORE" --head HEAD
env:
EVENT_NAME: ${{ github.event_name }}
BEFORE: ${{ github.event.before }}
lint:
name: Linting and TypeCheck
needs: changes
if: needs.changes.outputs.lint == 'true'
runs-on: ubuntu-latest
env:
WORKSPACES: ${{ needs.changes.outputs.lint_workspaces }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: ${{ needs.changes.outputs.lint_workspaces != '' && 'npm' || '' }}
- run: npm ci $WORKSPACES --include-workspace-root
if: env.WORKSPACES != ''
- id: generate
run: npm run generate-typescript
if: env.WORKSPACES != ''
- run: npm run lint $WORKSPACES --if-present -- --reporter=github
if: ${{ !cancelled() && steps.generate.outcome == 'success' }}
- run: npm run typecheck $WORKSPACES --if-present
if: ${{ !cancelled() && steps.generate.outcome == 'success' }}
- run: node --test 'scripts/*.test.mts'
if: ${{ !cancelled() && needs.changes.outputs.core == 'true' }}
- run: node --test '.github/scripts/*.test.mjs'
if: ${{ !cancelled() && needs.changes.outputs.github == 'true' }}
build_csharp:
name: Build and Test C#
needs: changes
if: needs.changes.outputs.core == 'true' || needs.changes.outputs.csharp == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: 'npm'
- uses: actions/setup-dotnet@v6
with:
dotnet-version: '8'
- run: npm ci -w packages/alphatab -w packages/transpiler -w packages/tooling -w packages/csharp --include-workspace-root
- run: npm run build-csharp
- run: npm run test-ci-csharp
id: test
- uses: actions/upload-artifact@v7
if: ${{ failure() && steps.test.conclusion == 'failure' }}
with:
name: test-results-csharp
path: |
packages/alphatab/test-data/**/*.new.png
packages/alphatab/test-data/**/*.diff.png
build_kotlin:
name: Build and Test Kotlin
needs: changes
if: needs.changes.outputs.core == 'true' || needs.changes.outputs.kotlin == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: 'npm'
- uses: actions/setup-java@v6.1.0
with:
java-version: '19'
distribution: 'temurin'
- uses: gradle/actions/setup-gradle@v6
with:
cache-read-only: false
- run: npm ci -w packages/alphatab -w packages/transpiler -w packages/tooling -w packages/kotlin --include-workspace-root
- run: npm run build-kotlin
- run: npm run test-kotlin
id: test
- uses: dorny/test-reporter@v3
if: ${{ !cancelled() }}
with:
name: Kotlin Tests
path: 'packages/kotlin/**/build/test-results/**/*.xml'
reporter: java-junit
- uses: actions/upload-artifact@v7
if: ${{ failure() && steps.test.conclusion == 'failure' }}
with:
name: test-results-kotlin
path: |
packages/alphatab/test-data/**/*.new.png
packages/alphatab/test-data/**/*.diff.png
- run: ./packages/kotlin/src/gradlew --stop
build_web:
name: Build Web
needs: changes
if: needs.changes.outputs.build_web == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# keyed on the checked-out sources, before anything is generated or installed; a cached dist
# passed the published types check of the script version in its key
- id: dist-cache
uses: actions/cache/restore@v6
with:
path: ${{ env.WEB_DIST_PATHS }}
# one indentation level throughout, so the folded scalar joins the lines with spaces
key: >-
web-dist-${{ runner.os }}-${{ hashFiles(
'packages/alphatab/src/**', 'packages/lsp/src/**', 'packages/monaco/src/**',
'packages/webpack/src/**', 'packages/vite/src/**', 'packages/react/src/**',
'packages/alphatex/src/**', 'packages/tooling/src/**', 'packages/transpiler/src/**',
'scripts/check-published-types.mts',
'packages/alphatab/font/**', 'packages/alphatab/bundler/**', 'packages/alphatab/scripts/**',
'packages/*/vite.config.ts', 'packages/*/package.json', 'packages/*/tsconfig.json',
'tsconfig.base.json', 'package.json', 'package-lock.json',
'!**/node_modules/**', '!**/test-data/**', '!**/test/**'
) }}
- uses: actions/setup-node@v7
if: steps.dist-cache.outputs.cache-hit != 'true'
with:
node-version: 'lts/*'
cache: 'npm'
- if: steps.dist-cache.outputs.cache-hit != 'true'
run: >
npm ci --include-workspace-root
-w packages/alphatab -w packages/alphatex -w packages/transpiler -w packages/tooling
-w packages/lsp -w packages/monaco -w packages/webpack -w packages/vite -w packages/react
- if: steps.dist-cache.outputs.cache-hit != 'true'
run: npm run build-web
- if: steps.dist-cache.outputs.cache-hit != 'true'
run: npm run build-language-server
- if: steps.dist-cache.outputs.cache-hit != 'true'
run: npm run build-monaco
- if: steps.dist-cache.outputs.cache-hit != 'true'
run: npm run build -w packages/react
- if: steps.dist-cache.outputs.cache-hit != 'true'
run: node scripts/check-published-types.mts
- uses: actions/cache/save@v6
if: steps.dist-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request'
with:
path: ${{ env.WEB_DIST_PATHS }}
key: ${{ steps.dist-cache.outputs.cache-primary-key }}
- uses: actions/upload-artifact@v7
with:
name: web-dist
path: ${{ env.WEB_DIST_PATHS }}
if-no-files-found: error
retention-days: 1
test_web:
name: Test Web (${{ matrix.name }})
needs: [changes, build_web]
if: needs.changes.outputs.test_web == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
# the legs and the areas selecting them are webTestLegs in scripts/ci-areas.mts
matrix: ${{ fromJSON(needs.changes.outputs.web_tests) }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: 'npm'
- run: npm ci $WORKSPACES --include-workspace-root
env:
WORKSPACES: ${{ matrix.install }}
- uses: actions/download-artifact@v8
with:
name: web-dist
path: packages
- run: npm run generate-typescript
- id: test
run: npm run test-web $WORKSPACES
env:
WORKSPACES: ${{ matrix.test }}
- uses: actions/upload-artifact@v7
if: ${{ failure() && steps.test.conclusion == 'failure' }}
with:
name: test-results-web-${{ matrix.id }}
path: |
packages/alphatab/test-data/**/*.new.png
packages/alphatab/test-data/**/*.diff.png
website:
name: Build Website
needs: [changes, build_web]
if: needs.changes.outputs.build_website == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
# own key: the core jobs' npm cache holds no Docusaurus packages
- id: npm-cache
uses: actions/cache/restore@v6
with:
path: ~/.npm
key: npm-website-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: npm-website-${{ runner.os }}-
- run: npm ci --include-workspace-root -w website -w packages/ui
- uses: actions/download-artifact@v8
with:
name: web-dist
path: packages
# npm ci recreates node_modules, so the build caches are restored after it
- id: docusaurus-cache
uses: actions/cache/restore@v6
with:
path: |
website/.docusaurus
website/node_modules/.cache
key: docusaurus-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: docusaurus-${{ runner.os }}-
- id: generate
run: npm run generate-alphatabdoc -w website
- run: npm run lint -w website
if: ${{ !cancelled() && steps.generate.outcome == 'success' }}
- run: npm run typecheck -w website
if: ${{ !cancelled() && steps.generate.outcome == 'success' }}
# the reference docs are generated above; --ignore-scripts skips the prebuild generation
- id: build
if: ${{ !cancelled() && steps.generate.outcome == 'success' }}
run: npm run build -w website --ignore-scripts
- uses: actions/cache/save@v6
if: ${{ !cancelled() && steps.npm-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request' }}
with:
path: ~/.npm
key: ${{ steps.npm-cache.outputs.cache-primary-key }}
- uses: actions/cache/save@v6
if: ${{ steps.build.outcome == 'success' && steps.docusaurus-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request' }}
with:
path: |
website/.docusaurus
website/node_modules/.cache
key: ${{ steps.docusaurus-cache.outputs.cache-primary-key }}
- uses: actions/upload-artifact@v7
if: steps.build.outcome == 'success'
with:
name: website
path: website/build
if-no-files-found: error
retention-days: 3
ci_ok:
name: ci_ok
needs: [changes, lint, build_csharp, build_kotlin, build_web, test_web, website]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- if: >-
needs.changes.result != 'success' ||
contains(needs.*.result, 'failure') ||
contains(needs.*.result, 'cancelled')
run: |
echo "::error::Required jobs did not succeed: $RESULTS"
exit 1
env:
RESULTS: ${{ toJSON(needs.*.result) }}
- run: echo "All required jobs succeeded or were not needed for this change."