Files
magnus919_agent-skills/playwright/references/05-ci-integration.md
T
Magnus Hedemarkandfactory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> b0845776a1 chore(docs): pin npx package versions in skill docs (Fixes #381)
Pin copy-pasteable npx invocations to explicit versions so agents
executing them verbatim get reproducible behavior:

- playwright docs: npx playwright@1.62.1 (SKILL.md, README.md,
  references 02-selectors / 05-ci-integration / 07-accessibility)
- mermaid-diagrams: @mermaid-js/mermaid-cli@11.16.0 (SKILL.md,
  references/pdf-rendering-pipeline.md)
- hugo-theme seo-outputs-testing: @axe-core/cli@4.13.0
- agent-skills using-scripts.md: strengthen version-pinning bullet
  into a normative rule for copy-pasteable commands

Reword the anydoc cli-reference "Version pinning" prose so the
anti-pattern is explained didactically without presenting an unpinned
command as a recipe; the @0.1.6 house pin is unchanged.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-08-22 22:07:49 -04:00

3.3 KiB
Raw Blame History

CI Integration

Last Updated: 2026-08-03

Playwright in CI is: install browsers + OS deps, pin the version, run the suite with retries and tracing, and surface a debuggable report. This reference assumes GitHub Actions; the same shape applies to any runner.

Minimal GitHub Actions workflow

name: e2e
on: [push, pull_request]
jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: npm }
      - run: npm ci
      - run: npx playwright@1.62.1 install --with-deps chromium
      - run: npx playwright@1.62.1 test
      - if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 14

Non-negotiables

  1. Install browsers with OS deps: npx playwright@1.62.1 install --with-deps (not bare install) on Linux runners; --with-deps installs the system libraries Chromium/Firefox/WebKit need.

  2. Pin and cache:

    • npm ci with a committed package-lock.json (never npm install).
    • Cache the browser download: ~/.cache/ms-playwright (Linux), ~/Library/Caches/ms-playwright (macOS), %USERPROFILE%\AppData\Local\ms-playwright (Windows).
    • Cache node_modules via the setup-node cache: npm option.
  3. Retry flaky tests on CI only, with traces on retry so failures are debuggable:

    retries: process.env.CI ? 2 : 0,
    use: { trace: 'on-first-retry' },
    
  4. Configure webServer in the config so the runner starts and waits for the app; never assume a long-lived dev server on a runner.

  5. Upload artifacts on failure: the HTML report, the JSON report, and the test-results/ dir (traces). Retention bounded (714 days) — see hard boundaries in SKILL.md about keeping evidence bounded.

Reporters

  • list/line — human-readable run output.

  • html — the browsable report (upload on failure).

  • json — the machine-readable report for agent triage:

    scripts/pwrun report --report test-results/test-results.json --json
    

    It prints stats (expected/unexpected/flaky/skipped), the failing specs, and the error message from the last retry — enough to triage without opening a browser.

  • github — inline annotations on GitHub Actions, keyed to the failing spec line.

Sharding across jobs

For large suites, split the run:

strategy:
  matrix:
    shard: [1/4, 2/4, 3/4, 4/4]
steps:
  - run: npx playwright@1.62.1 test --shard=${{ matrix.shard }}

Merge reports from all shards with playwright merge-reports (see 04-parallel-workers-and-sharding.md for the math).

Triage loop for a red CI run

  1. scripts/pwrun report --report <json> --json — get the failing specs and messages.
  2. Download the trace artifact (trace.zip) and open it in the Trace Viewer to see the failing action, network, and console.
  3. Classify: environment (missing dep/browser), selector (see 02-selectors.md), timing (webServer readiness, webServer.timeout), or app regression (real bug — the test did its job).
  4. Fix, re-run, and confirm the shard matrix is green.
  • Parallelism and sharding configuration: 04-parallel-workers-and-sharding.md.
  • Trace reading and headed debugging: 07-accessibility-and-debugging.md.