diff --git a/.github/actions/e2e-setup/action.yml b/.github/actions/e2e-setup/action.yml index c2d2c80c5b..b42b8b4236 100644 --- a/.github/actions/e2e-setup/action.yml +++ b/.github/actions/e2e-setup/action.yml @@ -42,6 +42,26 @@ runs: shell: bash run: npx nx run-many -t ci:build + # Cache the Chromium binary (~120MB) keyed on the resolved Playwright + # version, so it isn't re-downloaded every shard/run. Browser versions are + # pinned to the Playwright package version, so the version is the correct + # cache key. On a hit, `playwright install` finds the browser present and + # only installs OS deps. + - name: Resolve Playwright version + id: playwright-version + shell: bash + run: + echo "version=$(cd packages/app && node -p + "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT" + + - name: Cache Playwright browsers + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: + ${{ runner.os }}-playwright-${{ + steps.playwright-version.outputs.version }} + - name: Install Playwright browsers shell: bash run: cd packages/app && npx playwright install --with-deps chromium diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 9cd34cb1fd..54a835e157 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -5,7 +5,10 @@ on: jobs: e2e-tests: name: E2E Tests - Shard ${{ matrix.shard }} - runs-on: ubuntu-24.04 + # 8-core runner so the 4 Playwright workers (see playwright.config.ts) have + # CPU headroom alongside the app + ClickHouse + MongoDB — 4 workers + # over-subscribed the 4-vCPU ubuntu-24.04 runner and caused timeouts. + runs-on: 8-core-playwright timeout-minutes: 15 permissions: contents: read diff --git a/packages/app/playwright.config.ts b/packages/app/playwright.config.ts index d03d278af9..5c571d578b 100644 --- a/packages/app/playwright.config.ts +++ b/packages/app/playwright.config.ts @@ -32,8 +32,16 @@ export default defineConfig({ forbidOnly: !!process.env.CI, /* Retry on CI only */ retries: process.env.CI ? 2 : 1, - /* Use multiple workers on CI for faster execution */ - workers: process.env.CI ? 2 : undefined, + /* Use multiple workers on CI for faster execution. CI e2e shards run on + * 8-core runners (see .github/workflows/e2e-tests.yml), so 4 workers leave + * headroom for the app + ClickHouse + Mongo. Override with E2E_WORKERS + * (a positive integer); anything else falls back to the default. */ + workers: (() => { + const raw = process.env.E2E_WORKERS; + const parsed = raw ? Number(raw) : NaN; + if (Number.isInteger(parsed) && parsed >= 1) return parsed; + return process.env.CI ? 4 : undefined; + })(), /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: [ ['html'],