-
Notifications
You must be signed in to change notification settings - Fork 4
172 lines (149 loc) · 6.11 KB
/
tests.yml
File metadata and controls
172 lines (149 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: E2E Tests
on:
push:
pull_request:
jobs:
e2e:
name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ["8.2", "8.3", "8.4"]
wordpress: ["6.7", "6.8"]
exclude:
# Exclude older PHP versions with newer WordPress
- php: "7.4"
wordpress: "6.5.3"
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: root
ports: [3306:3306]
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
WP_VERSION: ${{ matrix.wordpress }}
WP_SITE_URL: http://localhost:8100
WP_DB_NAME: wordpress
WP_DB_USER: root
WP_DB_PASS: root
WP_DB_HOST: 127.0.0.1
steps:
- name: Check MySQL tables
run: |
echo "Listing databases:"
mysql -h 127.0.0.1 -uroot -proot -e "SHOW DATABASES;"
echo "Checking if 'wordpress' database has any tables:"
mysql -h 127.0.0.1 -uroot -proot -D wordpress -e "SHOW TABLES;" || echo "No tables found (yet)."
- name: Checkout plugin
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
# Note: Specified version is only for running tests,
# as the WordPress PHP version is set inside the FrankenPHP Dockerfile.
php-version: 8.4
extensions: mysqli, zip, gd
coverage: none
tools: wp-cli
- name: Cache WordPress archive
id: cache-wordpress
uses: actions/cache@v3
with:
path: /tmp/wp
key: wp-${{ matrix.wordpress }}
- name: Download WordPress
if: steps.cache-wordpress.outputs.cache-hit != 'true'
run: |
mkdir -p /tmp/wp
curl -O https://wordpress.org/wordpress-${WP_VERSION}.tar.gz
tar -xzf wordpress-${WP_VERSION}.tar.gz --strip-components=1 -C /tmp/wp
rm wordpress-${WP_VERSION}.tar.gz
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build FrankenPHP image (with cache)
id: build
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
context: .
file: .github/docker/Dockerfile
tags: frankenphp-${{ matrix.php }}
load: true
build-args: |
PHP_VERSION=${{ matrix.php }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Start FrankenPHP server
run: |
docker run -d \
--name frankenphp \
--network host \
-p 8100:8100 \
-v /tmp/wp:/var/www/html \
-v $GITHUB_WORKSPACE:/var/www/html/wp-content/plugins/simpleanalytics \
-v $GITHUB_WORKSPACE/Caddyfile:/etc/frankenphp/Caddyfile \
frankenphp-${{ matrix.php }}
- name: Install WordPress
run: |
rm -f /tmp/wp/wp-config.php
wp config create \
--dbname="$WP_DB_NAME" \
--dbuser="$WP_DB_USER" \
--dbpass="$WP_DB_PASS" \
--dbhost="$WP_DB_HOST" \
--path=/tmp/wp \
--skip-check
wp core install \
--url="${WP_SITE_URL}" \
--title="Test Site" \
--admin_user=admin \
--admin_password=admin \
--path=/tmp/wp \
--skip-email \
--allow-root
wp user create author [email protected] --role=author --user_pass=author --path=/tmp/wp
wp user create editor [email protected] --role=editor --user_pass=editor --path=/tmp/wp
wp user create subscriber [email protected] --role=subscriber --user_pass=subscriber --path=/tmp/wp
- name: Show current config values
run: wp config list --path=/tmp/wp --allow-root
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "pnpm"
- name: Install pnpm dependencies
run: pnpm install
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Run composer install
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Run PHPUnit tests
run: ./vendor/bin/phpunit
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-php${{ matrix.php }}-wp${{ matrix.wordpress }}
path: var/browser
retention-days: 30
- name: Show FrankenPHP logs
if: always()
run: |
echo "=== FrankenPHP logs ==="
docker logs frankenphp || echo "No logs found"