From add59f5a20f402f9bc16952dc07a0b5021d22f3b Mon Sep 17 00:00:00 2001 From: Dominic Bett Date: Tue, 13 Oct 2026 18:55:07 +0300 Subject: [PATCH 1/5] ci: start wp-env while the e2e tools install wp-env now starts in the background while the e2e dependencies and Chrome install, and a later step waits for it and prints its log. WordPress core comes from the release zip instead of a git clone. --- .github/workflows/e2e-tests.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 702e44a..76acff8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,14 +42,18 @@ jobs: npm run build # Pin WordPress to the test-utils line (wp-6.9 -> 1.33.2); .wp-env.json leaves core unset. + # A release zip downloads faster than a clone of WordPress/WordPress, and does not fail with `early EOF`. # Pin PHP to 8.2 here (bookworm base) rather than the committed 7.4 (bullseye), # whose base image's apt packages are archived and 404 during the image build. - name: Pin WordPress core and PHP for wp-env run: | - echo '{ "core": "WordPress/WordPress#6.9.6", "phpVersion": "8.2" }' > .wp-env.override.json + echo '{ "core": "https://wordpress.org/wordpress-6.9.6.zip", "phpVersion": "8.2" }' > .wp-env.override.json + # Runs in the background while the e2e dependencies and Chrome install. - name: Start wp-env - run: npm run env:start + run: | + ( npm run env:start > "$RUNNER_TEMP/wp-env.log" 2>&1 + echo $? > "$RUNNER_TEMP/wp-env.exit" ) > /dev/null 2>&1 & - name: Install e2e dependencies working-directory: tests/e2e @@ -59,6 +63,13 @@ jobs: working-directory: tests/e2e run: npx playwright install --with-deps chrome + - name: Wait for wp-env + timeout-minutes: 10 + run: | + until [ -f "$RUNNER_TEMP/wp-env.exit" ]; do sleep 1; done + cat "$RUNNER_TEMP/wp-env.log" + exit "$(cat "$RUNNER_TEMP/wp-env.exit")" + - name: Configure the plugin for the Ceros env working-directory: tests/e2e env: From 95769a9105dd42f70b5b7478f0c38aa28a51940b Mon Sep 17 00:00:00 2001 From: Dominic Bett Date: Tue, 13 Oct 2026 20:59:34 +0300 Subject: [PATCH 2/5] ci: share main's npm cache with the e2e workflow The e2e workflow keyed its npm cache on both lockfiles, a key nothing on main saves, so every branch run missed it. Keying on the root lockfile, as ci.yml does, reuses the cache ci.yml saves on main. --- .github/workflows/e2e-tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 76acff8..7d1d9a8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -32,9 +32,8 @@ jobs: with: node-version: '22' cache: npm - cache-dependency-path: | - package-lock.json - tests/e2e/package-lock.json + # Same key as ci.yml, which saves it on main, so every branch reuses main's cache. + cache-dependency-path: package-lock.json - name: Install and build the plugin run: | From 9b099e44ff4cdf28b01ead053032e4af41faab87 Mon Sep 17 00:00:00 2001 From: Dominic Bett Date: Tue, 13 Oct 2026 22:04:15 +0300 Subject: [PATCH 3/5] Revert "ci: share main's npm cache with the e2e workflow" This reverts commit 95769a9105dd42f70b5b7478f0c38aa28a51940b. --- .github/workflows/e2e-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 7d1d9a8..76acff8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -32,8 +32,9 @@ jobs: with: node-version: '22' cache: npm - # Same key as ci.yml, which saves it on main, so every branch reuses main's cache. - cache-dependency-path: package-lock.json + cache-dependency-path: | + package-lock.json + tests/e2e/package-lock.json - name: Install and build the plugin run: | From 776c9f86d3330858af70758b7a4d76710179b25a Mon Sep 17 00:00:00 2001 From: Dominic Bett Date: Thu, 15 Oct 2026 18:41:45 +0300 Subject: [PATCH 4/5] ci: run the e2e suite on pull requests that are ready for review Skips drafts, fork pull requests (no secrets) and changes outside the plugin, its build inputs and the suite. A small job on main saves the npm cache under the e2e key, so pull request runs restore it instead of saving their own. --- .github/workflows/e2e-tests.yml | 51 +++++++++++++++++++++++++++++++-- tests/e2e/README.md | 14 ++++++--- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 30f1d01..49ca47b 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,4 +1,4 @@ -name: E2E (manual) +name: E2E on: workflow_dispatch: @@ -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 diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 7cdb95b..1468d02 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -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 @@ -171,8 +172,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). From 5ada9ad05105f24cbe3b511807e4e353293b264e Mon Sep 17 00:00:00 2001 From: Dominic Bett Date: Thu, 15 Oct 2026 18:54:56 +0300 Subject: [PATCH 5/5] ci: check that a new push cancels the running e2e run