Skip to content

Commit 759d6e6

Browse files
committed
ci: add wp-env Playwright E2E workflow
Runs the @lite and @Pro suites in one job against @wordpress/env. Builds the plugin first (composer install in dev mode so Mozart emits lib/packages/, then npm run build) because build/, lib/ and vendor/ are gitignored. .wp-env.json maps ../../../tryaura-pro as a workspace sibling, so the job either checks out the Pro repo there (when PRO_REPO_TOKEN is set) or writes a stub plugin header, without which wp-env start aborts. @lite and @Pro run sequentially against a single wp-env instance, each with its own Playwright --output dir so the second run does not wipe the first one's traces. The @Pro step is guarded by !cancelled() so a @lite failure still reports both suites.
1 parent 5507f0f commit 759d6e6

1 file changed

Lines changed: 151 additions & 0 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: E2E (wp-env)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
inputs:
10+
suite:
11+
description: "Which tagged suite to run"
12+
type: choice
13+
default: both
14+
options:
15+
- both
16+
- lite
17+
- pro
18+
19+
concurrency:
20+
group: e2e-${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
e2e:
25+
name: Playwright @lite + @pro
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 40
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Detect Pro access
33+
id: pro_token
34+
env:
35+
PRO_REPO_TOKEN: ${{ secrets.PRO_REPO_TOKEN }}
36+
run: |
37+
if [ -n "$PRO_REPO_TOKEN" ]; then
38+
echo "enabled=true" >> "$GITHUB_OUTPUT"
39+
else
40+
echo "enabled=false" >> "$GITHUB_OUTPUT"
41+
echo "::notice::PRO_REPO_TOKEN not set — the @pro suite will be skipped."
42+
fi
43+
44+
- name: Checkout tryaura-pro
45+
if: steps.pro_token.outputs.enabled == 'true'
46+
uses: actions/checkout@v4
47+
with:
48+
repository: getdokan/tryaura-pro
49+
token: ${{ secrets.PRO_REPO_TOKEN }}
50+
path: .tryaura-pro-src
51+
52+
- name: Setup PHP 8.2
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: '8.2'
56+
coverage: none
57+
tools: composer:v2
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: '20'
63+
cache: npm
64+
cache-dependency-path: |
65+
package-lock.json
66+
tests/pw/package-lock.json
67+
68+
- name: Build plugin
69+
# Dev install on purpose: Mozart (post-install-cmd) only runs in dev
70+
# mode and generates lib/packages/, which the plugin loads at runtime.
71+
run: |
72+
composer install --no-interaction --no-progress
73+
npm ci
74+
npm run build
75+
76+
- name: Prepare tryaura-pro mapping
77+
# .wp-env.json maps ../../../tryaura-pro — a sibling of the workspace.
78+
# Without Pro source, a stub keeps `wp-env start` from aborting; @lite
79+
# never activates it.
80+
env:
81+
HAS_PRO: ${{ steps.pro_token.outputs.enabled }}
82+
run: |
83+
PRO_DIR="$(dirname "$GITHUB_WORKSPACE")/tryaura-pro"
84+
rm -rf "$PRO_DIR"
85+
86+
if [ "$HAS_PRO" = "true" ]; then
87+
mv "$GITHUB_WORKSPACE/.tryaura-pro-src" "$PRO_DIR"
88+
cd "$PRO_DIR"
89+
if [ -f composer.json ]; then
90+
composer install --no-interaction --no-progress
91+
fi
92+
if [ -f package-lock.json ]; then
93+
npm ci
94+
npm run build --if-present
95+
fi
96+
else
97+
mkdir -p "$PRO_DIR"
98+
cat > "$PRO_DIR/tryaura-pro.php" <<'PHP'
99+
<?php
100+
/**
101+
* Plugin Name: TryAura Pro (CI stub)
102+
* Description: Placeholder so the wp-env mapping resolves when Pro source is unavailable.
103+
*/
104+
PHP
105+
fi
106+
107+
- name: Install E2E dependencies
108+
working-directory: tests/pw
109+
run: |
110+
npm ci
111+
npx playwright install --with-deps chromium
112+
113+
- name: Start wp-env
114+
working-directory: tests/pw
115+
run: npx wp-env start
116+
117+
- name: Run @lite specs
118+
if: ${{ !cancelled() && (github.event_name != 'workflow_dispatch' || inputs.suite != 'pro') }}
119+
working-directory: tests/pw
120+
env:
121+
WP_BASE_URL: http://localhost:8899
122+
run: npm run test:lite -- --output=test-results/lite
123+
124+
- name: Run @pro specs
125+
# Runs even if @lite failed, so one run reports both suites.
126+
if: ${{ !cancelled() && steps.pro_token.outputs.enabled == 'true' && (github.event_name != 'workflow_dispatch' || inputs.suite != 'lite') }}
127+
working-directory: tests/pw
128+
env:
129+
WP_BASE_URL: http://localhost:8899
130+
run: npm run test:pro -- --output=test-results/pro
131+
132+
- name: wp-env logs
133+
if: failure()
134+
working-directory: tests/pw
135+
run: npx wp-env logs tests --no-watch || true
136+
137+
- name: Upload Playwright artifacts
138+
if: always()
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: playwright-artifacts
142+
path: |
143+
tests/pw/playwright-report
144+
tests/pw/test-results
145+
retention-days: 7
146+
if-no-files-found: ignore
147+
148+
- name: Stop wp-env
149+
if: always()
150+
working-directory: tests/pw
151+
run: npx wp-env stop || true

0 commit comments

Comments
 (0)