diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc1a7e3..586a8b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,26 @@ on: pull_request: jobs: build_and_test: + services: + postgres: + image: postgres + env: + POSTGRES_USER: test + POSTGRES_PASSWORD: test + POSTGRES_DB: test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5439:5432 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: sqlc-dev/setup-sqlc@v4 with: sqlc-version: '1.27.0' - - uses: actions/setup-node@v4 - uses: oven-sh/setup-bun@v2 - run: wget https://github.com/bytecodealliance/javy/releases/download/v4.0.0/javy-x86_64-linux-v4.0.0.gz - run: gzip -d javy-x86_64-linux-v4.0.0.gz diff --git a/test/prepare.ts b/test/prepare.ts index e58cf09..41936de 100644 --- a/test/prepare.ts +++ b/test/prepare.ts @@ -11,7 +11,12 @@ for (const c of cases) { await $`bun run ${c} prepare`; } -await $`docker compose up -d`; +const dbStatus = await $`pg_isready -h localhost -p 5439`; +if (dbStatus.exitCode !== 0) { + // when running in CI, the database will be up already + await $`docker compose up -d`; +} + await $`sqlc generate`; await db.file("schema.sql");