-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 2.73 KB
/
php-tests.yml
File metadata and controls
97 lines (82 loc) · 2.73 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
name: Reusable PHP/WordPress Tests
on:
workflow_call:
inputs:
php_versions:
description: "List of PHP versions for the test matrix"
required: false
type: string
default: "['7.4', '8.0', '8.1', '8.2']"
phpunit9_config:
description: "Configuration file only for PHPUnit 9"
required: false
type: string
default: phpunit-9.xml
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']
steps:
- name: Check out source code
uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run PHPCS
run: vendor/bin/phpcs -ps .
# continue-on-error: true
test:
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ${{ fromJson(inputs.php_versions) }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mysqli
coverage: none
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist
- name: Prepare WordPress test suite
if: ${{ hashFiles('bin/install-wp-tests.sh') != '' }}
run: |
mysql --user=root --password=root --host=127.0.0.1 --execute="DROP DATABASE IF EXISTS wordpress_test; CREATE DATABASE wordpress_test;"
rm -rf /tmp/wordpress-tests-lib /tmp/wordpress
yes y | bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest
- name: Detect PHPUnit version and run tests
run: |
PHPUNIT_VERSION=$(vendor/bin/phpunit --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | cut -d. -f1)
PHPUNIT_CONFIG="${{ inputs.phpunit9_config }}"
if [ "$PHPUNIT_VERSION" = "9" ] && [ -f phpunit-9.xml ]; then
PHPUNIT_CONFIG="-c phpunit-9.xml"
else
PHPUNIT_CONFIG=""
fi
vendor/bin/phpunit $PHPUNIT_CONFIG
WP_MULTISITE=1 vendor/bin/phpunit $PHPUNIT_CONFIG