Repository navigation
828 lines (734 loc) · 40.3 KB
/
Copy pathtests.yml
File metadata and controls
828 lines (734 loc) · 40.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
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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
name: Test JS
on:
push:
branches:
- 'main'
pull_request:
branches:
- "**"
# Plan documents under docs/plans/ need none of these jobs. Later patterns
# win, so the negation has to come after the catch-all.
paths:
- '**'
- '!docs/plans/**'
jobs:
# Biome format + lint. Its own job (no DB, no credentials, node-agnostic) so it
# surfaces as a distinct check and runs once rather than per Node matrix leg.
# Gates on ERRORS only — warnings are allowed, so the `no-type-erasing-assertions`
# plugin (at `warn`) surfaces new `as any`/`never`/`unknown` without blocking.
# Tightening to fail on warnings is tracked in #625.
lint:
name: Lint (Biome)
runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache
timeout-minutes: 10
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- uses: pnpm/[email protected]
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/[email protected]
with:
# Node 24 is the supply-chain hardening baseline every pnpm-using job
# must pin (enforced by e2e/tests/supply-chain.e2e.test.ts). Lint is
# runtime-agnostic, so a single pinned version is fine.
node-version: 24
cache: 'pnpm'
# node-pty's install hook falls back to `node-gyp rebuild` when no
# linux-x64 prebuild matches; pnpm/action-setup v6 no longer ships it.
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Biome check (format + lint)
run: pnpm run code:check
run-tests:
name: Run Tests (Node ${{ matrix.node-version }})
runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache
timeout-minutes: 25
strategy:
matrix:
node-version: [24, 26]
postgres-version: [16, 17]
exclude:
- node-version: 24
postgres-version: 17
- node-version: 26
postgres-version: 16
# Postgres + EQL for the integration tests. Official EQL image —
# PostgreSQL 16 and 17 with EQL pre-installed via
# /docker-entrypoint-initdb.d. Keeping one supported Node line on each
# server version exercises the pre-PG17 attstattarget representation
# without adding a third full test leg.
# Pinned to eql-2.3.1 to match the EQL payload format the code emits
# (protect-ffi 0.23.x); bump in lockstep with the protect-ffi upgrade.
services:
postgres:
image: ghcr.io/cipherstash/postgres-eql:${{ matrix.postgres-version }}-2.3.1
env:
POSTGRES_USER: cipherstash
POSTGRES_PASSWORD: password
POSTGRES_DB: cipherstash
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U cipherstash -d cipherstash"
--health-interval 2s
--health-timeout 5s
--health-retries 20
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- uses: pnpm/[email protected]
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
# node-pty's install hook falls back to `node-gyp rebuild` when no
# linux-x64 prebuild matches. pnpm/action-setup v6 no longer ships
# node-gyp on PATH, so install it explicitly.
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Fail loudly if any live-test credential is missing, so the v3 live
# matrix (and every other `describeLive` suite) can't silently skip.
# Before the binding build below, not after: this costs seconds and that
# costs minutes on a cold cache.
- name: Require CipherStash secrets
uses: ./.github/actions/require-cs-secrets
with:
workspace-crn: ${{ vars.CS_WORKSPACE_CRN }}
client-id: ${{ vars.CS_CLIENT_ID }}
client-key: ${{ secrets.CS_CLIENT_KEY }}
client-access-key: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
# `pnpm run test` below runs the `languages/typescript/packages/stack` suites, and only 8 of
# those 120 files mock `@cipherstash/protect-ffi` — the rest load
# `index.node`, which nothing else in this job produces.
#
# NOT for protect-ffi's own suite, though vendoring it did add
# `@cipherstash/protect-ffi#test` to `turbo test --filter './languages/typescript/packages/**' --filter './packages/**'`.
# That suite must pass with no binding at all (its `build` is `tsc` and
# its `test` is deliberately cargo-free), and `src/lintWiring.test.ts`
# re-runs it here with the artifact hidden to keep that true — this job
# having a binding is exactly why that nested run is the only place the
# artifact-free path gets exercised in CI.
#
# The type steps below need `lib/`: they call package scripts directly,
# so turbo's `^build` never runs and protect-ffi's declarations resolve
# to nothing. No `wasm: true` — every `wasm-inline` unit test either
# mocks the module or asserts on the bundle graph.
- name: Build the protect-ffi binding
uses: ./.github/actions/build-ffi-binding
# The SDK, stash and wizard suites below load @cipherstash/auth's napi
# module, and so does its own vitest suite.
- name: Build the @cipherstash/auth binding
uses: ./.github/actions/build-auth-binding
# `pnpm run test` below also runs the @cipherstash/profile vitest suite,
# which loads the napi module. Its `test` script does not build it, so
# cargo stays off the default `test` path; this step builds it, as the
# step above does for @cipherstash/auth. `build:debug` writes its typings
# to the committed `native.d.ts`, so the build leaves the tree clean;
# tests-crates.yml holds it to that, and runs the same suites against the
# pinned Rust.
- name: Build the profile node binding
run: pnpm --filter @cipherstash/profile run build:debug
- name: Type tests (stack)
run: pnpm exec turbo run test:types --filter @cipherstash/stack
# The v3 domain catalog lives in the test kit, and its
# `satisfies Record<EqlV3TypeName, DomainSpec>` is what forces a new SDK
# domain to be covered. That check only fires under `tsc`, so without this
# step a domain added to stack would slip through untested.
- name: Type tests (test-kit — enforces v3 domain coverage)
run: pnpm exec turbo run test:types --filter @cipherstash/test-kit
# The adapter packages carry their own `.test-d.ts` type-contract guards
# (the M1 client-surface / #622 erasure guards, the Supabase key-set
# gating). They moved here from `@cipherstash/stack` in the #627 split but
# were never wired into CI, so type-level regressions in them went
# undetected — run them explicitly.
- name: Type tests (stack-drizzle)
run: pnpm exec turbo run test:types --filter @cipherstash/stack-drizzle
- name: Type tests (stack-supabase)
run: pnpm exec turbo run test:types --filter @cipherstash/stack-supabase
# prisma-next's operator-capability gating is proven by `.test-d.ts`
# `@ts-expect-error` assertions (an unsupported operator on a column
# must be a compile error). Those only fire when tsc processes them,
# so the package `typecheck` must run — and be required — here (#684).
# Its tsconfig resolves stack subpaths to SOURCE — but NOT
# `@cipherstash/eql`, which it reaches through the package `exports` map
# at `./dist/sql.d.ts`. That used to be a registry tarball with `dist/`
# already in it, so a bare `pnpm --filter` resolved it whatever CI had
# built. The EQL subtree import made it a workspace package whose `dist/`
# is a build output, and this step became the first in the job to need
# something built — failing `TS2307` on three files.
#
# Through turbo, so `typecheck`'s `dependsOn: ["^build"]` builds
# `@cipherstash/eql` first. This is the trap
# `workflow-turbo-build-deps.test.mjs` was written for; the step was on
# its grandfathered KNOWN_BARE list, and the import is what collected.
- name: Typecheck (prisma-next — enforces v3 operator-capability gating)
run: pnpm exec turbo run typecheck --filter @cipherstash/stack-prisma
# `languages/typescript/packages/bench` is a live importer of `@cipherstash/stack` and
# `@cipherstash/stack-drizzle`, but it has no `test` script (its suites
# need a database), so `pnpm run test` never reaches it and an adapter
# rename could break it unnoticed. Its `build` is `tsc --noEmit`, and
# turbo's `^build` builds the two adapters first. This also runs in the
# Bun job's full `turbo build`, but that job swallows its own test
# failures — the importer guard should not depend on it.
- name: Typecheck (bench — guards the stack/stack-drizzle importers)
run: pnpm exec turbo run build --filter @cipherstash/bench
# The wizard is built by tsup, which transpiles without typechecking, so
# nothing here caught the three `auth.AutoStrategy` resolution errors that
# sat in `main` until #771. Gate it so they cannot come back silently.
- name: Typecheck (wizard)
run: pnpm exec turbo run typecheck --filter @cipherstash/wizard
# `languages/typescript/examples/*` are standalone apps outside the `./languages/typescript/packages/*` filter that
# root `build`/`test` use, so nothing in CI compiled them. `languages/typescript/examples/basic`
# had been broken since the v2 removal deleted `encryptedType` and the v2
# `encryptedSupabase` — on a fully green board. Gate it through turbo so
# `^build` builds stack/stack-drizzle/stash first.
- name: Typecheck (languages/typescript/examples/basic — guards the v3 stack/stack-drizzle importers)
run: pnpm exec turbo run typecheck --filter @cipherstash/basic-example
# The rest of the surfaces that were compiling nowhere. Each of these has
# a `tsconfig.json` that covers its `src` and tests, and each was already
# clean — so they are gated now, before they drift. They resolve their
# workspace dependencies through `dist/*.d.ts`, hence the turbo filters
# (`^build` builds the dependencies first).
#
# NOT fully gated yet, and deliberately: `@cipherstash/stack` (147 errors
# under its own tsconfig), `stash` (21) and `@cipherstash/stack-supabase`
# (11). Their `test:types` scripts only cover `__tests__/**/*.test-d.ts`,
# so `src` and the runtime test suites compile nowhere.
# `@cipherstash/stack-drizzle` now type-tests every `integration/**`
# source as well; its remaining `src` / runtime-test errors share one
# root cause — `V3_MATRIX`'s `indexes` union in `@cipherstash/test-kit`
# — see #778.
- name: Typecheck (migrate)
run: pnpm exec turbo run typecheck --filter @cipherstash/migrate
- name: Typecheck (nextjs)
run: pnpm exec turbo run typecheck --filter @cipherstash/nextjs
- name: Typecheck (languages/typescript/examples/prisma — guards the prisma-next importers)
run: pnpm exec turbo run typecheck --filter @cipherstash/prisma-example
- name: Typecheck (e2e)
run: pnpm exec turbo run typecheck --filter @cipherstash/e2e
# The protect-ffi live integration suite, compiled but NOT run here — it
# needs Docker and CipherStash credentials, so it runs in
# integration-protect-ffi.yml behind a `paths:` filter.
#
# Which is exactly why this step exists. The suite's `tsc` used to ride
# along on its own `npm test`; CI invoked vitest directly, so it compiled
# nowhere, and the credentialed job is path-filtered — a repo-wide change
# that broke the suite's types (an `@cipherstash/auth` catalog bump moving
# `AccessKeyStrategy.create` to a `Result`, say) would not have started
# anything that noticed. Cheap: `tsc --noEmit` over the suite, no
# credentials, no database.
#
# That includes the two `.cjs` fixtures — the tsconfig sets `checkJs` and
# globs them deliberately. One of them is a real `AccessKeyStrategy` call
# site and was among the four the auth bump broke, so a `tests/**/*.ts`
# scope would have left this step green over it.
- name: Typecheck (protect-ffi integration suite)
run: >
pnpm exec turbo run typecheck --filter @cipherstash/ffi-integration-tests
# Everything else typechecks against SOURCE. This one reads the emitted
# `.d.ts`, which is what customers consume — and where typed `encryptQuery`
# sat broken for every column through the whole rc series, because `tsc`
# strips private member types and that was the only place the column's
# domain parameter appeared bare.
- name: Typecheck (stack — emitted declarations, not source)
run: pnpm exec turbo run test:types:dist --filter @cipherstash/stack
# `stash init` writes a client file into the user's project and tells them
# not to hand-edit it. Nothing compiled that file, so tightening
# `Encryption` to require a non-empty schema set left every `stash init`
# emitting a project that fails its first `tsc` — with CI green (#772
# review). The fixtures are pinned byte-for-byte to the generator by
# `placeholder-client-fixture.test.ts`.
# Through turbo, not `pnpm run` — the fixtures import `@cipherstash/stack/v3`,
# so this needs that package BUILT. Invoked directly it passed only because
# earlier steps in this job happen to build it via their own `^build`; drop
# or reorder those (they read as guards for other packages, so they look
# independently removable) and this fails `TS2307`, which reads as "the
# scaffold is broken" rather than "you forgot to build" (#787 review).
- name: Typecheck (stash init's scaffolded client)
run: pnpm exec turbo run typecheck:scaffold --filter stash
- name: Lint — no hardcoded package-manager runners
run: pnpm run lint:runners
# The gates above only mean something if they compile source. A tsconfig
# with no `include` globs `**/*`, which sweeps the package's own `dist/`
# into the program — and whether `dist/` exists during a gate depends on
# what an earlier step built transitively, so the gate compiles a
# different program in CI than it does locally.
- name: Lint — typecheck gates compile source, not build output
run: pnpm run lint:typecheck-scope
# Deleting or renaming a package leaves `packages/<name>` references
# dangling in docs and CI config. Nothing else catches it (#760 review).
- name: Lint — no references to deleted package directories
run: pnpm run lint:package-paths
# `eql-bindings` emits EQL payloads; `@cipherstash/eql` carries the SQL
# that stores them. Both live here now and release at one lockstep
# version. A registry pin on either lets them drift apart — it compiles,
# it passes every suite, and it fails in a customer's database.
- name: Lint — EQL resolves in-tree, not from a registry
run: pnpm run lint:eql-pins
# THE SAME GATE release.yml RUNS, one merge earlier.
#
# `changeset publish` publishes every public workspace package whose
# version is absent from npm — with no dependency ordering, and a failed
# publish returns a result rather than throwing, so it does not stop the
# siblings that depend on it. A merge can therefore ARM a release that
# cannot succeed, and this repository has done it. `@cipherstash/eql` is
# published from cipherstash/encrypt-query-language, so a version bumped
# in this workspace cannot be published from here — while `languages/typescript/packages/cli`
# and `languages/typescript/packages/stack-prisma` carry it in RUNTIME dependencies, so pnpm
# packs whatever version this tree holds into both tarballs. Bump it past
# what the registry carries and both ship a range no published version
# satisfies, in tarballs that publish fine. That is what the hand-applied
# 3.0.5 bump did; upstream has since released 3.0.5 and it cleared on its
# own. The CONDITION is what this step is for — the verdict is whatever it
# prints on the day.
#
# The gate in release.yml blocks the publish, which is the load-bearing
# half. This step is the half that says so BEFORE the merge rather than
# after it, which is the difference between a red pull request and a red
# main. Same script, same verdict, no second copy to drift.
#
# It talks to the registry, in a job that already installs the whole
# workspace from it — so this adds a class of dependency the job does not
# already have, only a few more requests. A lookup that fails for any
# reason other than a 404 throws rather than being read as "published".
- name: Lint — this tree can be published, and installed
run: pnpm run release:gate
- name: Test — lint script self-tests
run: pnpm run test:scripts
- name: Create .env file in ./languages/typescript/packages/stack/
run: |
touch ./languages/typescript/packages/stack/.env
echo "CS_WORKSPACE_CRN=${{ vars.CS_WORKSPACE_CRN }}" >> ./languages/typescript/packages/stack/.env
echo "CS_CLIENT_ID=${{ vars.CS_CLIENT_ID }}" >> ./languages/typescript/packages/stack/.env
echo "CS_CLIENT_KEY=${{ secrets.CS_CLIENT_KEY }}" >> ./languages/typescript/packages/stack/.env
echo "CS_CLIENT_ACCESS_KEY=${{ secrets.CS_CLIENT_ACCESS_KEY }}" >> ./languages/typescript/packages/stack/.env
echo "DATABASE_URL=postgres://cipherstash:password@localhost:5432/cipherstash" >> ./languages/typescript/packages/stack/.env
# Run TurboRepo tests
#
# STASH_TEST_DATABASE_URL points the CLI's live-Postgres suites
# (`languages/typescript/packages/cli/src/**/__tests__/**.live.test.ts`) at this job's
# service container — without it they self-skip, and the only guard on
# the `stash eql verify` parser↔catalog spelling seam
# (`installer/__tests__/verify.live.test.ts`) would run in no CI
# workflow at all: a routine `@cipherstash/eql` bump could then make
# every `stash eql install` fail with phantom damage, on green CI.
# Most suites need Postgres only. The encrypted-index upgrade suite also
# loads this job's CipherStash credentials from languages/typescript/packages/stack/.env and
# uses the binding built above to create genuine ciphertext. The verify
# suite installs EQL v3 into its own schemas, which coexists
# with the image's pre-installed EQL v2 that the stack tests use.
# They share that one database, so the CLI vitest config runs them
# serially (the `live` project uses a single fork —
# verify.live's bundle install opens with DROP SCHEMA … CASCADE, which
# races destructively under the other suites in parallel forks).
# (`supabase-push.live.test.ts` gates on different env vars and still
# skips here — it needs the Supabase CLI binary.)
#
# PG_TEST_URL runs `@cipherstash/migrate`'s integration suites (forward
# and reverse backfill: resume, force obligation, concurrent dual-writes).
# They self-skip without it. They need no credentials, but each opens
# with DROP SCHEMA cipherstash CASCADE, so they get a database of their
# own: turbo runs packages in parallel, and in the shared one that drop
# would race the CLI's live suites.
- name: Create the migrate integration database
run: psql "postgres://cipherstash:password@localhost:5432/cipherstash" -c 'CREATE DATABASE migrate_test'
- name: Run tests
run: pnpm run test
env:
STASH_TEST_DATABASE_URL: postgres://cipherstash:password@localhost:5432/cipherstash
PG_TEST_URL: postgres://cipherstash:password@localhost:5432/migrate_test
# CLI E2E tests drive the built `dist/bin/stash.js` through a real
# pseudo-terminal via node-pty. Run via turbo so the `^build` + `build`
# deps declared on the `test:e2e` task are honored.
- name: Run CLI E2E tests
run: pnpm exec turbo run test:e2e --filter stash
e2e-tests:
name: Run E2E Tests
runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache
# The migration harness's live Runs take most of this job's time; the
# limit covers them plus the job's other suites, with headroom.
timeout-minutes: 30
# Auth-dependent suites in `e2e/` skip themselves unless these env vars
# are set. We expose them at the job level so the wizard subprocess
# picks them up via `process.env`.
env:
CS_WORKSPACE_CRN: ${{ vars.CS_WORKSPACE_CRN }}
CS_CLIENT_ID: ${{ vars.CS_CLIENT_ID }}
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
# No CS_ZEROKMS_HOST / CS_CTS_HOST: current clients derive both from the
# CRN, and a pinned region points the shared credentials at the wrong
# deployment (see integration-protect-ffi.yml).
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- uses: pnpm/[email protected]
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: 24
cache: 'pnpm'
# node-pty's install hook falls back to `node-gyp rebuild` when no
# linux-x64 prebuild matches. pnpm/action-setup v6 no longer ships
# node-gyp on PATH, so install it explicitly.
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Auth-dependent `e2e/` suites skip themselves without these vars — a
# silent skip would hide regressions behind a green job. Fail loudly.
- name: Require CipherStash secrets
uses: ./.github/actions/require-cs-secrets
with:
workspace-crn: ${{ vars.CS_WORKSPACE_CRN }}
client-id: ${{ vars.CS_CLIENT_ID }}
client-key: ${{ secrets.CS_CLIENT_KEY }}
client-access-key: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
# The protect-dynamodb compatibility step at the end of this job
# encrypts against the live service through `@cipherstash/stack`, so it
# needs `index.node`; turbo's `^build` only gets as far as protect-ffi's
# `build` (tsc → `lib/`), which is the half that does not encrypt
# anything. (`tests/prisma-example-readme.e2e.test.ts` would need it too,
# but under turbo's strict env mode the job-level CS_* never reach it,
# so it skips.)
#
# After the pre-flight above, per
# scripts/__tests__/ffi-binding-step-order.test.mjs. No `wasm: true` —
# nothing in `e2e/tests/**` loads the WASM build (the Deno smoke test that
# does lives in `e2e/wasm/` and runs in `wasm-e2e-tests`).
- name: Build the protect-ffi binding
id: ffi-binding
uses: ./.github/actions/build-ffi-binding
- name: Build the @cipherstash/auth binding
id: auth-binding
uses: ./.github/actions/build-auth-binding
# Docker Hub refuses pulls without a login after too many from one
# address, and RunsOn machines reach that limit. With either secret empty,
# as on a fork's pull request, this step does nothing and pulls stay
# anonymous. scripts/__tests__/workflow-docker-hub-login.test.mjs
# requires it.
- name: Log in to Docker Hub
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
set -euo pipefail
if [ -z "$DOCKER_HUB_USERNAME" ] || [ -z "$DOCKER_HUB_PASSWORD" ]; then
echo "No Docker Hub credentials, so image pulls stay anonymous."
exit 0
fi
printf '%s' "$DOCKER_HUB_PASSWORD" |
docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
# Run the standalone `e2e/` workspace via turbo so the `^build`
# dep on the `test:e2e` task builds cli + wizard first. CLI's own
# E2E (`languages/typescript/packages/cli/tests/e2e/**`) is covered by the `run-tests`
# job above; we filter to the new workspace here to avoid duplication.
- name: Run E2E tests
run: pnpm exec turbo run test:e2e --filter @cipherstash/e2e
# The step above runs under turbo's strict env mode, which filters out
# every env var `turbo.json` does not declare, so the job-level CS_*
# never reach vitest there and auth-gated suites skip. The
# protect-dynamodb compatibility suite proves a migration claim made to
# customers, so the default e2e config leaves it out and it runs here
# with `--env-mode=loose`, which lets the credentials through. It fails
# rather than skips if they are missing.
- name: Run the protect-dynamodb compatibility suite
run: pnpm exec turbo run test:protect-compat --filter @cipherstash/e2e --env-mode=loose
# The DynamoDB <-> Postgres cross-store suite moves protect-dynamodb
# 6.0.1 items into EQL v3 columns and back, so it needs a database.
# `integration-db` gives this job its own compose project and ephemeral
# port; the suite installs EQL v3 itself through the real
# `stash eql install`. Loose env mode for the same reason as above.
# The suite is independent of the preceding test suites, but still
# requires both native bindings. A failed build must not start the DB
# and produce a second set of missing-binding errors.
- name: Start postgres
id: db
if: ${{ !cancelled() && steps.ffi-binding.outcome == 'success' && steps.auth-binding.outcome == 'success' }}
uses: ./.github/actions/integration-db
with:
db: postgres
- name: Run the DynamoDB <-> Postgres cross-store suite
if: ${{ !cancelled() && steps.db.outcome == 'success' }}
run: pnpm exec turbo run test:protect-crossover --filter @cipherstash/e2e --env-mode=loose
env:
DATABASE_URL: ${{ steps.db.outputs.database-url }}
# Deterministic Fake Migrators only: no model credentials or token spend.
# The live suites read HARNESS_LIVE; migration-harness.yml runs the
# rest of the self-test on harness changes. These suites install Stack
# inside isolated containers. The tree-source case packs the JavaScript
# build produced by the earlier E2E task.
- name: Run the credentialed Migration Harness self-test
if: ${{ !cancelled() }}
run: pnpm exec turbo run harness:selftest --filter @cipherstash/e2e --env-mode=loose -- live.test.ts
env:
HARNESS_LIVE: '1'
# Guarded on the project being set: if the stack never came up there is
# nothing to tear down, and an unguarded `-p ""` would mask the real error.
- name: Stop postgres
if: always() && env.CS_COMPOSE_PROJECT != ''
run: docker compose -p "$CS_COMPOSE_PROJECT" -f "$CS_COMPOSE_FILE" down -v
# The integration image above is PostgreSQL 17. PostgreSQL 18 records
# NOT NULL constraints in pg_constraint, including the one on a primary
# key's column, so the upgrade example's dependency preflight sees a
# different catalogue there. No postgres-eql image exists for 18; the
# upgrade suite installs EQL v2.2.1 and v3 itself, so the official image
# (pinned by digest) is enough.
- name: Start PostgreSQL 18
id: db18
if: ${{ !cancelled() && steps.ffi-binding.outcome == 'success' && steps.auth-binding.outcome == 'success' }}
run: |
docker run -d --name pg18-upgrade -e POSTGRES_PASSWORD=password \
-p 127.0.0.1::5432 \
postgres:18@sha256:e3d24f6906d0760bf4da0dae872415391ededefad23fd471c47dc53b0ddf3c42
# Probe over TCP: the init-time server listens on the socket only.
for _ in $(seq 1 60); do
docker exec pg18-upgrade pg_isready -h 127.0.0.1 -U postgres -q && break
sleep 1
done
docker exec pg18-upgrade pg_isready -h 127.0.0.1 -U postgres
port="$(docker port pg18-upgrade 5432/tcp | head -n1 | sed 's/.*://')"
echo "database-url=postgres://postgres:[email protected]:${port}/postgres" >> "$GITHUB_OUTPUT"
# The login stored the Docker Hub password in the Docker config file,
# where any later step could read it. No later step pulls an image.
# scripts/__tests__/workflow-docker-hub-login.test.mjs checks the order.
- name: Log out of Docker Hub
if: always()
run: docker logout
- name: Run the Postgres upgrade example on PostgreSQL 18
if: ${{ !cancelled() && steps.db18.outcome == 'success' }}
run: pnpm exec turbo run test:protect-crossover --filter @cipherstash/e2e --env-mode=loose -- tests/protect-postgres-upgrade.e2e.test.ts
env:
DATABASE_URL: ${{ steps.db18.outputs.database-url }}
- name: Stop PostgreSQL 18
if: always() && steps.db18.outcome != 'skipped'
run: docker rm -f pg18-upgrade || true
# Verifies @cipherstash/stack/wasm-inline works under Deno — i.e. the
# WASM build of protect-ffi 0.26+ and auth 0.40+ can round-trip an
# encryption against ZeroKMS / CTS in a runtime with no native
# bindings available. The deno.json deliberately omits --allow-ffi so
# a silent fallback to the NAPI module is impossible.
wasm-e2e-tests:
name: Run WASM E2E Tests (Deno)
runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache
timeout-minutes: 35
permissions:
contents: read
# CS_WORKSPACE_CRN is the single source of truth for workspace
# identity and region — the stack /wasm-inline config requires it and
# derives the AccessKeyStrategy region from it.
env:
CS_WORKSPACE_CRN: ${{ vars.CS_WORKSPACE_CRN }}
CS_CLIENT_ID: ${{ vars.CS_CLIENT_ID }}
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
steps:
- name: Checkout Repo
uses: actions/checkout@v6
with:
persist-credentials: false
- uses: pnpm/[email protected]
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: 24
cache: 'pnpm'
# node-pty (a dev-dep of @cipherstash/cli used by its E2E PTY
# tests) falls back to `node-gyp rebuild` when no prebuild matches
# the runner, and pnpm/action-setup v6 no longer ships node-gyp on
# PATH. The WASM smoke test itself uses no native modules — this
# install only exists so the workspace-wide `pnpm install` step
# below doesn't fail.
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install Deno
uses: denoland/[email protected]
with:
deno-version: v2.x
- name: Install dependencies
run: pnpm install --frozen-lockfile
# The e2e/wasm suites FAIL when any of the four CS_* env vars is
# missing (requireEnv throws — no skip gating), so a rotated / cleared
# secret can't hide a real WASM regression behind a green job. This
# preflight just fails faster, before the two builds below and the Deno
# module downloads.
#
# It is the preflight that moves above the binding build here, not the
# binding build that moves below it: `Build stack` consumes
# protect-ffi's dist/wasm output, so the two build steps have to stay in
# this order.
- name: Require CipherStash secrets
uses: ./.github/actions/require-cs-secrets
with:
workspace-crn: ${{ vars.CS_WORKSPACE_CRN }}
client-id: ${{ vars.CS_CLIENT_ID }}
client-key: ${{ secrets.CS_CLIENT_KEY }}
client-access-key: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
# `wasm: true` — this is the job the WASM output exists for. stack's
# dist/wasm-inline.js imports protect-ffi's dist/wasm/protect_ffi_inline.js
# by relative path, and only the three .d.ts under dist/wasm are tracked;
# the .js and .wasm come from wasm-pack and nothing else in CI runs it.
- name: Build the protect-ffi binding
uses: ./.github/actions/build-ffi-binding
with:
wasm: 'true'
# stack's wasm-inline entry imports @cipherstash/auth/wasm-inline, which
# loads auth's own wasm/.
- name: Build the @cipherstash/auth binding
uses: ./.github/actions/build-auth-binding
with:
wasm: 'true'
# The only job that can run this: the type tests read the GENERATED
# dist/wasm/*.d.ts (wasm-bindgen emits them from the `typescript_type`
# attributes in crates/protect-ffi/src/wasm.rs) and those declarations
# import ../../lib/types.js, so it needs both halves of the step above.
# That is why it is exempt from protect-ffi's `test` entry point, which
# must pass in a fresh clone with no dist/ — and the exemption in
# src/lintWiring.test.ts asserts this step exists, because between the
# absorption and this line the check ran nowhere at all: the jobs its
# exemption named were the upstream copies under
# languages/typescript/packages/protect-ffi/.github/, which GitHub never executes.
- name: Typecheck the generated WASM declarations
run: pnpm --filter @cipherstash/protect-ffi run test:typecheck:wasm
# The `clientKey` contract test (#804). It loads the REAL WASM core
# instead of the stub in `vitest.shared.ts`, so it needs the step above:
# excluded from stack's default vitest config, which runs in
# `run-tests`, where the binding is built without `wasm: 'true'` and
# `dist/wasm/protect_ffi_inline.js` therefore does not exist — there the
# file failed to COLLECT, which is not a skip.
#
# Not the only suite that loads the real core, and this is not the only
# job that builds it for one — `integration-drizzle.yml` runs
# `languages/typescript/packages/stack`'s `integration/wasm/**` the same way. It is here
# because it needs NOTHING else: no credentials, no database. Those
# suites' `globalSetup` requires both unconditionally and throws rather
# than skipping, and that job is path-filtered and fork-skipped besides,
# so hosting a core contract there would leave it unchecked on every diff
# those paths do not select. See
# `languages/typescript/packages/stack/vitest.wasm-core.config.ts` for the long form.
#
# Before `Build stack` deliberately — it reads protect-ffi's output
# directly and none of stack's, so a core that changed its credential
# contract fails here rather than after another build.
#
# Offline despite the credentials in this job's env: every assertion
# lands during argument deserialisation or key loading, before any
# ZeroKMS / CTS call. It is here for the WASM build, not the secrets.
#
# `scripts/__tests__/wasm-core-contract-ci.test.mjs` fails if this step
# goes away while the exclusion stays — a suite that no job runs reads
# exactly like a suite that passes.
- name: Test the WASM core credential contract (stack)
run: pnpm exec turbo run test:wasm-core --filter @cipherstash/stack
# The Deno smoke tests import the locally-built dist/wasm-inline.js of
# BOTH packages via file URLs in e2e/wasm/deno.json — they need fresh
# builds. stack-supabase is here for `supabase-declared.test.ts`, which
# is the only place the edge entry is exercised on a real edge runtime
# rather than asserted about (#708).
- name: Build stack and the Supabase adapter
run: >
pnpm exec turbo run build
--filter @cipherstash/stack
--filter @cipherstash/stack-supabase
- name: Run Deno WASM smoke test
working-directory: e2e/wasm
run: deno task test
run-tests-bun:
name: Run Tests (Bun)
runs-on: runs-on=${{ github.run_id }}/family=c8a+m8a/cpu=4/image=ubuntu24-full-x64/volume=80gb/extras=s3-cache
timeout-minutes: 15
continue-on-error: true
services:
postgres:
image: ghcr.io/cipherstash/postgres-eql:17-2.3.1
env:
POSTGRES_USER: cipherstash
POSTGRES_PASSWORD: password
POSTGRES_DB: cipherstash
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U cipherstash -d cipherstash"
--health-interval 2s
--health-timeout 5s
--health-retries 20
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
- uses: pnpm/[email protected]
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: 24
cache: 'pnpm'
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Fail loudly if any live-test credential is missing. The `.env` written
# below feeds the same live suites `run-tests` runs, and this job hides
# its own failures twice over (`continue-on-error: true` on the job, `||
# true` around the vitest call), so a rotated secret would otherwise show
# up as nothing at all.
# Before the binding build, not after: this costs seconds and that costs
# minutes on a cold cache.
- name: Require CipherStash secrets
uses: ./.github/actions/require-cs-secrets
with:
workspace-crn: ${{ vars.CS_WORKSPACE_CRN }}
client-id: ${{ vars.CS_CLIENT_ID }}
client-key: ${{ secrets.CS_CLIENT_KEY }}
client-access-key: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
# The `languages/typescript/packages/stack` suites below are the live ones — 120 files, of
# which only 8 mock `@cipherstash/protect-ffi` — so they load
# `index.node`, and the `Build packages` step below does not produce it
# (protect-ffi's `build` is `tsc`, deliberately cargo-free). No
# `wasm: true`: every `wasm-inline` unit test resolves the stubs in
# `vitest.shared.ts` or asserts on the bundle graph, same as `run-tests`.
#
# It shares the native cache key with `run-tests`, so in the normal case
# this is a restore rather than a compile.
- name: Build the protect-ffi binding
uses: ./.github/actions/build-ffi-binding
- name: Build the @cipherstash/auth binding
uses: ./.github/actions/build-auth-binding
- name: Create .env file in ./languages/typescript/packages/stack/
run: |
touch ./languages/typescript/packages/stack/.env
echo "CS_WORKSPACE_CRN=${{ vars.CS_WORKSPACE_CRN }}" >> ./languages/typescript/packages/stack/.env
echo "CS_CLIENT_ID=${{ vars.CS_CLIENT_ID }}" >> ./languages/typescript/packages/stack/.env
echo "CS_CLIENT_KEY=${{ secrets.CS_CLIENT_KEY }}" >> ./languages/typescript/packages/stack/.env
echo "CS_CLIENT_ACCESS_KEY=${{ secrets.CS_CLIENT_ACCESS_KEY }}" >> ./languages/typescript/packages/stack/.env
echo "DATABASE_URL=postgres://cipherstash:password@localhost:5432/cipherstash" >> ./languages/typescript/packages/stack/.env
# Build with Node (turbo/tsup need Node), then run tests with Bun
- name: Build packages
run: pnpm turbo build --filter './languages/typescript/packages/*'
- name: Run tests with Bun
run: |
for dir in languages/typescript/packages/stack; do
if [ -f "$dir/vitest.config.ts" ] || [ -f "$dir/package.json" ]; then
echo "--- Testing $dir ---"
(cd "$dir" && bunx --bun vitest run) || true
fi
done