-
Notifications
You must be signed in to change notification settings - Fork 33
135 lines (117 loc) · 3.85 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
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
name: PHPUnit
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: read
jobs:
unit-tests:
name: "WP ${{ matrix.wp }}, multisite: ${{ matrix.ms }}, PHP: ${{ matrix.php }}"
if: "!contains(github.event.head_commit.message, '[ci skip]')"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2]
wp: [6.4.x, latest, nightly]
ms: [no, yes]
coverage: [no]
phpunit: [9]
include:
# PHP 7.4 is not supported by PHPUnit 9
- phpunit: 7
php: 7.4
# add coverage job
- coverage: yes
php: 8.0
wp: latest
ms: no
phpunit: 9
services:
mysql:
image: mariadb:latest
ports:
- "3306:3306"
env:
MYSQL_ROOT_PASSWORD: wordpress
MARIADB_INITDB_SKIP_TZINFO: 1
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Matrix variables
id: matrix
run: |
echo "::group::Matrix variables"
echo "PHP version = ${{ matrix.php }}"
echo "WordPress = ${{ matrix.wp }}"
echo "Multisite = ${{ matrix.ms }}"
echo "Coverage = ${{ matrix.coverage }}"
echo "PHPUnit = ${{ matrix.phpunit }}"
echo "::endgroup::"
- name: Decide whether to enable coverage
id: coverage
run: |
if [ "${{ matrix.coverage }}" = "yes" ]; then
echo "coverage=pcov" >> $GITHUB_OUTPUT
echo 'ini=pcov.directory=inc, pcov.exclude="~/(vendor|tests|node_modules)/~"'
else
echo "coverage=none" >> $GITHUB_OUTPUT
echo "ini=opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M" >> $GITHUB_OUTPUT
fi
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
coverage: ${{ steps.coverage.outputs.coverage }}
ini-values: ${{ steps.coverage.outputs.ini }}
php-version: ${{ matrix.php }}
env:
fail-fast: 'true'
- name: Install PHPUnit
run: |
wget -q -O /usr/local/bin/phpunit "https://phar.phpunit.de/phpunit-${{ matrix.phpunit }}.phar"
chmod +x /usr/local/bin/phpunit
- name: Install dependencies
uses: ramsey/composer-install@v3
#- name: Install Node.js
# uses: actions/setup-node@v2
# with:
# node-version: 18.x
#- name: Install dependencies
# run: npm ci
#- name: Build assets
# run: npm run build
- name: Set up WordPress and WordPress Test Library
uses: sjinks/setup-wordpress-test-library@master
with:
version: ${{ matrix.wp }}
- name: Set up multisite mode
run: echo "WP_MULTISITE=1" >> $GITHUB_ENV
if: matrix.ms == 'yes'
- name: Update wp-test-config.php
run: |
if php -r 'exit(PHP_VERSION_ID < 80100);'; then
echo "Disabling WP_DEBUG in wp-test-config.php"
sed -i "s@define( 'WP_DEBUG', true );@// define( 'WP_DEBUG', true );@" /tmp/wordpress-tests-lib/wp-tests-config.php
fi
- name: Verify MariaDB connection
run: |
while ! mysqladmin ping -h 127.0.0.1 -P ${{ job.services.mysql.ports[3306] }} --silent; do
sleep 1
done
timeout-minutes: 1
- name: Run tests
run: |
OPTIONS=
if [ "${{ steps.coverage.outputs.coverage }}" != 'none' ]; then
OPTIONS="$OPTIONS --coverage-clover=clover.xml"
fi
phpunit --order-by=random ${OPTIONS}