From 292b4d70ac4da2355acba9fe28c4638af3c2d248 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Sun, 10 May 2026 22:21:06 +0530 Subject: [PATCH] chore: enhance E2E tests workflow by adding caching for Next.js build and updating test command --- .github/workflows/e2e-tests.yml | 13 ++++++++++--- surfsense_backend/alembic/env.py | 6 +++++- surfsense_web/package.json | 1 + surfsense_web/playwright.config.ts | 8 +++++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 63db5f4f1..a807603b8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -21,8 +21,7 @@ jobs: if: github.event.pull_request.draft == false timeout-minutes: 45 - # Postgres runs as a step (not a service) so we can pass `-c wal_level=logical`, - # required for migration 117's zero-cache publications. + # Postgres runs as a step (not a service) services: redis: image: redis:8-alpine @@ -246,9 +245,17 @@ jobs: working-directory: surfsense_web run: pnpm exec playwright install-deps chromium + - name: Cache Next.js build + uses: actions/cache@v5 + with: + path: surfsense_web/.next/cache + key: nextjs-${{ runner.os }}-${{ hashFiles('surfsense_web/pnpm-lock.yaml') }}-${{ hashFiles('surfsense_web/**/*.{js,jsx,ts,tsx}') }} + restore-keys: | + nextjs-${{ runner.os }}-${{ hashFiles('surfsense_web/pnpm-lock.yaml') }}- + - name: Run Playwright tests working-directory: surfsense_web - run: pnpm test:e2e + run: pnpm test:e2e:prod - name: Upload Playwright HTML report if: always() diff --git a/surfsense_backend/alembic/env.py b/surfsense_backend/alembic/env.py index bd8c20356..5354211aa 100644 --- a/surfsense_backend/alembic/env.py +++ b/surfsense_backend/alembic/env.py @@ -67,7 +67,11 @@ def run_migrations_offline() -> None: def do_run_migrations(connection: Connection) -> None: - context.configure(connection=connection, target_metadata=target_metadata) + context.configure( + connection=connection, + target_metadata=target_metadata, + transaction_per_migration=True, + ) with context.begin_transaction(): context.run_migrations() diff --git a/surfsense_web/package.json b/surfsense_web/package.json index fa8d50cdc..d9f836ea9 100644 --- a/surfsense_web/package.json +++ b/surfsense_web/package.json @@ -20,6 +20,7 @@ "db:studio": "drizzle-kit studio", "format:fix": "npx @biomejs/biome check --fix", "test:e2e": "playwright test", + "test:e2e:prod": "cross-env CI=1 playwright test", "test:e2e:ui": "playwright test --ui", "test:e2e:headed": "playwright test --headed", "test:e2e:debug": "playwright test --debug", diff --git a/surfsense_web/playwright.config.ts b/surfsense_web/playwright.config.ts index 189916f02..0dfdf80bf 100644 --- a/surfsense_web/playwright.config.ts +++ b/surfsense_web/playwright.config.ts @@ -53,11 +53,13 @@ export default defineConfig({ webServer: process.env.PLAYWRIGHT_NO_WEB_SERVER ? undefined : { - // Pin to webpack dev (Turbopack has caused stale-lock panics in E2E). - command: "pnpm exec next dev", + // Local stays on webpack dev (Turbopack caused stale-lock panics in E2E). + command: process.env.CI + ? "pnpm build && pnpm start" + : "pnpm exec next dev", url: `http://localhost:${PORT}`, reuseExistingServer: !process.env.CI, - timeout: 180_000, + timeout: process.env.CI ? 300_000 : 180_000, env: { NEXT_PUBLIC_FASTAPI_BACKEND_URL: `http://localhost:${BACKEND_PORT}`, NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE: "LOCAL",