Skip to content

Commit 92e8f28

Browse files
committed
test
1 parent 0fff10f commit 92e8f28

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ jobs:
5555
runs-on: ubuntu-latest
5656
timeout-minutes: 15
5757

58+
services:
59+
postgres:
60+
image: postgres:16
61+
env:
62+
POSTGRES_USER: postgres
63+
POSTGRES_PASSWORD: postgres
64+
POSTGRES_DB: poppy_test
65+
options: >-
66+
--health-cmd pg_isready
67+
--health-interval 10s
68+
--health-timeout 5s
69+
--health-retries 5
70+
ports:
71+
- 5432:5432
72+
5873
steps:
5974
- name: Checkout code
6075
uses: actions/checkout@v4
@@ -83,9 +98,14 @@ jobs:
8398
- name: Install dependencies
8499
run: pnpm install --frozen-lockfile
85100

101+
- name: Setup database schema
102+
run: pnpm --filter @poppy/db db:push
103+
env:
104+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/poppy_test
105+
86106
- name: Run tests
87107
run: pnpm test
88108
env:
89109
NODE_ENV: test
90-
DATABASE_URL: ${{ secrets.DATABASE_URL }}
91-
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: ${{ secrets.DATABASE_URL }}
110+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/poppy_test
111+
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: postgresql://postgres:postgres@localhost:5432/poppy_test

apps/interaction-worker/src/db/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import type { WorkerEnv } from "../context";
77
* @returns Drizzle database instance with all schemas
88
*/
99
export function createDatabaseClient(env: WorkerEnv) {
10-
const isTest = process.env.NODE_ENV === "test";
10+
const isTest = env.NODE_ENV === "test";
11+
console.log(env);
1112
// Use Hyperdrive connection string for optimized PostgreSQL access
1213
return getDb(
1314
isTest ? process.env.DATABASE_URL : env.HYPERDRIVE.connectionString,

apps/interaction-worker/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ app.get("/health", async (c) => {
4747

4848
// Webhook handler at root
4949
app.post("/", async (c) => {
50-
console.log(process.env);
5150
const body = await c.req.json();
5251
console.log("Received webhook payload", body);
5352

apps/interaction-worker/vitest.config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default defineWorkersProject({
1818
"enable_nodejs_http_modules",
1919
],
2020
bindings: {
21-
ENVIRONMENT: "VITEST",
21+
NODE_ENV: "test",
2222
},
2323
durableObjects: {
2424
MESSAGE_DEBOUNCER: "MessageDebouncer",

packages/hono-helpers/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { z } from "zod";
22

33
export type WorkersEnvironment = z.infer<typeof WorkersEnvironment>;
44
export const WorkersEnvironment = z.enum([
5-
"VITEST",
5+
"test",
66
"development",
77
"staging",
88
"production",

0 commit comments

Comments
 (0)