forked from disneystreaming/smithy4s
-
Notifications
You must be signed in to change notification settings - Fork 0
557 lines (484 loc) · 16.9 KB
/
Copy pathci.yml
File metadata and controls
557 lines (484 loc) · 16.9 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
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
name: CI
on:
workflow_dispatch:
inputs:
publishSnapshot:
description: "Publish Snapshot"
required: false
default: false
type: boolean
publishSnapshotPr:
description: "PR number to publish snapshot from"
required: false
type: number
publishMicrosite:
description: "Publish Microsite"
required: false
default: false
type: boolean
push:
branches: ["main", "series/**", "feature/**"]
tags: ["v*"]
pull_request:
branches: ["**"]
schedule:
# midnight, every Monday and Thursday
- cron: '0 0 * * 1,4'
env:
CHECKOUT_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publishSnapshotPr != '' && format('refs/pull/{0}/head', github.event.inputs.publishSnapshotPr) || github.ref }}
SBT_OPTS: "-XX:MaxMetaspaceSize=4G -XX:MaxInlineLevel=20 -Xss2m -Xms512M -Xmx6G -XX:ReservedCodeCacheSize=256M"
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
compile:
name: Compile ${{matrix.scalaVersion}} (${{matrix.scalaPlatform}})
strategy:
fail-fast: true
matrix:
scalaVersion: ["2_12", "2_13", "3_0"]
scalaPlatform: ["jvm", "js"]
exclude:
# Do not build 2.12 artifacts for Scalajs
- scalaVersion: "2_12"
scalaPlatform: "js"
include:
- scalaVersion: "3_0"
scalaPlatform: "native"
runs-on: ubuntu-latest
env:
BUILD_KEY: ${{matrix.scalaVersion}}_${{matrix.scalaPlatform}}
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: ${{ env.BUILD_KEY }}
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt scala-cli
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Compile
# cs fetch is only needed to work around the following issue https://github.com/VirtusLab/scala-cli/issues/4108
run: |
cs fetch --no-default -r central ch.epfl.scala::bloop-frontend:2.0.17
sbt compile_$BUILD_KEY \
testCompile_$BUILD_KEY \
pushRemoteCache_$BUILD_KEY
- name: Check for untracked changes
run: |
git status
./scripts/check-dirty.sh
echo "Built $(cat version)"
- name: Upload compilation cache
uses: actions/upload-artifact@v7
with:
name: compilation-${{env.BUILD_KEY}}.zip
path: /tmp/remote-cache
retention-days: 3
test:
name: Test ${{matrix.scalaVersion}} (${{matrix.scalaPlatform}})
needs: compile
strategy:
fail-fast: true
matrix:
scalaVersion: ["2_12", "2_13", "3_0"]
scalaPlatform: ["jvm", "js"]
exclude:
- scalaVersion: "2_12"
scalaPlatform: "js"
include:
- scalaVersion: "3_0"
scalaPlatform: "native"
runs-on: ubuntu-latest
env:
BUILD_KEY: ${{matrix.scalaVersion}}_${{matrix.scalaPlatform}}
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: ${{ env.BUILD_KEY }}
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt scala-cli
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Download compilation cache
uses: actions/download-artifact@v8
with:
name: compilation-${{env.BUILD_KEY}}.zip
path: /tmp/remote-cache
- name: Run tests
run: |
cs fetch --no-default -r central ch.epfl.scala::bloop-frontend:2.0.17
sbt pullRemoteCache_$BUILD_KEY \
test_$BUILD_KEY
mima:
name: MiMa ${{matrix.scalaVersion}} (jvm)
needs: compile
strategy:
fail-fast: true
matrix:
scalaVersion: ["2_12", "2_13", "3_0"]
runs-on: ubuntu-latest
env:
BUILD_KEY: ${{matrix.scalaVersion}}_jvm
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: ${{ env.BUILD_KEY }}
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Download compilation cache
uses: actions/download-artifact@v8
with:
name: compilation-${{env.BUILD_KEY}}.zip
path: /tmp/remote-cache
- name: Check for Binary Compatibility
run: sbt pullRemoteCache_$BUILD_KEY mimaReportBinaryIssuesIfRelevant_$BUILD_KEY
checks:
name: Checks (scalafmt, scalafix, headers)
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: checks
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Run formatter and linters
run: |
sbt scalafmtCheckAll \
headerCheck \
scalafix_2_13_jvm \
scalafixTests_2_13_jvm
docs:
name: Docs (mdoc + website)
needs: compile
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: docs
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Download compilation cache (2_13_jvm)
uses: actions/download-artifact@v8
with:
name: compilation-2_13_jvm.zip
path: /tmp/remote-cache
- name: Render mdoc
run: sbt pullRemoteCache_2_13_jvm "docsRendering/mdoc"
- name: Build website
run: cd ./modules/website && yarn && yarn swizzle docusaurus-lunr-search SearchBar --danger --wrap && yarn build
sbt-plugin-discover:
name: sbt plugin (discover scripted tests)
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.list.outputs.tests }}
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: List scripted test folders
id: list
run: |
tests=$(ls modules/codegen-plugin/src/sbt-test/codegen-plugin | jq -R . | jq -sc .)
echo "tests=$tests" >> "$GITHUB_OUTPUT"
echo "Discovered: $tests"
sbt-plugin:
name: sbt plugin (${{ matrix.test }})
needs: [compile, sbt-plugin-discover]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.sbt-plugin-discover.outputs.tests) }}
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: sbt-plugin
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Download compilation cache (jvm)
uses: actions/download-artifact@v8
with:
pattern: compilation-*_jvm.zip
path: /tmp/remote-cache
- name: Merge compilation caches
run: cd /tmp/remote-cache && (ls | xargs -I {} sh -c 'cp -r {}/* .')
- name: Run scripted (${{ matrix.test }})
run: sbt pullRemoteCache_2_12_jvm pullRemoteCache_2_13_jvm pullRemoteCache_3_0_jvm "scripted codegen-plugin/${{ matrix.test }}"
mill-plugin:
name: mill plugin (${{ matrix.project }})
needs: compile
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ["millCodegenPlugin0_11", "millCodegenPlugin0_12", "millCodegenPlugin13"]
steps:
- name: Checkout current branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: mill-plugin
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Download compilation cache (2_13_jvm)
uses: actions/download-artifact@v8
with:
name: compilation-2_13_jvm.zip
path: /tmp/remote-cache/2_13_jvm
- name: Download compilation cache (3_0_jvm)
uses: actions/download-artifact@v8
with:
name: compilation-3_0_jvm.zip
path: /tmp/remote-cache/3_0_jvm
- name: Merge compilation caches
run: cd /tmp/remote-cache && (ls | xargs -I {} sh -c 'cp -r {}/* .')
- name: Run mill plugin tests (${{ matrix.project }})
run: sbt pullRemoteCache_2_13_jvm pullRemoteCache_3_0_jvm ${{ matrix.project }}/test
build-success-checkpoint:
runs-on: ubuntu-latest
needs: [compile, test, mima, checks, docs, sbt-plugin-discover, sbt-plugin, mill-plugin]
steps:
- name: Build matrix completed
run: |
echo "compile = ${{ needs.compile.result }}"
echo "test = ${{ needs.test.result }}"
echo "mima = ${{ needs.mima.result }}"
echo "checks = ${{ needs.checks.result }}"
echo "docs = ${{ needs.docs.result }}"
echo "sbt-plugin-discover = ${{ needs.sbt-plugin-discover.result }}"
echo "sbt-plugin = ${{ needs.sbt-plugin.result }}"
echo "mill-plugin = ${{ needs.mill-plugin.result }}"
if [[ "${{ needs.compile.result }}" != "success" \
|| "${{ needs.test.result }}" != "success" \
|| "${{ needs.mima.result }}" != "success" \
|| "${{ needs.checks.result }}" != "success" \
|| "${{ needs.docs.result }}" != "success" \
|| "${{ needs.sbt-plugin-discover.result }}" != "success" \
|| "${{ needs.sbt-plugin.result }}" != "success" \
|| "${{ needs.mill-plugin.result }}" != "success" ]]; then
exit 1
fi
release:
name: Release ${{matrix.scalaVersion}} (${{matrix.scalaPlatform}})
needs: compile
if:
startsWith(github.ref, 'refs/tags/v') ||
github.event.inputs.publishSnapshot == 'true' ||
github.event_name == 'schedule'
strategy:
# don't cancel the matrix on first failure: for snapshots we want every
# shard to land independently, and for stable releases we'd rather the
# aggregator skip than half the bundle silently disappear
fail-fast: false
matrix:
scalaVersion: ["2_12", "2_13", "3_0"]
scalaPlatform: ["jvm", "js"]
exclude:
- scalaVersion: "2_12"
scalaPlatform: "js"
include:
- scalaVersion: "3_0"
scalaPlatform: "native"
runs-on: ubuntu-latest
env:
BUILD_KEY: ${{matrix.scalaVersion}}_${{matrix.scalaPlatform}}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: ${{ env.BUILD_KEY }}
- name: Download compilation cache
uses: actions/download-artifact@v8
with:
name: compilation-${{env.BUILD_KEY}}.zip
path: /tmp/remote-cache
- name: Publish ${{ github.ref }} (${{env.BUILD_KEY}})
run: sbt "show version; pullRemoteCache_$BUILD_KEY; ci-release"
env:
# cleaning will removed generated code from bootstrapped module which will
# cause the repo to be dirty and change the version to a -SNAPSHOT version
CI_CLEAN: ""
# Override what ci-release runs so each shard only publishes its own
# (scala, platform) slice. CI_RELEASE replaces "+publishSigned" for
# stable releases; CI_SNAPSHOT_RELEASE replaces "+publish" for snapshots.
# For snapshots, that publishes straight to central-snapshots — done.
# For stable releases, publishSigned_<shard> writes signed artifacts
# into target/sona-staging/, which the aggregator job collects and
# releases as one bundle via sonaRelease. Skip the per-shard release.
CI_RELEASE: publishSigned_${{env.BUILD_KEY}}
CI_SNAPSHOT_RELEASE: publish_${{env.BUILD_KEY}}
CI_SONATYPE_RELEASE: version
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.CENTRAL_SONATYPE_USERNAME }}
- name: Upload signed staging slice
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v7
with:
name: sona-staging-${{env.BUILD_KEY}}
path: target/sona-staging
retention-days: 1
if-no-files-found: error
release-bundle:
name: Release bundle (aggregate)
needs: release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Cache
uses: coursier/cache-action@v8
with:
extraKey: release-bundle
- name: Download per-shard staging slices
uses: actions/download-artifact@v8
with:
pattern: sona-staging-*
path: /tmp/staging
- name: Merge into one staging tree
# Each shard's artifact unpacks to /tmp/staging/sona-staging-<key>/<contents>.
# Merge them into a single tree at target/sona-staging/.
run: |
mkdir -p target/sona-staging
for d in /tmp/staging/sona-staging-*; do
cp -r "$d"/. target/sona-staging/
done
echo "Merged staging tree:"
find target/sona-staging -maxdepth 4 -type d
- name: Release bundle
run: sbt "show version; sonaRelease"
env:
SONATYPE_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.CENTRAL_SONATYPE_USERNAME }}
microsite:
name: Publish Docs Microsite
if:
startsWith(github.ref, 'refs/tags/v') ||
github.event.inputs.publishMicrosite == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.CHECKOUT_REF }}
- name: Setup Java and Scala
uses: coursier/setup-action@v3
with:
jvm: temurin:1.17
apps: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Cache
uses: coursier/cache-action@v8
- name: Resolve latest smithy4s-core version
# export the version only when we trigger publish manually
if: ${{ github.event_name == 'workflow_dispatch' }}
run: echo "SMITHY4S_VERSION=$(cs resolve com.disneystreaming.smithy4s:smithy4s-core_2.13:latest.stable --ttl 0 | head -1 | awk -F':' '{print $3}')" >> $GITHUB_ENV
- name: Compile Documentation Markdown Files
run: sbt "docsRendering/mdoc"
- name: Build Microsite
run: cd ./modules/website && yarn && yarn swizzle docusaurus-lunr-search SearchBar --danger --wrap && yarn build
- name: Publish Microsite
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./modules/website/build
publish_branch: gh-pages