Skip to content

Commit aa5c064

Browse files
authored
CI: add e2e test workflow (#1030)
* ci: add e2e test workflow * fix: decouple e2e tests from Jetpack monorepo * fix: make apache2-wrapper.sh executable * fix: approve build scripts and fix jest config URL resolution * fix: inline tsconfig from jetpack-e2e-commons
1 parent 2a7c8b1 commit aa5c064

6 files changed

Lines changed: 3421 additions & 5 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: E2E Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [trunk]
7+
8+
jobs:
9+
e2e:
10+
name: E2E Tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: pnpm/action-setup@v4
18+
with:
19+
version: latest
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
cache: pnpm
25+
cache-dependency-path: tests/e2e/pnpm-lock.yaml
26+
27+
- name: Install dependencies
28+
working-directory: tests/e2e
29+
run: pnpm install --frozen-lockfile
30+
31+
- name: Start Docker environment
32+
working-directory: tests/e2e
33+
run: docker compose up -d --build --wait
34+
35+
- name: Wait for WordPress
36+
run: |
37+
echo "Waiting for WordPress to be ready..."
38+
for i in $(seq 1 30); do
39+
if curl -sf http://localhost:2022/ > /dev/null 2>&1; then
40+
echo "WordPress is ready."
41+
exit 0
42+
fi
43+
echo "Attempt $i/30 - waiting 5s..."
44+
sleep 5
45+
done
46+
echo "WordPress did not become ready in time."
47+
docker compose -f tests/e2e/docker-compose.yml --project-directory tests/e2e logs
48+
exit 1
49+
50+
- name: Run e2e tests
51+
working-directory: tests/e2e
52+
run: pnpm test:run
53+
54+
- name: Docker logs
55+
if: failure()
56+
working-directory: tests/e2e
57+
run: docker compose logs
58+
59+
- name: Tear down Docker environment
60+
if: always()
61+
working-directory: tests/e2e
62+
run: docker compose down -v

tests/e2e/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'url';
22
import { config as dotenvConfig } from 'dotenv';
33

44
// Read .env file so variables are available in tests.
5-
dotenvConfig( { path: fileURLToPath( '.env', import.meta.url ) } );
5+
dotenvConfig( { path: fileURLToPath( new URL( '.env', import.meta.url ) ) } );
66

77
export default {
88
preset: 'ts-jest',

tests/e2e/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"type": "module",
44
"scripts": {
5-
"build": "pnpm jetpack build plugins/super-cache -v --no-pnpm-install --production",
5+
"build": "echo 'No build needed'",
66
"clean": "rm -rf output",
77
"distclean": "rm -rf node_modules",
88
"env:down": "docker-compose down",
@@ -11,12 +11,16 @@
1111
"test:run": "jest --runInBand",
1212
"typecheck": "tsgo --noEmit"
1313
},
14+
"pnpm": {
15+
"onlyBuiltDependencies": [
16+
"unrs-resolver"
17+
]
18+
},
1419
"devDependencies": {
1520
"@jest/globals": "^30.0.0",
1621
"@types/node": "^24.12.0",
1722
"@types/shell-escape": "0.2.3",
1823
"@typescript/native-preview": "7.0.0-dev.20260225.1",
19-
"_jetpack-e2e-commons": "workspace:*",
2024
"axios": "1.13.5",
2125
"cheerio": "1.2.0",
2226
"domhandler": "5.0.3",

0 commit comments

Comments
 (0)