-
Notifications
You must be signed in to change notification settings - Fork 447
467 lines (403 loc) · 15.3 KB
/
Copy pathsdk-typescript.yml
File metadata and controls
467 lines (403 loc) · 15.3 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
name: typescript
on:
pull_request:
paths:
- ".github/**"
- "api/**"
- "api-contracts/**"
- "internal/**"
- "pkg/**"
- "sdks/typescript/**"
push:
branches:
- main
paths:
- "sdks/typescript/**"
defaults:
run:
working-directory: ./sdks/typescript
jobs:
lint:
runs-on: ubicloud-standard-4
strategy:
matrix:
include:
- package-manager: pnpm
install-cmd: pnpm install
lint-cmd: pnpm lint:check
tsc-cmd: pnpm exec tsc
unit-test-cmd: pnpm test:unit
e2e-test-cmd: pnpm test:e2e
- package-manager: bun
install-cmd: bun install
lint-cmd: bun run lint:check
tsc-cmd: bunx tsc
unit-test-cmd: bun run test:unit
e2e-test-cmd: bun run test:e2e
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
submodules: recursive
- name: Install pnpm
if: matrix.package-manager == 'pnpm'
run: npm install -g pnpm@10.16.1
- name: Get pnpm store directory
if: matrix.package-manager == 'pnpm'
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
if: matrix.package-manager == 'pnpm'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Bun
if: matrix.package-manager == 'bun'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
cache: true
cache-dependency-path: sdks/typescript/pnpm-lock.yaml
- name: Install dependencies
run: ${{ matrix.install-cmd }}
- name: Lint
run: ${{ matrix.lint-cmd }}
- name: Type check
run: ${{ matrix.tsc-cmd }}
test-unit:
runs-on: ubicloud-standard-4
strategy:
matrix:
include:
- package-manager: pnpm
install-cmd: pnpm install
lint-cmd: pnpm lint:check
tsc-cmd: pnpm exec tsc
unit-test-cmd: pnpm test:unit
e2e-test-cmd: pnpm test:e2e
- package-manager: bun
install-cmd: bun install
lint-cmd: bun run lint:check
tsc-cmd: bunx tsc
unit-test-cmd: bun run test:unit
e2e-test-cmd: bun run test:e2e
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
submodules: recursive
- name: Install pnpm
if: matrix.package-manager == 'pnpm'
run: npm install -g pnpm@10.16.1
- name: Get pnpm store directory
if: matrix.package-manager == 'pnpm'
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
if: matrix.package-manager == 'pnpm'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Bun
if: matrix.package-manager == 'bun'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
cache: true
cache-dependency-path: sdks/typescript/pnpm-lock.yaml
- name: Install dependencies
run: ${{ matrix.install-cmd }}
- name: Unit tests
run: ${{ matrix.test-cmd }}
test-e2e:
runs-on: ubicloud-standard-4
timeout-minutes: 20
strategy:
matrix:
include:
- package-manager: pnpm
install-cmd: pnpm install
lint-cmd: pnpm lint:check
tsc-cmd: pnpm exec tsc
unit-test-cmd: pnpm test:unit
e2e-test-cmd: pnpm test:e2e
- package-manager: bun
install-cmd: bun install
lint-cmd: bun run lint:check
tsc-cmd: bunx tsc
unit-test-cmd: bun run test:unit
e2e-test-cmd: bun run test:e2e
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Sync Submodule Branch
shell: bash
run: |
./branch-sync.sh
- name: Install Protoc
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
with:
version: "25.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26"
- name: Install pnpm
if: matrix.package-manager == 'pnpm'
run: npm install -g pnpm@10.16.1
- name: Get pnpm store directory
if: matrix.package-manager == 'pnpm'
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
if: matrix.package-manager == 'pnpm'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Bun
if: matrix.package-manager == 'bun'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
cache: true
cache-dependency-path: sdks/typescript/pnpm-lock.yaml
- name: Install Atlas
run: |
curl -sSf https://atlasgo.sh | sh
- name: Compose
working-directory: .
run: docker compose up -d
- name: Install dependencies
run: ${{ matrix.install-cmd }}
- name: Generate
working-directory: .
run: |
export DATABASE_URL="postgresql://hatchet:hatchet@127.0.0.1:5431/hatchet"
go run ./cmd/hatchet-migrate
- name: Setup
working-directory: .
run: |
export SEED_DEVELOPMENT=true
export SERVER_PORT=8080
export SERVER_URL=http://localhost:8080
export SERVER_AUTH_COOKIE_DOMAIN=localhost
export SERVER_AUTH_COOKIE_INSECURE=true
export SERVER_MSGQUEUE_RABBITMQ_URL="amqp://user:password@localhost:5672/"
export SERVER_LOGGER_LEVEL=info
export SERVER_LOGGER_FORMAT=console
export DATABASE_LOGGER_LEVEL=warn
export DATABASE_LOGGER_FORMAT=console
go run ./cmd/hatchet-admin quickstart
go run ./cmd/hatchet-engine --config ./generated/ 2>&1 | tee $GITHUB_WORKSPACE/engine.log &
go run ./cmd/hatchet-api --config ./generated/ 2>&1 | tee $GITHUB_WORKSPACE/api.log &
sleep 30
- name: E2E tests
run: |
cd ../..
export HATCHET_CLIENT_TOKEN="$(go run ./cmd/hatchet-admin token create --config ./generated/ --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52)"
cd sdks/typescript
export HATCHET_CLIENT_TLS_ROOT_CA_FILE=../../certs/ca.cert
export HATCHET_CLIENT_TLS_SERVER_NAME=cluster
export NODE_TLS_REJECT_UNAUTHORIZED=0
${{ matrix.test-cmd }}
- name: Upload engine logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdk-typescript-engine-logs-${{ matrix.package-manager }}
path: engine.log
- name: Upload API logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdk-typescript-api-logs-${{ matrix.package-manager }}
path: api.log
old-engine-new-sdk:
runs-on: ubicloud-standard-4
timeout-minutes: 20
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
fetch-tags: true
- name: Start Docker dependencies
working-directory: .
run: docker compose up -d
- name: Determine latest stable release tag
working-directory: .
run: |
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
if [ -z "$LATEST_TAG" ]; then
echo "ERROR: No stable release tag found"
exit 1
fi
echo "Latest stable tag: $LATEST_TAG"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Pull release images
working-directory: .
run: docker compose -f docker-compose.yml -f docker-compose.release.yml pull hatchet-migrate hatchet-admin hatchet-engine hatchet-api
- name: Run migrations
working-directory: .
run: docker compose -f docker-compose.yml -f docker-compose.release.yml run --rm hatchet-migrate
- name: Setup config and seed database
working-directory: .
run: |
mkdir -p generated
docker compose -f docker-compose.yml -f docker-compose.release.yml run --rm \
hatchet-admin /hatchet/hatchet-admin quickstart --skip certs --generated-config-dir /hatchet/generated
- name: Generate API token
working-directory: .
run: |
TOKEN=$(docker compose -f docker-compose.yml -f docker-compose.release.yml run -T --rm \
hatchet-admin /hatchet/hatchet-admin token create --config /hatchet/generated --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52)
echo "HATCHET_CLIENT_TOKEN=$TOKEN" >> $GITHUB_ENV
- name: Start engine and API
working-directory: .
run: |
docker compose -f docker-compose.yml -f docker-compose.release.yml up -d hatchet-engine hatchet-api
sleep 30
- name: Install pnpm
run: npm install -g pnpm@10.16.1
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Set HATCHET_CLIENT_NAMESPACE
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
echo "HATCHET_CLIENT_NAMESPACE=old-engine-new-sdk-ts-${SHORT_SHA}" >> $GITHUB_ENV
- name: Run e2e tests
id: run-tests
continue-on-error: true
env:
HATCHET_CLIENT_TLS_STRATEGY: none
HATCHET_CLIENT_WORKER_HEALTHCHECK_ENABLED: "false"
NODE_TLS_REJECT_UNAUTHORIZED: "0"
run: |
echo "Testing current SDK against engine ${{ env.LATEST_TAG }}"
echo "Using HATCHET_CLIENT_NAMESPACE: $HATCHET_CLIENT_NAMESPACE"
pnpm test:e2e
- name: Collect engine logs
if: always()
working-directory: .
run: docker compose -f docker-compose.yml -f docker-compose.release.yml logs hatchet-engine > /tmp/engine.log 2>&1 || true
- name: Upload engine logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.HATCHET_CLIENT_NAMESPACE }}-engine-logs
path: /tmp/engine.log
- name: Collect API logs
if: always()
working-directory: .
run: docker compose -f docker-compose.yml -f docker-compose.release.yml logs hatchet-api > /tmp/api.log 2>&1 || true
- name: Upload API logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.HATCHET_CLIENT_NAMESPACE }}-api-logs
path: /tmp/api.log
- name: Comment on PR
if: steps.run-tests.outcome == 'failure' && github.event_name == 'pull_request'
run: |
gh pr comment ${{ github.event.pull_request.number }} \
--body "⚠️ **Optional test failure**: The \`old-engine-new-sdk\` (TypeScript) job failed on this PR. This check is non-mandatory and does not block merging, but may be worth investigating. [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
env:
GH_TOKEN: ${{ github.token }}
- name: Teardown
if: always()
working-directory: .
run: docker compose -f docker-compose.yml -f docker-compose.release.yml down
publish:
runs-on: ubicloud-standard-4
needs: [lint, test-unit, test-e2e]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
submodules: recursive
- name: Install pnpm
run: npm install -g pnpm@10.16.1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build and Publish SDK
run: |
VERSION=$(jq '.version' package.json)
CURRENT_NPM_VERSION=$(pnpm view @hatchet-dev/typescript-sdk version)
if [[ "$VERSION" == "$CURRENT_NPM_VERSION" ]]; then
echo "Version has not changed. Skipping publish."
exit 0
fi
## If the version contains `alpha`, it's an alpha version
## and we should tag it as such.=
if [[ "$VERSION" == *alpha* ]]; then
pnpm publish:ci:alpha
else
pnpm publish:ci
fi
echo "VERSION_TAG=$NEW_VERSION" >> $GITHUB_ENV
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Generate release notes"
if: env.VERSION_TAG != ''
working-directory: ${{ github.workspace }}
run: ./hack/ci/release-notes.sh typescript > ./release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Release"
if: env.VERSION_TAG != ''
working-directory: ${{ github.workspace }}
run: |
gh release create "ts/${VERSION_TAG}" \
--target "$GITHUB_SHA" \
--title "Typescript SDK ${VERSION_TAG}" \
--notes-file ./release_notes.md \
--latest=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}