Test Postgres in the CI

This commit is contained in:
Alex Gleason 2024-05-26 18:37:47 -05:00
parent a6cae8f878
commit 8f3b9df1e1
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 18 additions and 1 deletions

View File

@ -29,3 +29,13 @@ test:
- deno-test.xml - deno-test.xml
reports: reports:
junit: deno-test.xml junit: deno-test.xml
postgres:
stage: test
script: deno task db:migrate
services:
- postgres:16
variables:
DITTO_NSEC: nsec1zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs4rm7hz
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
POSTGRES_HOST_AUTH_METHOD: trust

View File

@ -5,6 +5,7 @@
"start": "deno run -A src/server.ts", "start": "deno run -A src/server.ts",
"dev": "deno run -A --watch src/server.ts", "dev": "deno run -A --watch src/server.ts",
"hook": "deno run --allow-read --allow-run --allow-write https://deno.land/x/deno_hooks@0.1.1/mod.ts", "hook": "deno run --allow-read --allow-run --allow-write https://deno.land/x/deno_hooks@0.1.1/mod.ts",
"db:migrate": "deno run -A scripts/db-migrate.ts",
"debug": "deno run -A --inspect src/server.ts", "debug": "deno run -A --inspect src/server.ts",
"test": "DATABASE_URL=\"sqlite://:memory:\" deno test -A --junit-path=./deno-test.xml", "test": "DATABASE_URL=\"sqlite://:memory:\" deno test -A --junit-path=./deno-test.xml",
"check": "deno check src/server.ts", "check": "deno check src/server.ts",

6
scripts/db-migrate.ts Normal file
View File

@ -0,0 +1,6 @@
import { DittoDB } from '@/db/DittoDB.ts';
const kysely = await DittoDB.getInstance();
await kysely.destroy();
Deno.exit();