Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
validate:
name: Validate
runs-on: ubuntu-latest
env:
DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
DATABASE_URL=postgresql://localhost:5432/dispatch

- name: Validate Prisma CLI runtime
run: |
IMAGE="dispatch:prisma-cli-runtime"
docker build -t "$IMAGE" .
echo "Validating Prisma CLI in image: $IMAGE"
docker run --rm --entrypoint ./node_modules/.bin/prisma "$IMAGE" --version
docker run --rm --entrypoint ./node_modules/.bin/prisma "$IMAGE" validate
docker run --rm --env DATABASE_URL=postgresql://localhost:5432/dispatch --entrypoint ./node_modules/.bin/prisma "$IMAGE" --version
docker run --rm --env DATABASE_URL=postgresql://localhost:5432/dispatch --entrypoint ./node_modules/.bin/prisma "$IMAGE" validate

- name: Run Trivy vulnerability scanner
if: github.event_name != 'pull_request'
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN npm ci --omit=dev

FROM base AS builder
WORKDIR /app
ARG DATABASE_URL=postgresql://localhost:5432/dispatch
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates && rm -rf /var/lib/apt/lists/*
Expand Down
9 changes: 7 additions & 2 deletions prisma.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { defineConfig } from "prisma/config";

const databaseUrl =
process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch";
const databaseUrl = process.env.DATABASE_URL;

if (!databaseUrl) {
throw new Error(
"DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",
);
}

export default defineConfig({
schema: "prisma/schema.prisma",
Expand Down
9 changes: 7 additions & 2 deletions src/lib/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { PrismaPg } from "@prisma/adapter-pg";
import { PrFixQueueClient } from "@/lib/pr-fix-queue";
import { AgentWorkClient } from "@/lib/agent-work";

const databaseUrl =
process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch";
const databaseUrl = process.env.DATABASE_URL;

if (!databaseUrl) {
throw new Error(
"DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",
);
}

const adapter = new PrismaPg(databaseUrl);

Expand Down
4 changes: 4 additions & 0 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Import @testing-library/jest-dom/vitest for custom matchers
import "@testing-library/jest-dom/vitest";

// Provide a dummy DATABASE_URL so prisma.ts module loads without throwing.
// Tests that need real DB access mock/override as needed.
process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test";

// Patch React.act for React 19 + @testing-library/react v16 compat.
// React 19 removed React.act, but older react-dom/test-utils still calls it.
const React = require("react");
Expand Down