-
Notifications
You must be signed in to change notification settings - Fork 1
283 lines (236 loc) · 8.89 KB
/
lint-and-test.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: Lint and Test
on:
push:
branches:
- main
pull_request:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
lint-js:
name: JS Lints
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
- name: package.json Lint
run: npm run lint:pkg-json
- name: Type checking
run: npm run build:package-types
- name: Lint JS
run: npm run lint:js
- name: Lint CSS
run: npm run lint:css
- name: Lint Markdown
run: npm run lint:md:docs
bundle-size:
name: Bundle size check
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
- name: Bundle size check
uses: preactjs/compressed-size-action@v2
with:
pattern: 'build/*.{js,css,wasm}'
strip-hash: "\\.(\\w{8})\\.wasm$"
build-script: 'build'
minimum-change-threshold: 100
lint-php:
name: PHP Lints
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: latest
coverage: none
tools: composer, cs2pr
- name: Install PHP dependencies
uses: ramsey/composer-install@v3
with:
composer-options: '--prefer-dist --no-scripts'
- name: Validate composer.json
run: composer validate --no-check-all --strict
- name: Lint PHP
run: composer lint
- name: PHPStan
run: composer phpstan
unit-js:
name: JS Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:unit -- --collectCoverage
- name: Upload code coverage report
uses: codecov/[email protected]
with:
file: artifacts/logs/lcov.info
flags: js
token: ${{ secrets.CODECOV_TOKEN }}
unit-php:
name: 'PHP ${{ matrix.php }} - WP ${{ matrix.wp }}'
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:lts
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
MARIADB_DATABASE: wordpress_test
MARIADB_MYSQL_LOCALHOST_USER: 1
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
ports:
- 3306
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php: ['8.2', '8.1', '8.0', '7.4']
wp: ['latest']
coverage: [false]
experimental: [false]
include:
- php: '8.3'
wp: 'latest'
coverage: true
experimental: false
- php: '8.3'
wp: 'trunk'
experimental: true
- php: '8.4'
wp: 'trunk'
experimental: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mysql
coverage: xdebug
tools: composer, cs2pr
- 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: Set up tests
run: bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true
- name: Install PHP dependencies
uses: ramsey/composer-install@v3
with:
composer-options: '--prefer-dist --no-progress --no-interaction --no-scripts'
# Installs a different PHPUnit version depending on the WP/PHP version combo we're testing against.
#
# | WP / PHP | PHPUnit |
# |-----------|---------|
# | * / 5.6 | 5 |
# | * / 7.4 | 9 |
# | * / 8 | 9 |
#
# See https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/
- name: Update PHPUnit
run: |
if [[ $PHP_VERSION == "8.0" || $PHP_VERSION == "8.1" || $PHP_VERSION == "8.2" ]]; then
echo "Installing latest version of PHPUnit"
composer update --ignore-platform-reqs --no-interaction --no-scripts yoast/phpunit-polyfills --with-dependencies --with "phpunit/phpunit:^9.6"
fi
env:
WP_VERSION: ${{ matrix.wp }}
PHP_VERSION: ${{ matrix.php }}
- name: Run tests
run: |
composer test
composer test:multisite
if: ${{ ! matrix.coverage }}
- name: Run tests with coverage
run: |
composer test -- --coverage-clover coverage.xml
composer test:multisite -- --coverage-clover coverage-multisite.xml
if: ${{ matrix.coverage }}
- name: Upload code coverage report
uses: codecov/[email protected]
with:
file: artifacts/coverage.xml
flags: default
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ matrix.coverage }}
- name: Upload code coverage report
uses: codecov/[email protected]
with:
file: coverage-multisite.xml
flags: multisite
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ matrix.coverage }}
plugin-check:
name: Plugin Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: latest
coverage: none
tools: wp-cli
- name: Install latest version of dist-archive-command
run: wp package install wp-cli/dist-archive-command:dev-main
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
- name: Build plugin
run: |
npm run build
wp dist-archive . ./media-experiments.zip
mkdir tmp-build
unzip media-experiments.zip -d tmp-build
- name: Run plugin check
uses: WordPress/plugin-check-action@v1
with:
build-dir: './tmp-build/media-experiments'
wp-version: 'trunk'
exclude-checks: |
late_escaping
plugin_review_phpcs
trademarks
plugin_readme
plugin_updater