Skip to content

Commit 5697475

Browse files
committed
Run for push on main and run prettier
1 parent 205497a commit 5697475

1 file changed

Lines changed: 166 additions & 164 deletions

File tree

.github/workflows/tests.yml

Lines changed: 166 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: E2E Tests
22

33
on:
44
workflow_call:
5-
push:
65
pull_request:
6+
push:
7+
branches:
8+
- main
79

810
jobs:
911
e2e:
@@ -12,20 +14,20 @@ jobs:
1214
strategy:
1315
fail-fast: false
1416
matrix:
15-
php: [ "8.2", "8.3", "8.4" ]
16-
wordpress: [ "6.7", "6.8" ]
17+
php: ["8.2", "8.3", "8.4"]
18+
wordpress: ["6.7", "6.8"]
1719
exclude:
1820
# Exclude older PHP versions with newer WordPress
19-
- php: "7.4"
20-
wordpress: "6.5.3"
21+
- php: "7.4"
22+
wordpress: "6.5.3"
2123

2224
services:
2325
mysql:
2426
image: mysql:8.0
2527
env:
2628
MYSQL_DATABASE: wordpress
2729
MYSQL_ROOT_PASSWORD: root
28-
ports: [ 3306:3306 ]
30+
ports: [3306:3306]
2931
options: >-
3032
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot"
3133
--health-interval=10s
@@ -41,162 +43,162 @@ jobs:
4143
WP_DB_HOST: 127.0.0.1
4244

