ci: fix E2E postgres-test collision and smoke @playwright/test resolution
CI / Architecture Guardrails (push) Successful in 3m46s
CI / Assistant Split Regression (push) Successful in 4m38s
CI / Lint (push) Successful in 4m56s
CI / Typecheck (push) Successful in 5m24s
CI / Unit Tests (push) Failing after 5m21s
CI / Build (push) Successful in 5m46s
CI / Fresh-Linux Docker Deploy (push) Failing after 4m35s
CI / Release Images (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Architecture Guardrails (push) Successful in 3m46s
CI / Assistant Split Regression (push) Successful in 4m38s
CI / Lint (push) Successful in 4m56s
CI / Typecheck (push) Successful in 5m24s
CI / Unit Tests (push) Failing after 5m21s
CI / Build (push) Successful in 5m46s
CI / Fresh-Linux Docker Deploy (push) Failing after 4m35s
CI / Release Images (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
E2E: test-server.mjs always spins up its own postgres-test container and publishes port 5432 on the docker host — colliding with Gitea's core postgres on the QNAP runner. Add PLAYWRIGHT_USE_EXTERNAL_DB opt-in so CI can reuse the e2epg job-service container (which test-server still pushes+seeds into). Set the flag in the E2E job. docker-deploy smoke: install @playwright/test locally (no -g, no --save) so the CJS require() in apps/web/playwright.ci.config.ts resolves it by walking up from the config directory. Global npm install lands in a hostedtoolcache path Node does not search.
This commit is contained in:
@@ -334,9 +334,18 @@ if (!playwrightDatabaseUrl) {
|
||||
throw new Error("PLAYWRIGHT_DATABASE_URL or DATABASE_URL_TEST must be configured for E2E runs.");
|
||||
}
|
||||
|
||||
const requestedTestDbPort = Number(new URL(playwrightDatabaseUrl).port || "5434");
|
||||
const selectedTestDbPort = await selectAvailablePort(requestedTestDbPort);
|
||||
playwrightDatabaseUrl = replaceDatabasePort(playwrightDatabaseUrl, selectedTestDbPort);
|
||||
// CI mode: use an externally-provided postgres (e.g. a GitHub Actions service
|
||||
// container) instead of spinning up our own compose-managed postgres-test.
|
||||
// In that mode we trust PLAYWRIGHT_DATABASE_URL as-is — no port rebinding,
|
||||
// no compose up.
|
||||
const useExternalDb = process.env.PLAYWRIGHT_USE_EXTERNAL_DB === "true";
|
||||
|
||||
let selectedTestDbPort;
|
||||
if (!useExternalDb) {
|
||||
const requestedTestDbPort = Number(new URL(playwrightDatabaseUrl).port || "5434");
|
||||
selectedTestDbPort = await selectAvailablePort(requestedTestDbPort);
|
||||
playwrightDatabaseUrl = replaceDatabasePort(playwrightDatabaseUrl, selectedTestDbPort);
|
||||
}
|
||||
|
||||
const playwrightDatabaseName = parseDatabaseName(playwrightDatabaseUrl);
|
||||
|
||||
@@ -348,7 +357,9 @@ if (!/(^|_)(test|e2e|ci)$/u.test(playwrightDatabaseName)) {
|
||||
|
||||
process.env.DATABASE_URL = playwrightDatabaseUrl;
|
||||
process.env.PLAYWRIGHT_DATABASE_URL = playwrightDatabaseUrl;
|
||||
process.env.POSTGRES_TEST_PORT = String(selectedTestDbPort);
|
||||
if (selectedTestDbPort !== undefined) {
|
||||
process.env.POSTGRES_TEST_PORT = String(selectedTestDbPort);
|
||||
}
|
||||
process.env.CAPAKRAKEN_EXPECTED_DB_NAME = playwrightDatabaseName;
|
||||
process.env.ALLOW_DESTRUCTIVE_DB_TOOLS = "true";
|
||||
process.env.CONFIRM_DESTRUCTIVE_DB_NAME = playwrightDatabaseName;
|
||||
@@ -378,8 +389,10 @@ writeManagedWebEnv(rootEnv);
|
||||
process.on("exit", restoreWebEnvOnce);
|
||||
|
||||
try {
|
||||
await cleanupStaleE2eArtifacts();
|
||||
await ensureE2eDatabaseContainer();
|
||||
if (!useExternalDb) {
|
||||
await cleanupStaleE2eArtifacts();
|
||||
await ensureE2eDatabaseContainer();
|
||||
}
|
||||
await run("pnpm", ["--filter", "@capakraken/db", "db:push"], workspaceRoot);
|
||||
await run("pnpm", ["--filter", "@capakraken/db", "db:seed"], workspaceRoot);
|
||||
await run("pnpm", ["--filter", "@capakraken/db", "db:seed:holidays"], workspaceRoot);
|
||||
|
||||
Reference in New Issue
Block a user