From f238010e914815a9f235a19c0d4e7570276fb7c1 Mon Sep 17 00:00:00 2001 From: Jophkins Date: Mon, 2 Feb 2026 22:12:05 -0700 Subject: [PATCH 1/2] :wrench: fix: fixing test runs for github actions --- tests/helpers/next-server.ts | 82 +++++++++++++++++------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/tests/helpers/next-server.ts b/tests/helpers/next-server.ts index 913a889..f43b2bf 100644 --- a/tests/helpers/next-server.ts +++ b/tests/helpers/next-server.ts @@ -1,17 +1,22 @@ -import type { ChildProcess } from "node:child_process"; +import type { ChildProcessWithoutNullStreams } from "node:child_process"; import { spawn } from "node:child_process"; import net from "node:net"; import path from "node:path"; -let serverProcess: ChildProcess | null = null; -let serverPort: number | null = null; +let serverProcess: ChildProcessWithoutNullStreams | null = null; + // Shared buffer for debugging const logs = { stdout: "", stderr: "" }; + const ROOT_DIR = path.resolve(import.meta.dirname, "../.."); +function pnpmCmd() { + return process.platform === "win32" ? "pnpm.cmd" : "pnpm"; +} + /** * Get a random available port by binding to port 0. */ @@ -38,54 +43,48 @@ async function getAvailablePort(): Promise { */ export async function startNextServer(): Promise<{ baseUrl: string; port: number }> { const port = await getAvailablePort(); - serverPort = port; - // Reset logs logs.stdout = ""; logs.stderr = ""; - // eslint-disable-next-line no-console console.log(`[test] Starting Next.js server on port ${port}...`); - // Use shell mode for better compatibility with pnpm - serverProcess = spawn(`pnpm next dev --port ${port}`, { - cwd: ROOT_DIR, - stdio: ["ignore", "pipe", "pipe"], - shell: true, - env: { - ...process.env, - NODE_ENV: "development", - }, - }); + serverProcess = spawn( + pnpmCmd(), + ["next", "dev", "--port", String(port)], + { + cwd: ROOT_DIR, + stdio: ["ignore", "pipe", "pipe"], + env: { + ...process.env, + NODE_ENV: "development", + NEXT_TELEMETRY_DISABLED: "1", + }, + } + ); - serverProcess.stdout?.on("data", (data: Buffer) => { + serverProcess.stdout.on("data", (data: Buffer) => { const text = data.toString(); logs.stdout += text; - // eslint-disable-next-line no-console console.log(`[next] ${text.trim()}`); }); - serverProcess.stderr?.on("data", (data: Buffer) => { + serverProcess.stderr.on("data", (data: Buffer) => { const text = data.toString(); logs.stderr += text; - console.error(`[next:err] ${text.trim()}`); }); - // Handle early process exit serverProcess.on("exit", (code) => { if (code !== 0 && code !== null) { console.error(`[test] Next.js process exited with code ${code}`); } }); - // Wait for server to be ready - const baseUrl = `http://localhost:${port}`; + const baseUrl = `http://127.0.0.1:${port}`; await waitForServer(baseUrl); - // eslint-disable-next-line no-console console.log(`[test] Next.js server ready at ${baseUrl}`); - return { baseUrl, port }; } @@ -93,29 +92,26 @@ export async function startNextServer(): Promise<{ baseUrl: string; port: number * Stops the Next.js server if running. */ export async function stopNextServer(): Promise { - if (!serverProcess) { - return; - } + if (!serverProcess) return; - // eslint-disable-next-line no-console console.log("[test] Stopping Next.js server..."); - return new Promise((resolve) => { - serverProcess!.on("close", () => { - serverProcess = null; - serverPort = null; - resolve(); - }); + const p = serverProcess; + serverProcess = null; - serverProcess!.kill("SIGTERM"); + if (p.exitCode !== null) return; - // Force kill after 5 seconds - setTimeout(() => { - if (serverProcess) { - serverProcess.kill("SIGKILL"); - } - }, 5000); - }); + p.kill("SIGTERM"); + + const exited = await Promise.race([ + new Promise((resolve) => p.once("exit", () => resolve(true))), + new Promise((resolve) => setTimeout(() => resolve(false), 3000)), + ]); + + if (!exited && p.exitCode === null) { + p.kill("SIGKILL"); + await new Promise((resolve) => p.once("exit", () => resolve())); + } } /** From c161eaa6954755433a7ff508dc0859b19b46ef8e Mon Sep 17 00:00:00 2001 From: Jophkins Date: Mon, 2 Feb 2026 22:23:07 -0700 Subject: [PATCH 2/2] :wrench: fix: fixing linter action --- .github/workflows/lint.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 301fb48..c69df2d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,6 +8,9 @@ on: jobs: build: runs-on: ubuntu-latest + env: + DATABASE_URL: postgresql://user:pass@localhost:5432/db?schema=public + DIRECT_URL: postgresql://user:pass@localhost:5432/db?schema=public steps: - uses: actions/checkout@v5 - name: Install pnpm