-
-
Notifications
You must be signed in to change notification settings - Fork 506
142 lines (126 loc) · 4.25 KB
/
php-unit-tests.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
136
137
138
139
140
141
142
name: PHP unit tests
on:
push:
branches:
- master
- 2.x
paths:
- '**workflows/php-unit-tests.yml'
- '**.php'
- '**composer.json'
- '**phpunit.xml'
pull_request:
branches:
- master
- 2.x
paths:
- '**workflows/php-unit-tests.yml'
- '**.php'
- '**composer.json'
- '**phpunit.xml'
types:
- opened
- synchronize
- ready_for_review
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
php-unit-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:latest
env:
MYSQL_USER: root
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD: ''
MYSQL_DATABASE: wordpress_test
ports:
- 3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2']
wp: ['latest', '6.2']
multisite: ['0', '1']
dependency-version: ['highest', 'lowest']
webp: [false]
coverage: [false]
extensions: ['gd']
experimental: [false]
include:
# PHP 8.2 / experimental
- php: '8.2'
wp: 'trunk'
dependency-version: 'highest'
multisite: '0'
experimental: true
# PHP 8.3 / experimental
- php: '8.3'
wp: 'trunk'
dependency-version: 'highest'
multisite: '0'
experimental: true
# PHP with Imagick
- php: '8.1'
wp: 'latest'
dependency-version: 'highest'
multisite: '0'
extensions: 'imagick'
experimental: false
# Coverage
- php: '8.1'
wp: 'latest'
dependency-version: 'highest'
multisite: '0'
coverage: true
experimental: false
name: PHP ${{ matrix.php }} ${{ matrix.extensions == 'imagick' && ' (Imagick)' || '' }}${{ matrix.coverage && ' (with coverage)' || '' }} ${{ matrix.webp && ' (webp)' || '' }} | WP ${{ matrix.wp }}${{ matrix.multisite == 1 && ' (MS)' || '' }} | ${{ matrix.dependency-version }}
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage && 'pcov' || 'none' }}
tools: composer:v2
extensions: curl, date, dom, iconv, json, libxml, mysql, ${{ matrix.extensions }}
ini-values: pcov.directory=src
- name: Shutdown default MySQL service
run: sudo service mysql stop
- name: Verify MariaDB connection
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"${{ job.services.mysql.ports[3306] }}" --silent; do
sleep 1
done
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependency-version }}
- name: Install tests
run: bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true
- name: Run tests
if: ${{ !matrix.webp }}
run: composer run test
env:
WP_MULTISITE: ${{ matrix.multisite }}
- name: Run tests with coverage
if: matrix.coverage == true
run: |
composer run test:integration:codecov
- name: Upload coverage results to Coveralls
if: matrix.coverage == true
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=${GITHUB_WORKSPACE}/build/logs/clover.xml -v
- name: Run webp tests
if: matrix.webp
run: vendor/phpunit/phpunit/phpunit -c phpunit.xml --verbose --filter 'TestTimberImageToWEBP'