From 8f3b9df1e164d79954044fbbbfb1065e51bd0a59 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 26 May 2024 18:37:47 -0500 Subject: [PATCH] Test Postgres in the CI --- .gitlab-ci.yml | 12 +++++++++++- deno.json | 1 + scripts/db-migrate.ts | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 scripts/db-migrate.ts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2140db..58a3453 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,4 +28,14 @@ test: paths: - deno-test.xml reports: - junit: deno-test.xml \ No newline at end of file + 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 \ No newline at end of file diff --git a/deno.json b/deno.json index 48b468e..ac13eb4 100644 --- a/deno.json +++ b/deno.json @@ -5,6 +5,7 @@ "start": "deno run -A 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", + "db:migrate": "deno run -A scripts/db-migrate.ts", "debug": "deno run -A --inspect src/server.ts", "test": "DATABASE_URL=\"sqlite://:memory:\" deno test -A --junit-path=./deno-test.xml", "check": "deno check src/server.ts", diff --git a/scripts/db-migrate.ts b/scripts/db-migrate.ts new file mode 100644 index 0000000..b9f63bf --- /dev/null +++ b/scripts/db-migrate.ts @@ -0,0 +1,6 @@ +import { DittoDB } from '@/db/DittoDB.ts'; + +const kysely = await DittoDB.getInstance(); +await kysely.destroy(); + +Deno.exit();