-
Notifications
You must be signed in to change notification settings - Fork 9
226 lines (193 loc) · 6.93 KB
/
CI.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
name: "CI"
on:
push:
branches: "*"
pull_request:
env:
php-version: 8.2
cache-version: 1
jobs:
platform-check:
name: "PHP 5.6 compatibility"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@2.31.1
with:
php-version: 5.6
coverage: none
- name: "Check dependency compatibility"
run: |
composer check-platform-reqs --no-dev
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ env.php-version }}
coverage: none
- name: "Cache Composer dependencies"
uses: actions/cache@v4
with:
path: "~/.composer/cache"
key: composer-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('composer.json') }}
composer-dependencies-${{ runner.os }}-${{ env.cache-version }}-
- name: "Install Composer dependencies"
run: |
composer install -n --prefer-dist
- name: "Cache NPM dependencies"
uses: actions/cache@v4
with:
path: "~/.npm"
key: npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-
- name: "Install NPM dependencies"
run: |
npm ci
- name: "Build"
run: |
npm run build
- name: "Upload artifact"
uses: actions/upload-artifact@v4
with:
name: "build-artifact"
path: dist
lint:
name: "Lint"
runs-on: ubuntu-latest
needs: build
env:
php-extensions: ast
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP extension caching"
id: extcache
uses: shivammathur/cache-extensions@1.11.1
with:
php-version: ${{ env.php-version }}
extensions: ${{ env.php-extensions }}
key: php-extensions-${{ runner.os }}-${{ env.cache-version }}
- name: "Cache extensions"
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: "Setup PHP"
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ env.php-version }}
extensions: ${{ env.php-extensions }}
coverage: none
- name: "Cache Composer dependencies"
uses: actions/cache@v4
with:
path: "~/.composer/cache"
key: composer-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('composer.json') }}
composer-dependencies-${{ runner.os }}-${{ env.cache-version }}-
- name: "Install Composer dependencies"
run: |
composer install -n --prefer-dist
- name: "Cache NPM dependencies"
uses: actions/cache@v4
with:
path: "~/.npm"
key: npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-
- name: "Install NPM dependencies"
run: |
npm ci
- name: "Download build artifact"
uses: actions/download-artifact@v4
with:
name: "build-artifact"
path: dist
- name: "Lint"
run: |
npm run lint
unit:
name: "Test"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
versions: [{php: "5.6", wordpress: "4.9"}, {php: "5.6", wordpress: "5.9"}, {php: "5.6", wordpress: "6.2"}, {php: "7.4", wordpress: "latest"}, {php: "8.2", wordpress: "latest"}]
services:
mysql:
image: mysql:5
ports:
- 3306:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Install SVN"
uses: awalsh128/cache-apt-pkgs-action@v1.4.2
with:
packages: subversion
version: ${{ env.cache-version }}
- name: "Setup PHP"
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ matrix.versions.php }}
coverage: pcov
- name: "Cache Composer dependencies"
uses: actions/cache@v4
with:
path: "~/.composer/cache"
key: composer-dependencies-test-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-dependencies-test-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('composer.json') }}
composer-dependencies-test-${{ runner.os }}-${{ env.cache-version }}-
- name: "Move phpunit to non-dev Composer dependencies"
run: |
composer -n require --no-update yoast/phpunit-polyfills phpunit/phpunit:"^5.7 || ^6.5 || ^7.5 || ^8.5 || ^9.6"
- name: "Remove all non-dev Composer dependencies"
run: |
composer remove --dev --no-update $(composer show -s | sed -n '/requires (dev)$/,/^$/p' | grep -v 'requires (dev)' | cut -d ' ' -f1 | tr '\n' ' ')
- name: "Install Composer dependencies"
run: |
composer update -n --prefer-dist
- name: "Cache NPM dependencies"
uses: actions/cache@v4
with:
path: "~/.npm"
key: npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-
- name: "Install NPM dependencies"
run: |
npm ci
- name: "Download build artifact"
uses: actions/download-artifact@v4
with:
name: "build-artifact"
path: dist
- name: "Prepare WordPress test environment"
run: |
./bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 ${{ matrix.versions.wordpress }}
- name: "Run tests"
run: |
npm run test
- name: "Upload coverage results"
uses: codecov/codecov-action@v5.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true