From f320e845bbbe854392482fcb7848336909528529 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sun, 5 Jul 2026 16:33:10 +0200 Subject: [PATCH] chore: nightly full e2e and size limit tests --- .github/workflows/nightly.yml | 49 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 31 +++++----------------- .husky/pre-commit | 9 ++++--- .husky/pre-push | 4 --- test/e2e/README.md | 22 ++++++++++++---- 5 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/nightly.yml delete mode 100755 .husky/pre-push diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..268cc87 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,49 @@ +name: Nightly E2E + +# The full cross-browser e2e matrix (Chromium + Firefox + WebKit) is heavy to +# set up (browser downloads + system deps), so it runs once a day instead of on +# every push/PR. Push/PR CI keeps a fast Chromium-only e2e gate (test.yml). +on: + schedule: + # 06:00 UTC daily + - cron: '0 6 * * *' + workflow_dispatch: # allow manual runs from the Actions tab + +permissions: + contents: read + +jobs: + e2e-all: + name: E2E (Chromium + Firefox + WebKit) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: pnpm/action-setup@v4 + with: + version: 11 + - uses: actions/setup-node@v6 + with: + node-version-file: .nvmrc + cache: pnpm + - run: pnpm install --frozen-lockfile + # Firefox/WebKit need system deps that `--with-deps` installs via apt. + - name: Install Playwright browsers + run: pnpm exec playwright install --with-deps chromium firefox webkit + - run: pnpm test:e2e:all + + size: + name: Size limit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: pnpm/action-setup@v4 + with: + version: 11 + - uses: actions/setup-node@v6 + with: + node-version-file: .nvmrc + cache: pnpm + - run: pnpm install --frozen-lockfile + # `pnpm size-limit` builds `dist/` (tsc + esbuild) and checks each entry + # against the byte budgets declared in package.json `size-limit`. + - run: pnpm size-limit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9631516..a58e39e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ permissions: jobs: unit: - name: Unit (happy-dom) + name: Unit runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -31,7 +31,7 @@ jobs: - run: pnpm test e2e: - name: E2E (Chromium + Firefox + WebKit) + name: E2E runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -43,25 +43,8 @@ jobs: node-version-file: .nvmrc cache: pnpm - run: pnpm install --frozen-lockfile - # Downloads the browser binaries and their OS libraries (Firefox/WebKit - # need system deps that `--with-deps` installs via apt on the runner). - - name: Install Playwright browsers - run: pnpm exec playwright install --with-deps chromium firefox webkit - - run: pnpm test:e2e:all - - size: - name: Size limit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 - with: - version: 11 - - uses: actions/setup-node@v6 - with: - node-version-file: .nvmrc - cache: pnpm - - run: pnpm install --frozen-lockfile - # `pnpm size-limit` builds `dist/` (tsc + esbuild) and checks each entry - # against the byte budgets declared in package.json `size-limit`. - - run: pnpm size-limit + # Chromium only on push/PR — the full Firefox/WebKit matrix runs nightly + # (.github/workflows/nightly.yml). + - name: Install Playwright Chromium + run: pnpm exec playwright install --with-deps chromium + - run: pnpm test:e2e diff --git a/.husky/pre-commit b/.husky/pre-commit index d34f720..322c4e4 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,8 @@ -# Lean: lint + format staged files, then the fast unit suite. -# Heavier checks (browser e2e, size-limit) run on pre-push; the full -# cross-browser matrix runs in CI. +# Everything runs at commit time. This repo auto-pushes to multiple remotes +# (github, forgejo, sourcehut — see post-commit), so a pre-push hook would +# re-run these once per remote; keeping them here runs them once per commit. +# The full cross-browser e2e matrix still runs nightly in CI. Order: cheap → expensive. pnpm exec lint-staged pnpm test +pnpm test:e2e +pnpm size-limit diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100755 index 07bbad3..0000000 --- a/.husky/pre-push +++ /dev/null @@ -1,4 +0,0 @@ -# Heavier gate before code leaves the machine: browser e2e (Chromium only — -# Firefox/WebKit + their system deps are exercised in CI) and the size budget. -pnpm test:e2e -pnpm size-limit diff --git a/test/e2e/README.md b/test/e2e/README.md index 1a39010..16712cf 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -18,12 +18,24 @@ pnpm test:e2e:webkit # WebKit (the engine behind Safari) pnpm test:e2e:all # Chromium + Firefox + WebKit pnpm test # fast unit suite (happy-dom), unchanged -pnpm test:all # unit + default e2e +pnpm test:all # unit + full e2e (all 3 engines) ``` `pnpm test:e2e` stays on Chromium so it works everywhere with minimal setup; use -`test:e2e:all` (or a CI matrix) for the full cross-browser run. Each script just -sets the `E2E_BROWSERS` env var (comma-separated), which the config reads. +`test:e2e:all` for the full cross-browser run. Each script just sets the +`E2E_BROWSERS` env var (comma-separated), which the config reads. + +### Where each runs + +| Stage | e2e scope | +| ----------------------------- | ----------------------------- | +| pre-commit | none (unit only) | +| pre-push | `test:e2e` (Chromium) | +| CI on push to `main` / PRs | `test:e2e` (Chromium) | +| CI nightly (`nightly.yml`) | `test:e2e:all` (all 3 engines) | + +The full Firefox/WebKit matrix is heavy to provision, so it runs once a day +(and on-demand via **workflow_dispatch**) rather than on every push/PR. Config lives in `vitest.e2e.config.mjs` (Vitest browser mode + the `@vitest/browser-playwright` provider), kept separate from `vitest.config.mjs` @@ -38,8 +50,8 @@ npx playwright install-deps # Linux only: system libraries Firefox and especially WebKit need extra OS libraries on Linux (`libwoff1`, etc.); `playwright install-deps` requires root. Without them those engines fail -to launch — which is why the default target is Chromium and CI installs the deps -before running `test:e2e:all`. +to launch — which is why the default target is Chromium, and only the nightly +workflow installs the deps before running `test:e2e:all`. ## Coverage