From e8a256af2acdbc093bd7f3ef671bda3fd9ff6d79 Mon Sep 17 00:00:00 2001 From: shishantbiswas Date: Fri, 25 Sep 2026 13:37:27 +0000 Subject: [PATCH] update: tests and workflow to work the same way it does in github (#5) Reviewed-on: https://gitea.bsws.in/shishantbiswas/bknd/pulls/5 --- .github/workflows/test.yml | 4 ++-- app/__test__/data/postgres.test.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d9f51ee5..1b30ca61 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,8 +16,8 @@ jobs: POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres POSTGRES_DB: bknd - ports: - - 5430:5432 + # ports: + # - 5430:5432 options: >- --health-cmd pg_isready --health-interval 10s diff --git a/app/__test__/data/postgres.test.ts b/app/__test__/data/postgres.test.ts index 1560204d..6568450f 100644 --- a/app/__test__/data/postgres.test.ts +++ b/app/__test__/data/postgres.test.ts @@ -8,9 +8,11 @@ import { $ } from "bun"; import { connectionTestSuite } from "data/connection/connection-test-suite"; import { bunTestRunner } from "adapter/bun/test"; +const isCI = !!(process.env.GITEA_ACTIONS || process.env.GITHUB_ACTIONS); + const credentials = { - host: "localhost", - port: 5430, + host: isCI ? "postgres" : "localhost", + port: 5432, user: "postgres", password: "postgres", database: "bknd", @@ -39,6 +41,11 @@ async function isPostgresRunning() { describe("postgres", () => { beforeAll(async () => { + if (process.env.GITEA_ACTIONS || process.env.GITHUB_ACTIONS) { + console.log("Running in CI: Skipping manual docker run"); + return; + } + if (!(await isPostgresRunning())) { await $`docker run --rm --name bknd-test-postgres -d -e POSTGRES_PASSWORD=${credentials.password} -e POSTGRES_USER=${credentials.user} -e POSTGRES_DB=${credentials.database} -p ${credentials.port}:5432 postgres:17`; await $waitUntil("Postgres is running", isPostgresRunning);