update: tests and workflow to work the same way it does in github (#5)
Run Tests / test (push) Successful in 8m37s

Reviewed-on: shishantbiswas/bknd#5
This commit was merged in pull request #5.
This commit is contained in:
2026-09-25 13:37:27 +00:00
parent 8c596781ff
commit e8a256af2a
2 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ jobs:
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres POSTGRES_USER: postgres
POSTGRES_DB: bknd POSTGRES_DB: bknd
ports: # ports:
- 5430:5432 # - 5430:5432
options: >- options: >-
--health-cmd pg_isready --health-cmd pg_isready
--health-interval 10s --health-interval 10s
+9 -2
View File
@@ -8,9 +8,11 @@ import { $ } from "bun";
import { connectionTestSuite } from "data/connection/connection-test-suite"; import { connectionTestSuite } from "data/connection/connection-test-suite";
import { bunTestRunner } from "adapter/bun/test"; import { bunTestRunner } from "adapter/bun/test";
const isCI = !!(process.env.GITEA_ACTIONS || process.env.GITHUB_ACTIONS);
const credentials = { const credentials = {
host: "localhost", host: isCI ? "postgres" : "localhost",
port: 5430, port: 5432,
user: "postgres", user: "postgres",
password: "postgres", password: "postgres",
database: "bknd", database: "bknd",
@@ -39,6 +41,11 @@ async function isPostgresRunning() {
describe("postgres", () => { describe("postgres", () => {
beforeAll(async () => { beforeAll(async () => {
if (process.env.GITEA_ACTIONS || process.env.GITHUB_ACTIONS) {
console.log("Running in CI: Skipping manual docker run");
return;
}
if (!(await isPostgresRunning())) { 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 $`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); await $waitUntil("Postgres is running", isPostgresRunning);