Skip to content
51 changes: 48 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E (manual)
name: E2E

on:
workflow_dispatch:
Expand All @@ -7,23 +7,68 @@ on:
description: Ceros dev environment to target (experience URLs + API host derive from it)
type: string
default: latest
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- ceros.php
- includes/**
- src/**
- public/**
- package.json
- package-lock.json
- .wp-env.json
- tests/e2e/**
- .github/workflows/e2e-tests.yml
# Saves the npm cache on main, the only branch every PR can restore from.
push:
branches: [main]
paths:
- package-lock.json
- tests/e2e/package-lock.json
- .github/workflows/e2e-tests.yml

permissions:
contents: read

concurrency:
group: e2e-${{ github.ref }}
group: e2e-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
warm-cache:
name: Save the npm cache
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Set up Node
uses: actions/setup-node@v5
with:
node-version: '22'
cache: npm
cache-dependency-path: |
package-lock.json
tests/e2e/package-lock.json

- name: Install dependencies
run: |
npm ci
npm ci --prefix tests/e2e

e2e:
name: Playwright e2e (wp-env + real Ceros env)
# Not on drafts, and not on fork PRs, which get no secrets.
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && !github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
timeout-minutes: 35
env:
# wp-env's dev port (also the suite default).
BASE_URL: http://localhost:8888
E2E_CEROS_ENV: ${{ inputs.ceros_env }}
E2E_CEROS_ENV: ${{ inputs.ceros_env || 'latest' }}
steps:
- uses: actions/checkout@v5

Expand Down
14 changes: 10 additions & 4 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
Playwright tests for the Ceros block in the WordPress editor and on the published page,
run against a local `wp-env` instance.

**Not wired into CI or the pre-push hook, and not a required check.** These need WordPress,
Docker and network access, which the pre-push hook explicitly rules out. See [CI](#ci) below.
**Runs in CI on pull requests that are ready for review, but is not a required check or part of
the pre-push hook.** These need WordPress, Docker and network access, which the pre-push hook
explicitly rules out. See [CI](#ci) below.

## Prerequisites

Expand Down Expand Up @@ -172,8 +173,13 @@ not extend a shared base class, because at this size it would hold nothing.

## CI

The suite is not wired into CI and is not a required check — it spans two products (the
plugin and Ceros), and that ownership is unresolved. Running it anywhere, CI or another
`e2e-tests.yml` runs the suite on pull requests from this repository once they are ready for
review and change the plugin, its build inputs or the suite. Drafts and fork pull requests are
skipped, since a fork gets no secrets. A new push cancels the run it replaces. It can also be
run by hand against another Ceros environment (`ceros_env`).

It is not a required check: it spans two products (the plugin and Ceros), and that ownership
is unresolved. Running it anywhere, CI or another
machine, needs the same inputs as a local run: `E2E_CEROS_ENV`, the secret `E2E_CEROS_API_KEY`,
network access to that environment, and a pinned WordPress version (`.wp-env.json` leaves core
unset, which has resolved to a version with no tag in the mirror).
Loading