-
Notifications
You must be signed in to change notification settings - Fork 104
573 lines (506 loc) · 20.9 KB
/
ci.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
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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
name: Continuous Integration
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- 'releases/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_OFFICIAL_REPO: ${{ github.repository == 'temporalio/sdk-typescript' }}
# Is it the official main branch, or an official release branches?
IS_MAIN_OR_RELEASE: |
${{
github.repository == 'temporalio/sdk-typescript'
&& (github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/tags/')
|| startsWith(github.ref, 'refs/heads/releases'))
&& github.event_name != 'pull_request'
}}
TESTS_CLI_VERSION: 'v0.12.0'
jobs:
# Compile native bridge code for each target platform.
# Uploads the native library for each target as a build artifact.
compile-native-binaries:
strategy:
fail-fast: true
matrix:
include:
# For Linux targets, use Buildjet's builders to get the oldest supported glibc version
- platform: linux-x64
runner: buildjet-4vcpu-ubuntu-2204
target: x86_64-unknown-linux-gnu
container: quay.io/pypa/manylinux_2_24_x86_64
out-file: libtemporal_sdk_typescript_bridge.so
- platform: linux-arm
runner: buildjet-4vcpu-ubuntu-2204-arm
target: aarch64-unknown-linux-gnu
container: quay.io/pypa/manylinux_2_24_aarch64
out-file: libtemporal_sdk_typescript_bridge.so
- platform: macos-x64
runner: macos-12
target: x86_64-apple-darwin
out-file: libtemporal_sdk_typescript_bridge.dylib
- platform: macos-arm
runner: macos-14
target: aarch64-apple-darwin
out-file: libtemporal_sdk_typescript_bridge.dylib
- platform: windows-x64
runner: windows-latest
target: x86_64-pc-windows-msvc
out-file: temporal_sdk_typescript_bridge.dll
name: Compile Native Binaries (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container }}
env:
# This is required to allow continuing usage of Node 16 for actions,
# as Node 20 won't run on the docker image we use for linux builds
# (Node 20 require glibc 2.28+, but container image has glibc 2.24).
# https://github.blog/changelog/2024-05-17-updated-dates-for-actions-runner-using-node20-instead-of-node16-by-default/
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
defaults:
run:
shell: bash
steps:
- name: 'Checkout code'
# FIXME: v4+ requires Node 20
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Cache index.node'
id: cached-artifact
# FIXME: v4+ requires Node 20
uses: actions/cache@v3
with:
path: ./packages/core-bridge/releases
key: corebridge-artifactcache-${{ matrix.platform }}-${{ hashFiles('./packages/core-bridge/**/Cargo.lock', './packages/core-bridge/**/*.rs') }}
- name: Install Rust
if: steps.cached-artifact.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Install protoc
if: steps.cached-artifact.outputs.cache-hit != 'true'
# FIXME: v3+ requires Node 20
uses: arduino/setup-protoc@v2
with:
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Rust Cargo and Build cache
if: steps.cached-artifact.outputs.cache-hit != 'true'
# FIXME: v2.7.2+ requires Node 20
uses: Swatinem/rust-cache@v2.7.1
with:
workspaces: packages/core-bridge -> target
prefix-key: corebridge-buildcache
shared-key: ${{ matrix.platform }}
env-vars: ''
save-if: env.IS_MAIN_OR_RELEASE == 'true'
- name: Compile rust code
if: steps.cached-artifact.outputs.cache-hit != 'true'
working-directory: ./packages/core-bridge
run: |
set -x
cargo build --release --target ${{ matrix.target }}
mkdir -p ./releases/${{ matrix.target }}
cp target/${{ matrix.target }}/release/${{ matrix.out-file }} ./releases/${{ matrix.target }}/index.node
- name: Print required GLIBC version
if: startsWith(matrix.platform, 'linux')
working-directory: ./packages/core-bridge
run: |
objdump -T ./releases/${{ matrix.target }}/index.node |
grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -V | tail -1
# FIXME: v4+ requires Node 20
- uses: actions/upload-artifact@v3
with:
name: corebridge-native-${{ matrix.platform }}
# Actual file will be named ${{ matrix.target }}/index.node
path: ./packages/core-bridge/releases/*/index.node
# Gather native binaries for all platforms and build TypeScript @temporalio/* packages.
# Upload the built packages as a Verdaccio repository.
build-packages:
needs:
- compile-native-binaries
name: Build Packages
strategy:
# Using a matrix here ensure that Rust-related actions below can be easily be copied from the
# compile-binaries job and that the Rust build cache will be usable
matrix:
include:
- platform: linux-x64
runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download core-bridge native libraries
# Need v3 here to stay compatible with the compile-native-binaries job.
uses: actions/download-artifact@v3-node20
with:
path: ./packages/core-bridge/releases/tmp
- name: Put native files into place
working-directory: ./packages/core-bridge/releases
run: |
mv tmp/corebridge-*/* ./
rm -rf tmp
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Get NPM cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Restore NPM cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
npm-main-${{ matrix.platform }}-
- name: Download dependencies
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors :(
run: |
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
- name: Compile code
run: npm run build -- --ignore @temporalio/core-bridge
- name: Publish to Verdaccio
run: node scripts/publish-to-verdaccio.js --registry-dir ./tmp/registry
- name: Save Verdaccio repo artifact
uses: actions/upload-artifact@v4
with:
name: verdaccio-repo
path: ./tmp/registry/storage
- name: Save NPM cache
uses: actions/cache/save@v4
# Only saves NPM cache from the main branch, to reduce pressure on the cache (limited to 10GB).
if: env.IS_MAIN_OR_RELEASE == 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
# Run integration tests. Uses the native binaries built in compile-native-binaries,
# but build `@temporalio/*` packages locally.
integration-tests:
needs:
- compile-native-binaries
strategy:
fail-fast: false
matrix:
node: [16, 18, 20]
platform: [linux-x64, linux-arm, macos-x64, macos-arm, windows-x64]
reuse-v8-context: [true, false]
server: [cli] # FIXME: Add 'cloud'
include:
- platform: linux-x64
runner: ubuntu-latest
- platform: linux-arm
runner: buildjet-4vcpu-ubuntu-2204-arm
- platform: macos-x64
runner: macos-12
- platform: macos-arm
runner: macos-14
- platform: windows-x64
runner: windows-latest
runs-on: ${{ matrix.runner }}
name: Run Integration Tests (${{ matrix.platform }}, Node ${{ matrix.node }}, Reuse V8 Context ${{ matrix.reuse-v8-context }})
defaults:
run:
shell: bash
steps:
- name: 'Checkout code'
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download core-bridge native libraries
# Need v3 here to stay compatible with the compile-native-binaries job.
uses: actions/download-artifact@v3-node20
with:
name: corebridge-native-${{ matrix.platform }}
path: ./packages/core-bridge/releases
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Restore NPM cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
npm-main-${{ matrix.platform }}-
- name: Download dependencies
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors :(
run: |
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
- name: Compile code
run: npm run build -- --ignore @temporalio/core-bridge
- name: Install Temporal CLI
if: matrix.server == 'cli'
uses: temporalio/setup-temporal@v0
- name: Run Temporal CLI
if: matrix.server == 'cli'
shell: bash
run: |
temporal server start-dev --headless &
- name: Run Tests
run: npm test
env:
RUN_INTEGRATION_TESTS: true
REUSE_V8_CONTEXT: ${{ matrix.reuse-v8-context }}
- name: Upload logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: integration-tests-${{ matrix.platform }}-node${{ matrix.node }}-${{ matrix.server }}-${{ matrix.reuse-v8-context && 'reuse' || 'noreuse' }}-logs
path: ${{ startsWith(matrix.platform, 'windows') && 'C:\\npm\\_logs\\' || '~/.npm/_logs/' }}
# Tests that npm init @temporalio results in a working worker and client
test-npm-init:
needs: build-packages
strategy:
fail-fast: false
matrix:
node: [16, 18, 20]
platform: [linux-x64, linux-arm, macos-x64, macos-arm, windows-x64]
sample: [hello-world, fetch-esm, hello-world-mtls]
server: [cli, cloud]
exclude:
# Exclude non-mtls tests on cloud
- sample: hello-world
server: cloud
# Exclude mtls tests on cli
- sample: hello-world-mtls
server: cli
- sample: fetch-esm
server: cloud
# FIXME: investigate why 'fetch-esm' always hangs on Windows
- sample: fetch-esm
platform: windows-x64
# Exclude cloud tests if we don't have cloud namespace and certs
- server: ${{ vars.TEMPORAL_CLIENT_NAMESPACE == '' && 'cloud' || '' }}
include:
- platform: linux-x64
runner: ubuntu-latest
- platform: linux-arm
runner: buildjet-4vcpu-ubuntu-2204-arm
- platform: macos-x64
runner: macos-12
- platform: macos-arm
runner: macos-14
- platform: windows-x64
runner: windows-latest
runs-on: ${{ matrix.runner }}
name: Run Samples Tests - ${{ matrix.sample }} (${{ matrix.platform }}, Node ${{ matrix.node }}, ${{ matrix.server }})
env:
TEMPORAL_CLIENT_CERT: ${{ secrets.TEMPORAL_CLIENT_CERT }}
TEMPORAL_CLIENT_KEY: ${{ secrets.TEMPORAL_CLIENT_KEY }}
steps:
- name: 'Checkout code'
uses: actions/checkout@v4
with:
# We don't need the core submodule here since won't build the project
submodules: false
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Restore NPM cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
npm-main-${{ matrix.platform }}-
# No need to compile anything, we just need the package ./scripts and their dependencies
- name: Install dependencies without compilation
run: |
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
- name: Restore Verdaccio repo artifact
uses: actions/download-artifact@v4
with:
name: verdaccio-repo
path: ./tmp/registry/storage
# Note: here, `npx create` fails on windows if shell is bash.
- name: Instantiate sample project using verdaccio artifacts
run: node scripts/init-from-verdaccio.js --registry-dir ./tmp/registry --sample https://github.com/temporalio/samples-typescript/tree/next/${{ matrix.sample }} --target-dir ${{ runner.temp }}/example
- name: Install Temporal CLI
if: matrix.server == 'cli'
uses: temporalio/setup-temporal@v0
- name: Run Temporal CLI
if: matrix.server == 'cli'
shell: bash
run: |
temporal server start-dev --headless &
# We write the certs to disk because it serves the sample. Written into /tmp/temporal-certs
- name: Create certs dir
shell: bash
run: node scripts/create-certs-dir.js "${{ runner.temp }}/certs"
if: matrix.server == 'cloud'
- name: Test run a workflow (non-cloud)
run: node scripts/test-example.js --work-dir "${{ runner.temp }}/example"
shell: bash
if: matrix.server == 'cli'
- name: Test run a workflow (cloud)
run: node scripts/test-example.js --work-dir "${{ runner.temp }}/example"
shell: bash
env:
# These env vars are used by the hello-world-mtls sample
TEMPORAL_ADDRESS: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}.tmprl.cloud
TEMPORAL_NAMESPACE: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}
TEMPORAL_CLIENT_CERT_PATH: ${{ runner.temp }}/certs/client.pem
TEMPORAL_CLIENT_KEY_PATH: ${{ runner.temp }}/certs/client.key
TEMPORAL_TASK_QUEUE: ${{ format('{0}-{1}-{2}', matrix.platform, matrix.node, matrix.sample) }}
if: matrix.server == 'cloud'
- name: Destroy certs dir
if: always()
shell: bash
run: rm -rf ${{ runner.temp }}/certs
continue-on-error: true
# Runs the features repo tests with this repo's current SDK code
# FIXME: Update this job to reuse native build artifacts from compile-native-binaries
features-tests:
name: Features Tests
uses: temporalio/features/.github/workflows/typescript.yaml@main
with:
typescript-repo-path: ${{github.event.pull_request.head.repo.full_name}}
version: ${{github.event.pull_request.head.ref}}
version-is-repo-ref: true
features-repo-ref: sdk-1403-ts-startUpdate-require-wait-stage
stress-tests-no-reuse-context:
name: Stress Tests (No Reuse V8 Context)
# FIXME: Update this job to reuse native build artifacts from compile-native-binaries
uses: ./.github/workflows/stress.yml
with:
test-type: ci-stress
test-timeout-minutes: 20
reuse-v8-context: false
stress-tests-reuse-context:
name: Stress Tests (Reuse V8 Context)
# FIXME: Update this job to reuse native build artifacts from compile-native-binaries
uses: ./.github/workflows/stress.yml
with:
test-type: ci-stress
test-timeout-minutes: 20
reuse-v8-context: true
# Run TS linting and ts-prune to find unused code
lint-and-prune:
name: Lint and Prune
strategy:
# Using a matrix here ensure that Rust-related actions below can be easily be copied from the
# compile-binairies job and that the Rust build cache will be usable
matrix:
include:
- platform: linux-x64
runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Restore NPM cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
npm-main-${{ matrix.platform }}-
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Rust Cargo and Build cache
uses: Swatinem/rust-cache@v2
with:
workspaces: packages/core-bridge -> target
prefix-key: corebridge-buildcache
shared-key: ${{ matrix.platform }}
env-vars: ''
save-if: false
- name: Download dependencies
run: |
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
# eslint-import-resolver-typescript requires packages to be built
- name: Compile all non-rust code
run: npm run build -- --ignore @temporalio/core-bridge
- run: npm run lint.check
- run: npm run lint.prune
build-docs:
name: Build Docs
strategy:
# Using a matrix here ensure that Rust-related actions below can be easily be copied from the
# compile-binairies job and that the Rust build cache will be usable
matrix:
include:
- platform: linux-x64
runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Restore NPM cache
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
npm-main-${{ matrix.platform }}-
# Don't build during install phase since we're going to explicitly build
- name: Download dependencies
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
run: |
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
- run: npm run build -- --ignore @temporalio/core-bridge
# Do docs stuff (only on one host)
- name: Build docs
run: npm run docs
env:
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
- name: Deploy prod docs # TODO: only deploy prod docs when we publish a new version
if: env.IS_MAIN_OR_RELEASE == 'true'
run: npx vercel deploy packages/docs/build -t ${{ secrets.VERCEL_TOKEN }} --name typescript --scope temporal --prod --yes
# FIXME: This is not working properly, and should probably be done only from the main branch anyway
# (and "Deploy prod docs" should only be done when we publish a new release)
# - name: Deploy draft docs
# # Don't run on forks, since secrets won't be available, and command will fail
# if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.ref != 'refs/heads/main'
# run: npx vercel deploy packages/docs/build -t ${{ secrets.VERCEL_TOKEN }} --name typescript --scope temporal --yes