This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
235 lines (207 loc) · 7.17 KB
/
phpunit-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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: PHPUnit Tests
on:
push:
branches:
- develop
workflow_dispatch:
pull_request:
# Once weekly On Sundays at 00:00 UTC.
schedule:
- cron: '0 0 * * 0'
jobs:
# Runs the PHPUnit tests for ClassicPress.
#
# Performs the following steps:
# - Cancel workflow if PR updated.
# - Checkout ClassicPress.
# - Set environment variables.
# - Read .nvmrc.
# - Installs NodeJS.
# - Sets up caching for NPM.
# - Setup, wait for and initialise MySQL.
# - Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Configure PHP.
# - Set up locale.
# - Install PHPUnit and Composer dependencies.
# - Make Composer packages available globally.
# - Log debug information.
# - Create config file.
# - Set up object cache if needed for memcached tests.
# - Set up a Memcached server if needed.
# - Clone PHP.net if needed for unit tests.
# - Run PHPUnit Tests.
test-php:
name: "PHP ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }}${{ matrix.experimental && ' - Experimental' || '' }}"
runs-on: ubuntu-latest
if: ${{ github.repository == 'ClassicPress/ClassicPress-v2' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.0', '7.4' ]
mysql: [ '5.7' ]
memcached: [ false ]
experimental: [ false ]
include:
- php: '7.4'
mysql: '5.7'
memcached: true
experimental: false
- php: '8.2'
mysql: '5.7'
memcached: false
experimental: true
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Read .nvmrc
run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvmrc
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: '${{ steps.nvmrc.outputs.NVMRC }}'
- name: Use cached Node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
mysql root password: "password"
mysql version: "${{ matrix.mysql }}"
- name: Wait for MySQL
run: |
while ! mysqladmin ping --host=127.0.0.1 --port 3306 -u root -ppassword --silent; do
sleep 1
done
- name: Initialise MySQL
run: |
mysql --host 127.0.0.1 --port 3306 -u root -ppassword -e "SELECT @@VERSION"
mysql --host 127.0.0.1 --port 3306 -u root -ppassword < tools/local-env/mysql-init.sql
mysql --host 127.0.0.1 --port 3306 -u root -ppassword -e "SHOW DATABASES"
- name: Install dependencies
run: npx install-changed --install-command="npm ci"
- name: Set up PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php }}"
ini-values: >-
mysql.default_host=127.0.0.1,
mysql.default_port=3306,
mysql.default_socket=/var/run/mysqld/mysqld.sock
extensions: >-
bcmath,
curl,
dom,
exif,
gd,
iconv,
imagick,
intl,
libxml,
mbstring,
memcached,
mysql,
mysqli,
pcntl,
pdo,
pdo_mysql,
pdo_sqlite,
soap,
sqlite,
zip
coverage: none
- name: Set up locale
run: |
sudo locale-gen es_ES.UTF-8 fr_FR.UTF-8 ru_RU.UTF-8
sudo update-locale LC_ALL="es_ES.UTF-8 fr_FR.UTF-8 ru_RU.UTF-8"
- name: Install PHPUnit and Composer dependencies
run: |
composer require phpunit/phpunit "9.*" -W --no-progress --no-ansi --no-interaction
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Show debug information
run: |
set +e
set -x
npm --version
node --version
curl --version
git --version
svn --version
php --version
phpunit --version
composer --version
grunt --version
lsb_release -a
localectl list-locales
- name: Create ClassicPress config file for tests
run: |
cp wp-tests-config-sample.php wp-tests-config.php
sed -i 's/youremptytestdbnamehere/classicpress_develop_tests/g' wp-tests-config.php
sed -i 's/yourusernamehere/root/g' wp-tests-config.php
sed -i 's/yourpasswordhere/password/g' wp-tests-config.php
sed -i 's/localhost/127.0.0.1/g' wp-tests-config.php
- name: Set up object cache
if: ${{ matrix.memcached }}
run: |
cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
- name: Set up a Memcached server
if: ${{ matrix.memcached }}
uses: niden/actions-memcached@v7
- name: Clone PHP.net and create local supported versions for PHPUnit tests
if: ${{ matrix.memcached }}
run: |
mkdir php.net
git clone https://github.com/php/web-php php.net
php -d error_reporting=E_ERROR -f php.net/supported-versions.php > supported-versions.html
- name: Run PHPUnit default
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:default
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit ajax
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:ajax
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit multisite
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:multisite
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit ms-files
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:ms-files
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit external-http
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:external-http
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit restapi-jsclient
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:restapi-jsclient
continue-on-error: ${{ matrix.experimental }}
- name: Run PHPUnit wp-api-client-fixtures
env:
WP_DB_HOST: 127.0.0.1:3306
run: grunt phpunit:wp-api-client-fixtures
continue-on-error: ${{ matrix.experimental }}