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:
@@ -323,6 +323,11 @@ jobs:
|
|||||||
# ${PGADMIN_PASSWORD:?} check fires and aborts the compose call.
|
# ${PGADMIN_PASSWORD:?} check fires and aborts the compose call.
|
||||||
# Provide a dummy value so parsing succeeds — pgadmin is never started.
|
# Provide a dummy value so parsing succeeds — pgadmin is never started.
|
||||||
PGADMIN_PASSWORD: ci-unused
|
PGADMIN_PASSWORD: ci-unused
|
||||||
|
# Tell test-server.mjs not to spin up its own postgres-test container
|
||||||
|
# — the e2epg job service is already running and reachable. Without
|
||||||
|
# this, test-server tries to publish 5432 on the QNAP host, which
|
||||||
|
# collides with Gitea's core postgres.
|
||||||
|
PLAYWRIGHT_USE_EXTERNAL_DB: "true"
|
||||||
NEXTAUTH_URL: ${{ env.CI_AUTH_URL }}
|
NEXTAUTH_URL: ${{ env.CI_AUTH_URL }}
|
||||||
AUTH_URL: ${{ env.CI_AUTH_URL }}
|
AUTH_URL: ${{ env.CI_AUTH_URL }}
|
||||||
NEXTAUTH_SECRET: ${{ env.CI_AUTH_SECRET }}
|
NEXTAUTH_SECRET: ${{ env.CI_AUTH_SECRET }}
|
||||||
@@ -491,9 +496,13 @@ jobs:
|
|||||||
node-version: "20"
|
node-version: "20"
|
||||||
|
|
||||||
- name: Install Playwright and Chromium
|
- name: Install Playwright and Chromium
|
||||||
|
# Install locally (not -g) so the CJS require() in playwright.ci.config.ts
|
||||||
|
# resolves @playwright/test by walking up from apps/web/. A global
|
||||||
|
# install puts it in /opt/hostedtoolcache/.../lib/node_modules which
|
||||||
|
# Node's resolver doesn't check.
|
||||||
run: |
|
run: |
|
||||||
npm install -g @playwright/test@1.49
|
npm install --no-save --no-package-lock @playwright/test@1.49
|
||||||
playwright install chromium --with-deps
|
npx playwright install chromium --with-deps
|
||||||
|
|
||||||
- name: Run smoke tests
|
- name: Run smoke tests
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -334,9 +334,18 @@ if (!playwrightDatabaseUrl) {
|
|||||||
throw new Error("PLAYWRIGHT_DATABASE_URL or DATABASE_URL_TEST must be configured for E2E runs.");
|
throw new Error("PLAYWRIGHT_DATABASE_URL or DATABASE_URL_TEST must be configured for E2E runs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestedTestDbPort = Number(new URL(playwrightDatabaseUrl).port || "5434");
|
// CI mode: use an externally-provided postgres (e.g. a GitHub Actions service
|
||||||
const selectedTestDbPort = await selectAvailablePort(requestedTestDbPort);
|
// container) instead of spinning up our own compose-managed postgres-test.
|
||||||
playwrightDatabaseUrl = replaceDatabasePort(playwrightDatabaseUrl, selectedTestDbPort);
|
// 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);
|
const playwrightDatabaseName = parseDatabaseName(playwrightDatabaseUrl);
|
||||||
|
|
||||||
@@ -348,7 +357,9 @@ if (!/(^|_)(test|e2e|ci)$/u.test(playwrightDatabaseName)) {
|
|||||||
|
|
||||||
process.env.DATABASE_URL = playwrightDatabaseUrl;
|
process.env.DATABASE_URL = playwrightDatabaseUrl;
|
||||||
process.env.PLAYWRIGHT_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.CAPAKRAKEN_EXPECTED_DB_NAME = playwrightDatabaseName;
|
||||||
process.env.ALLOW_DESTRUCTIVE_DB_TOOLS = "true";
|
process.env.ALLOW_DESTRUCTIVE_DB_TOOLS = "true";
|
||||||
process.env.CONFIRM_DESTRUCTIVE_DB_NAME = playwrightDatabaseName;
|
process.env.CONFIRM_DESTRUCTIVE_DB_NAME = playwrightDatabaseName;
|
||||||
@@ -378,8 +389,10 @@ writeManagedWebEnv(rootEnv);
|
|||||||
process.on("exit", restoreWebEnvOnce);
|
process.on("exit", restoreWebEnvOnce);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!useExternalDb) {
|
||||||
await cleanupStaleE2eArtifacts();
|
await cleanupStaleE2eArtifacts();
|
||||||
await ensureE2eDatabaseContainer();
|
await ensureE2eDatabaseContainer();
|
||||||
|
}
|
||||||
await run("pnpm", ["--filter", "@capakraken/db", "db:push"], workspaceRoot);
|
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"], workspaceRoot);
|
||||||
await run("pnpm", ["--filter", "@capakraken/db", "db:seed:holidays"], workspaceRoot);
|
await run("pnpm", ["--filter", "@capakraken/db", "db:seed:holidays"], workspaceRoot);
|
||||||
|
|||||||
Reference in New Issue
Block a user