-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (52 loc) · 1.84 KB
/
phpunit.yml
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
name: PHPUnit Tests
on:
pull_request:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 3306:3306 # Expose MySQL port
options: --health-cmd="mysqladmin ping -h 127.0.0.1" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Setup WordPress Test Suite
run: |
# Wait for MySQL to be ready
until mysqladmin ping -h127.0.0.1 -uroot -prootpassword; do
echo "Waiting for MySQL to be ready..."
sleep 5
done
mkdir -p /home/runner/wordpress-tests
cd /home/runner/wordpress-tests
git clone --depth=1 https://github.com/WordPress/wordpress-develop.git
cd wordpress-develop
composer install
cp wp-tests-config-sample.php wp-tests-config.php
# Update wp-tests-config.php with your database details
sed -i "s/database_name_here/wordpress_test/g" wp-tests-config.php
sed -i "s/username_here/root/g" wp-tests-config.php
sed -i "s/password_here/rootpassword/g" wp-tests-config.php
# Create the test database
mysql -h127.0.0.1 -uroot -prootpassword -e "CREATE DATABASE wordpress_test;"
env:
WP_TESTS_PATH: /home/runner/wordpress-tests/wordpress-develop/tests/phpunit
- uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, mysqli, zip
tools: composer:v2
- name: Install dependencies
run: composer install --
- name: Run PHPUnit tests
env:
WP_TESTS_PATH: /home/runner/wordpress-tests/wordpress-develop/tests/phpunit
run: vendor/bin/phpunit --bootstrap tests/bootstrap.php