Skip to content

Commit 8b097ef

Browse files
authored
Merge pull request #1295 from cipherstash/claude/project-thread-0gkq38
ci: run the @cipherstash/migrate database suites in CI
2 parents bf49826 + a6891cc commit 8b097ef

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎.github/workflows/tests.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,21 @@ jobs:
373373
# races destructively under the other suites in parallel forks).
374374
# (`supabase-push.live.test.ts` gates on different env vars and still
375375
# skips here — it needs the Supabase CLI binary.)
376+
#
377+
# PG_TEST_URL runs `@cipherstash/migrate`'s integration suites (forward
378+
# and reverse backfill: resume, force obligation, concurrent dual-writes).
379+
# They self-skip without it. They need no credentials, but each opens
380+
# with DROP SCHEMA cipherstash CASCADE, so they get a database of their
381+
# own: turbo runs packages in parallel, and in the shared one that drop
382+
# would race the CLI's live suites.
383+
- name: Create the migrate integration database
384+
run: psql "postgres://cipherstash:password@localhost:5432/cipherstash" -c 'CREATE DATABASE migrate_test'
385+
376386
- name: Run tests
377387
run: pnpm run test
378388
env:
379389
STASH_TEST_DATABASE_URL: postgres://cipherstash:password@localhost:5432/cipherstash
390+
PG_TEST_URL: postgres://cipherstash:password@localhost:5432/migrate_test
380391

381392
# CLI E2E tests drive the built `dist/bin/stash.js` through a real
382393
# pseudo-terminal via node-pty. Run via turbo so the `^build` + `build`

‎scripts/__tests__/cli-live-postgres-ci.test.mjs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@ describe('CLI live-Postgres CI contract', () => {
2222
)
2323
})
2424

25+
// `@cipherstash/migrate`'s integration suites self-skip without PG_TEST_URL,
26+
// so a dropped variable reads as a green run. They DROP the `cipherstash`
27+
// schema, so they must not share the CLI live suites' database.
28+
it('forwards and supplies the migrate integration database URL', () => {
29+
const turbo = readJsonc(join(REPO_ROOT, 'turbo.json'))
30+
expect(turbo.tasks.test.env).toContain('PG_TEST_URL')
31+
32+
const workflow = readWorkflow('.github/workflows/tests.yml')
33+
const runTests = workflow.jobs['run-tests'].steps.find(
34+
(step) => step.name === 'Run tests',
35+
)
36+
const url = runTests.env.PG_TEST_URL
37+
expect(url).toMatch(/^postgres:\/\/[^/]+\/\w+$/)
38+
const database = url.split('/').at(-1)
39+
expect(database).not.toBe(
40+
runTests.env.STASH_TEST_DATABASE_URL.split('/').at(-1),
41+
)
42+
43+
const steps = workflow.jobs['run-tests'].steps
44+
const create = steps.findIndex((step) =>
45+
String(step.run ?? '').includes(`CREATE DATABASE ${database}`),
46+
)
47+
expect(create).toBeGreaterThan(-1)
48+
expect(create).toBeLessThan(steps.indexOf(runTests))
49+
})
50+
2551
it('runs the live reinstall suite against both pre-17 and current Postgres catalogs', () => {
2652
const workflow = readWorkflow('.github/workflows/tests.yml')
2753
const runTests = workflow.jobs['run-tests']

‎turbo.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test": {
1919
"dependsOn": ["^build"],
2020
"inputs": ["$TURBO_DEFAULT$", ".env*"],
21-
"env": ["STASH_TEST_DATABASE_URL"],
21+
"env": ["STASH_TEST_DATABASE_URL", "PG_TEST_URL"],
2222
"cache": false
2323
},
2424
// `languages/typescript/packages/bench`'s "build" is `tsc --noEmit` — a typecheck, not a bundle —

0 commit comments

Comments
 (0)