4345
steps:
44-
- name: Check MySQL tables
45-
run: |
46-
echo "Listing databases:"
47-
mysql -h 127.0.0.1 -uroot -proot -e "SHOW DATABASES;"
48-
49-
echo "Checking if 'wordpress' database has any tables:"
50-
mysql -h 127.0.0.1 -uroot -proot -D wordpress -e "SHOW TABLES;" || echo "No tables found (yet)."
51-
52-
- name: Checkout plugin
53-
uses: actions/checkout@v6
54-
with:
55-
persist-credentials: false
56-
57-
- name: Set up PHP
58-
uses: shivammathur/setup-php@v2
59-
with:
60-
# Note: Specified version is only for running tests,
61-
# as the WordPress PHP version is set inside the FrankenPHP Dockerfile.
62-
php-version: 8.4
63-
extensions: mysqli, zip, gd
64-
coverage: none
65-
tools: wp-cli
66-
67-
- name: Cache WordPress archive
68-
id: cache-wordpress
69-
uses: actions/cache@v5
70-
with:
71-
path: /tmp/wp
72-
key: wp-${{ matrix.wordpress }}
73-
74-
- name: Download WordPress
75-
if: steps.cache-wordpress.outputs.cache-hit != 'true'
76-
run: |
77-
mkdir -p /tmp/wp
78-
curl -O https://wordpress.org/wordpress-${WP_VERSION}.tar.gz
79-
tar -xzf wordpress-${WP_VERSION}.tar.gz --strip-components=1 -C /tmp/wp
80-
rm wordpress-${WP_VERSION}.tar.gz
81-
82-
- name: Set up Docker Buildx
83-
uses: docker/setup-buildx-action@v4
84-
85-
- name: Build FrankenPHP image (with cache)
86-
id: build
87-
uses: docker/build-push-action@v7
88-
env:
89-
DOCKER_BUILD_SUMMARY: false
90-
with:
91-
context: .
92-
file: .github/docker/Dockerfile
93-
tags: frankenphp-${{ matrix.php }}
94-
load: true
95-
build-args: |
96-
PHP_VERSION=${{ matrix.php }}
97-
cache-from: type=gha
98-
cache-to: type=gha,mode=max
99-
100-
- name: Start FrankenPHP server
101-
run: |
102-
docker run -d \
103-
--name frankenphp \
104-
--network host \
105-
-p 8100:8100 \
106-
-v /tmp/wp:/var/www/html \
107-
-v $GITHUB_WORKSPACE:/var/www/html/wp-content/plugins/simpleanalytics \
108-
-v $GITHUB_WORKSPACE/Caddyfile:/etc/frankenphp/Caddyfile \
109-
frankenphp-${{ matrix.php }}
110-
111-
- name: Wait for FrankenPHP to be ready
112-
run: |
113-
for i in $(seq 1 30); do
114-
curl -s -o /dev/null http://localhost:8100 && echo "Server is up" && exit 0
115-
echo "Waiting... ($i/30)"
116-
sleep 2
117-
done
118-
echo "Server did not start in time" && exit 1
119-
120-
- name: Verify MySQL is accepting connections
121-
run: |
122-
for i in $(seq 1 10); do
123-
mysql -h 127.0.0.1 -uroot -proot -e "SELECT 1" && echo "MySQL ready" && exit 0
124-
echo "Waiting for MySQL... ($i/10)"
125-
sleep 2
126-
done
127-
echo "MySQL not ready" && exit 1
128-
129-
- name: Install WordPress
130-
run: |
131-
rm -f /tmp/wp/wp-config.php
132-
wp config create \
133-
--dbname="$WP_DB_NAME" \
134-
--dbuser="$WP_DB_USER" \
135-
--dbpass="$WP_DB_PASS" \
136-
--dbhost="$WP_DB_HOST" \
137-
--path=/tmp/wp \
138-
--skip-check
139-
wp config set DISABLE_WP_CRON true --raw --path=/tmp/wp
140-
wp core install \
141-
--url="${WP_SITE_URL}" \
142-
--title="Test Site" \
143-
--admin_user=admin \
144-
--admin_password=admin \
145-
--admin_email=test@example.com \
46+
- name: Check MySQL tables
47+
run: |
48+
echo "Listing databases:"
49+
mysql -h 127.0.0.1 -uroot -proot -e "SHOW DATABASES;"
50+
51+
echo "Checking if 'wordpress' database has any tables:"
52+
mysql -h 127.0.0.1 -uroot -proot -D wordpress -e "SHOW TABLES;" || echo "No tables found (yet)."
53+
54+
- name: Checkout plugin
55+
uses: actions/checkout@v6
56+
with:
57+
persist-credentials: false
58+
59+
- name: Set up PHP
60+
uses: shivammathur/setup-php@v2
61+
with:
62+
# Note: Specified version is only for running tests,
63+
# as the WordPress PHP version is set inside the FrankenPHP Dockerfile.
64+
php-version: 8.4
65+
extensions: mysqli, zip, gd
66+
coverage: none
67+
tools: wp-cli
68+
69+
- name: Cache WordPress archive
70+
id: cache-wordpress
71+
uses: actions/cache@v5
72+
with:
73+
path: /tmp/wp
74+
key: wp-${{ matrix.wordpress }}
75+
76+
- name: Download WordPress
77+
if: steps.cache-wordpress.outputs.cache-hit != 'true'
78+
run: |
79+
mkdir -p /tmp/wp
80+
curl -O https://wordpress.org/wordpress-${WP_VERSION}.tar.gz
81+
tar -xzf wordpress-${WP_VERSION}.tar.gz --strip-components=1 -C /tmp/wp
82+
rm wordpress-${WP_VERSION}.tar.gz
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@v4
86+
87+
- name: Build FrankenPHP image (with cache)
88+
id: build
89+
uses: docker/build-push-action@v7
90+
env:
91+
DOCKER_BUILD_SUMMARY: false
92+
with:
93+
context: .
94+
file: .github/docker/Dockerfile
95+
tags: frankenphp-${{ matrix.php }}
96+
load: true
97+
build-args: |
98+
PHP_VERSION=${{ matrix.php }}
99+
cache-from: type=gha
100+
cache-to: type=gha,mode=max
101+
102+
- name: Start FrankenPHP server
103+
run: |
104+
docker run -d \
105+
--name frankenphp \
106+
--network host \
107+
-p 8100:8100 \
108+
-v /tmp/wp:/var/www/html \
109+
-v $GITHUB_WORKSPACE:/var/www/html/wp-content/plugins/simpleanalytics \
110+
-v $GITHUB_WORKSPACE/Caddyfile:/etc/frankenphp/Caddyfile \
111+
frankenphp-${{ matrix.php }}
112+
113+
- name: Wait for FrankenPHP to be ready
114+
run: |
115+
for i in $(seq 1 30); do
116+
curl -s -o /dev/null http://localhost:8100 && echo "Server is up" && exit 0
117+
echo "Waiting... ($i/30)"
118+
sleep 2
119+
done
120+
echo "Server did not start in time" && exit 1
121+
122+
- name: Verify MySQL is accepting connections
123+
run: |
124+
for i in $(seq 1 10); do
125+
mysql -h 127.0.0.1 -uroot -proot -e "SELECT 1" && echo "MySQL ready" && exit 0
126+
echo "Waiting for MySQL... ($i/10)"
127+
sleep 2
128+
done
129+
echo "MySQL not ready" && exit 1
130+
131+
- name: Install WordPress
132+
run: |
133+
rm -f /tmp/wp/wp-config.php
134+
wp config create \
135+
--dbname="$WP_DB_NAME" \
136+
--dbuser="$WP_DB_USER" \
137+
--dbpass="$WP_DB_PASS" \
138+
--dbhost="$WP_DB_HOST" \
146139
--path=/tmp/wp \
147-
--skip-email \
148-
--allow-root
149-
wp user create author author@local.test --role=author --user_pass=author --path=/tmp/wp --allow-root
150-
wp user create editor editor@local.test --role=editor --user_pass=editor --path=/tmp/wp --allow-root
151-
wp user create subscriber subscriber@local.test --role=subscriber --user_pass=subscriber --path=/tmp/wp --allow-root
152-
153-
- name: Show current config values
154-
run: wp config list --path=/tmp/wp --allow-root
155-
156-
- name: Warm up WordPress
157-
run: |
158-
curl -s -o /dev/null -w "wp-login.php: HTTP %{http_code} in %{time_total}s\n" http://localhost:8100/wp-login.php
159-
curl -s -o /dev/null -w "homepage: HTTP %{http_code} in %{time_total}s\n" http://localhost:8100/
160-
161-
- name: Install pnpm
162-
uses: pnpm/action-setup@v5
163-
with:
164-
version: 10
165-
166-
- name: Setup Node
167-
uses: actions/setup-node@v6
168-
with:
169-
node-version: lts/*
170-
cache: "pnpm"
171-
172-
- name: Install pnpm dependencies
173-
run: pnpm install
174-
175-
- name: Install Playwright Browsers
176-
run: npx playwright install --with-deps
177-
178-
- name: Cache composer dependencies
179-
uses: actions/cache@v5
180-
with:
181-
path: vendor
182-
key: composer-${{ hashFiles('composer.lock') }}
183-
184-
- name: Run composer install
185-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
186-
187-
- name: Run Pest tests
188-
run: ./vendor/bin/pest -v --ci --bail --colors=always
189-
190-
- name: Upload test results
191-
if: always()
192-
uses: actions/upload-artifact@v7
193-
with:
194-
name: test-results-php${{ matrix.php }}-wp${{ matrix.wordpress }}
195-
path: tests/Browser/Screenshots
196-
retention-days: 30
197-
198-
- name: Show FrankenPHP logs
199-
if: always()
200-
run: |
201-
echo "=== FrankenPHP logs ==="
202-
docker logs frankenphp || echo "No logs found"
140+
--skip-check
141+
wp config set DISABLE_WP_CRON true --raw --path=/tmp/wp
142+
wp core install \
143+
--url="${WP_SITE_URL}" \
144+
--title="Test Site" \
145+
--admin_user=admin \
146+
--admin_password=admin \
147+
--admin_email=test@example.com \
148+
--path=/tmp/wp \
149+
--skip-email \
150+
--allow-root
151+
wp user create author author@local.test --role=author --user_pass=author --path=/tmp/wp --allow-root
152+
wp user create editor editor@local.test --role=editor --user_pass=editor --path=/tmp/wp --allow-root
153+
wp user create subscriber subscriber@local.test --role=subscriber --user_pass=subscriber --path=/tmp/wp --allow-root
154+
155+
- name: Show current config values
156+
run: wp config list --path=/tmp/wp --allow-root
157+
158+
- name: Warm up WordPress
159+
run: |
160+
curl -s -o /dev/null -w "wp-login.php: HTTP %{http_code} in %{time_total}s\n" http://localhost:8100/wp-login.php
161+
curl -s -o /dev/null -w "homepage: HTTP %{http_code} in %{time_total}s\n" http://localhost:8100/
162+
163+
- name: Install pnpm
164+
uses: pnpm/action-setup@v5
165+
with:
166+
version: 10
167+
168+
- name: Setup Node
169+
uses: actions/setup-node@v6
170+
with:
171+
node-version: lts/*
172+
cache: "pnpm"
173+
174+
- name: Install pnpm dependencies
175+
run: pnpm install
176+
177+
- name: Install Playwright Browsers
178+
run: npx playwright install --with-deps
179+
180+
- name: Cache composer dependencies
181+
uses: actions/cache@v5
182+
with:
183+
path: vendor
184+
key: composer-${{ hashFiles('composer.lock') }}
185+
186+
- name: Run composer install
187+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
188+
189+
- name: Run Pest tests
190+
run: ./vendor/bin/pest -v --ci --bail --colors=always
191+
192+
- name: Upload test results
193+
if: always()
194+
uses: actions/upload-artifact@v7
195+
with:
196+
name: test-results-php${{ matrix.php }}-wp${{ matrix.wordpress }}
197+
path: tests/Browser/Screenshots
198+
retention-days: 30
199+
200+
- name: Show FrankenPHP logs
201+
if: always()
202+
run: |
203+
echo "=== FrankenPHP logs ==="
204+
docker logs frankenphp || echo "No logs found"

0 commit comments

Comments
 (0)