-
Notifications
You must be signed in to change notification settings - Fork 4
133 lines (115 loc) · 4.55 KB
/
tests.yml
File metadata and controls
133 lines (115 loc) · 4.55 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
name: E2E Tests
on:
push:
pull_request:
jobs:
e2e:
name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
wordpress: [ '5.9', '6.0', '6.3', '6.5.3' ]
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: Checkout plugin
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mysqli, zip, gd
coverage: none
tools: wp-cli
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y unzip curl jq
- name: Cache WordPress archive
id: cache-wordpress
uses: actions/cache@v3
with:
path: wordpress
key: wp-${{ matrix.wordpress }}-php-${{ matrix.php }}
- name: Download WordPress
if: steps.cache-wordpress.outputs.cache-hit != 'true'
run: |
curl -O https://wordpress.org/wordpress-${WP_VERSION}.tar.gz
tar -xzf wordpress-${WP_VERSION}.tar.gz
rm wordpress-${WP_VERSION}.tar.gz
- name: Configure WordPress
run: |
cp wordpress/wp-config-sample.php wordpress/wp-config.php
sed -i "s/database_name_here/${WP_DB_NAME}/" wordpress/wp-config.php
sed -i "s/username_here/${WP_DB_USER}/" wordpress/wp-config.php
sed -i "s/password_here/${WP_DB_PASS}/" wordpress/wp-config.php
sed -i "s/localhost/${WP_DB_HOST}/" wordpress/wp-config.php
# Add WP_DEBUG settings
sed -i "/define( 'DB_COLLATE', '' );/a define( 'WP_DEBUG', true );\ndefine( 'WP_DEBUG_LOG', true );" wordpress/wp-config.php
- name: Install WordPress
run: |
wp core install \
--url="${WP_SITE_URL}" \
--title="Test Site" \
--admin_user=admin \
--admin_password=admin \
--admin_email=test@example.com \
--path=wordpress \
--skip-email \
--allow-root
- name: Install plugin
run: |
PLUGIN_SLUG=$(basename "$GITHUB_WORKSPACE")
ln -s "$GITHUB_WORKSPACE" "wordpress/wp-content/plugins/simpleanalytics"
wp plugin activate simpleanalytics --path=wordpress --allow-root
- name: Start PHP server
run: |
php -S localhost:8100 -t wordpress > /dev/null 2>&1 &
sleep 5
- 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 Playwright and dependencies
run: |
pnpm install
pnpm run tests:install
- name: Run Playwright tests
run: pnpm run tests
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-php${{ matrix.php }}-wp${{ matrix.wordpress }}
path: |
playwright-report/
test-results/
retention-days: 30