-
Notifications
You must be signed in to change notification settings - Fork 0
236 lines (192 loc) · 7.08 KB
/
ci.yml
File metadata and controls
236 lines (192 loc) · 7.08 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
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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:
# Default to read-only for all jobs; individual jobs override only what they need.
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docs-quality:
name: Docs Quality
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint documentation markdown
run: npm run lint:docs:markdown
- name: Validate documentation links
run: npm run lint:docs:links
lint-js:
name: Lint JS & CSS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint JavaScript
run: npm run lint:js
- name: Lint CSS
run: npm run lint:css
- name: Audit npm dependencies
# All npm packages are devDependencies (build tooling only — nothing ships
# to WordPress). Audit only production deps to avoid false positives from
# build tools like @wordpress/scripts that can't be patched without a
# breaking downgrade.
run: npm audit --audit-level=high --omit=dev
test-js:
name: JavaScript Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run JavaScript unit tests with coverage
run: npm run test:js:coverage
- name: Upload JS coverage to Codecov
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
flags: jest
fail_ci_if_error: false
lint-php:
name: Lint PHP
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.2'
tools: composer
coverage: none
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHP_CodeSniffer
run: composer lint
- name: Audit Composer dependencies
run: composer audit
phpstan:
name: PHPStan Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: '24'
cache: 'npm'
- name: Set up PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.2'
tools: composer
coverage: none
- name: Install JS dependencies and build assets
# PHPStan statically follows the include() in class-telex-admin.php and
# requires the build/*.asset.php files to exist at analysis time.
run: npm ci && npm run build
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHPStan
run: php -d memory_limit=2G vendor/bin/phpstan analyse --no-progress --memory-limit=2G
test-php:
name: PHP Tests (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: ${{ matrix.php }}
extensions: mysqli, openssl
tools: composer
coverage: xdebug
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress
- name: Install WordPress test suite
run: |
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest
- name: Run PHPUnit with coverage
run: composer test -- --coverage-clover coverage.xml
- name: Upload coverage to Codecov
if: matrix.php == '8.2'
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
files: coverage.xml
flags: phpunit
fail_ci_if_error: false
plugin-check:
name: WordPress Plugin Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.2'
tools: composer
coverage: none
- name: Install Composer dependencies (production only)
run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader
- name: Build clean distribution directory
# Mirrors what bin/build-zip.sh does: copy only production files so
# dev tooling (bin/, tests/, .github/, .eslintrc.js, etc.) is absent
# when plugin-check runs — those files must not be in a WP.org zip.
run: |
mkdir -p /tmp/plugin-dist/dispatch
rsync -r --exclude-from=.distignore . /tmp/plugin-dist/dispatch/
- name: WordPress Plugin Check
uses: wordpress/plugin-check-action@6f5a57e173c065a394b78688f75df543e4011902 # v1
with:
build-dir: '/tmp/plugin-dist/dispatch'
# plugin_readme — readme.txt is for wordpress.org listing, not runtime.
# plugin_review_phpcs — covered by the dedicated lint-php job.
# plugin_updater — false positive: the update hooks inject updates for
# Telex-managed blocks/themes into WP's native update UI, not for
# self-updating this plugin outside wordpress.org.
exclude-checks: 'plugin_readme,plugin_review_phpcs,plugin_updater'