Files
it-tools/playwright.config.ts
da38faa9be ci: pnpm 12, pnpm/setup v3, faster and pinned CI, single Vercel deploy workflow (#577)
* ci: move to pnpm 12, pnpm/setup v3 and faster, pinned CI

pnpm 12.6.0 is declared in devEngines.packageManager instead of
packageManager, so pnpm/setup, the Dockerfile and local installs all pick
the same version; the lockfile records the resolved binary. Every workflow
moves to pnpm/setup v3, and the Vercel workflows gain a setup step so
`vercel build` runs with that pnpm rather than whatever is on the runner.

CI time:
- ci runs format check, lint, unit tests, typecheck and build as parallel
  steps instead of one after another.
- E2E builds the app once and shares dist with the three browser jobs
  instead of rebuilding it in each.
- ci and E2E cancel superseded runs on the same ref.
- The Docker latest/baseurl workflows no longer repeat ci's checks. They
  run on workflow_run after ci succeeds for a push, and build the commit
  ci tested.

Runners are pinned to ubuntu-26.04-arm. CodeQL stays on x64
(ubuntu-26.04): only the x64 image ships the CodeQL bundle in its tool
cache. The Playwright cache key now includes the runner architecture.

Every action is pinned to its latest release by commit SHA with a version
comment, the Dockerfile base images by digest, and the pnpm and Vercel CLI
installs to exact versions, matching the Renovate presets already enabled
(helpers:pinGitHubActionDigests, docker:pinDigests).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

* ci: deploy to Vercel from one workflow with previews and a concurrency group

Replaces sharevb-vercel-preview.yml and sharevb-vercel-prod.yml with
deploy.yaml, which builds here and deploys the prebuilt output:

- One concurrency group per ref with cancel-in-progress, so a burst of
  pushes costs one deployment instead of one per push.
- A GitHub environment per run (Production or Preview), which restores the
  Environments sidebar and the PR's "View deployment" button.
- Pull requests build their own head commit, named after the PR branch so
  Vercel shows the branch rather than "HEAD"; runs from forks are skipped,
  since they get no secrets.
- Fails early on missing secrets, refuses to deploy a build without
  index.html, and pins the Vercel CLI.

The production hostname for sitemap.xml and robots.txt comes from the
VERCEL_PRODUCTION_URL repository variable instead of being hardcoded, so
the same file serves any deployment. Secrets can live on the repository
or on the Production/Preview environments.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

* build: stop compiling tree-sitter's native addon

curlconverter depends on tree-sitter and tree-sitter-bash for its Node
shell parser, but the app only uses curlconverter in the browser, where its
`browser` field swaps in web-tree-sitter (WASM). The native addon is never
loaded.

Building it anyway broke installs: tree-sitter 0.21 ships prebuilds only for
darwin-x64 and win32-x64, so Linux compiles it from source, and its C++17
flags fail against Node 24.21's headers, which require C++20. That is what
failed pnpm install on the arm64 runners.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

* ci(e2e): run the browser jobs on x64

On ubuntu-26.04-arm the Playwright suite ran over 7x slower: chromium was
still in the test step after 27 minutes, against under 4 on x64. The build
job stays on arm; its output is architecture-independent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

* test(e2e): stop the preview server with SIGTERM so runs exit

pnpm 12 starts the script it runs in its own process group. Playwright
stops its webServer by SIGKILLing the `pnpm preview` process group, which
no longer contains vite: vite survives, keeps the output pipes open, and
Playwright waits on it forever. The E2E jobs finished every test and then
hung until the job timeout.

pnpm 12.6 forwards SIGTERM to the script it runs, so stop the server with
SIGTERM instead. Locally with pnpm 12.6.0: 112 tests in 1.8 min, clean
exit, nothing left listening on the port.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

* Revert "ci(e2e): run the browser jobs on x64"

The slowdown blamed on arm was the Playwright webServer hang fixed in the
previous commit: every test had finished and the job was waiting on an
orphaned vite process. The suite is not slower on arm, so the browser jobs
go back to ubuntu-26.04-arm like the rest.

This reverts commit 9f5af383.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

* ci(docker): publish one image at a time, newest wins

Two workflow_run publishes could overlap, and whichever finished last set
the tags, even if it built the older commit. A single concurrency group per
workflow with cancel-in-progress fixes that: ci already cancels superseded
runs on the branch, so publishes arrive in commit order and cancelling the
older one leaves the newest commit on the tags. Raised in review.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017s2w39tKNdBdD8kyfThuLy

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: sharevb <sharevb@gmail.com>
2026-09-27 18:37:50 +02:00

93 lines
3.3 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
const isCI = !!process.env.CI;
// `pnpm preview` serves the production build here, and Playwright starts it
// itself. Point E2E_BASE_URL somewhere else -- a running `pnpm dev`, a deployed
// preview -- and that is taken as "I am supplying the server", so Playwright
// leaves the lifecycle alone.
//
// Deliberately not BASE_URL: vite.config.ts already reads that as the app's
// base path (`/it-tools/`), so sharing the name would make one value mean two
// incompatible things.
const previewUrl = 'http://localhost:5050';
const baseUrl = process.env.E2E_BASE_URL || previewUrl;
const useWebServer = baseUrl === previewUrl;
// What the browser sees is pinned by `timezoneId` below, and the specs do no
// date maths of their own, so today this changes nothing. It keeps the runner
// deterministic if a spec ever does compute a date on the node side.
process.env.TZ = 'UTC';
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './src',
testMatch: /\.e2e\.(spec\.)?ts$/,
/* First paint of heavy lazy-loaded tools can exceed the 5s default on
slow CI browsers (webkit especially). Three workers share a runner, so
first paint is slower still and CI needs more headroom than a local run.
The test timeout has to stay above the expect timeout, otherwise it fires
first and reports a timeout instead of the assertion that actually failed. */
timeout: isCI ? 60_000 : 30_000,
expect: { timeout: isCI ? 30_000 : 15_000 },
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: isCI,
/* Retry on CI only */
retries: isCI ? 2 : 0,
/* CI runs one browser per job on a 4-core runner. Three workers saturates it
(measured ~95% busy); a fourth adds nothing and leaves no core for the
preview server. */
workers: isCI ? 3 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: baseUrl,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
testIdAttribute: 'data-test-id',
locale: 'en-GB',
timezoneId: 'Europe/Paris',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
/* Run your local dev server before starting the tests */
...(useWebServer && {
webServer: {
command: 'pnpm preview',
url: previewUrl,
reuseExistingServer: !isCI,
// pnpm 12 runs the script in its own process group, so Playwright's
// default SIGKILL to the `pnpm preview` group misses vite: it survives,
// holds the output pipes open, and the run never exits. pnpm forwards
// SIGTERM to the script, so stop it that way.
gracefulShutdown: { signal: 'SIGTERM', timeout: 5_000 },
},
}),
});