-
Notifications
You must be signed in to change notification settings - Fork 3
270 lines (222 loc) · 8.61 KB
/
ci.yml
File metadata and controls
270 lines (222 loc) · 8.61 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
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: CI checks
on:
push:
branches:
- "develop"
- "main"
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
composer_validate:
name: "Validate the composer.json file"
runs-on: "ubuntu-latest"
steps:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
- name: "Checkout code"
uses: actions/checkout@v4
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: "Composer validate"
run: composer validate --no-check-all --strict
ruleset_validate:
name: "Validate the WordPress rulesets"
runs-on: "ubuntu-latest"
env:
XMLLINT_INDENT: ' '
steps:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
- name: "Install xmllint"
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libxml2-utils
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Install Composer dependencies"
uses: ramsey/composer-install@v2
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
# Show XML violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- uses: korelstar/xmllint-problem-matcher@v1
# Validate the Ruleset XML files.
# @link http://xmlsoft.org/xmllint.html
- name: "Validate the WordPress rulesets"
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
- name: "Validate the sample ruleset"
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample
# Validate the Documentation XML files.
- name: "Validate documentation against schema"
run: xmllint --noout --schema vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd ./Eightshift/Docs/*/*Standard.xml
- name: "Check the code-style consistency of the xml files"
run: |
diff -B --tabsize=4 ./Eightshift/ruleset.xml <(xmllint --format "./Eightshift/ruleset.xml")
diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample")
feature_completeness:
name: "Check sniff feature completeness"
needs:
- "composer_validate"
- "ruleset_validate"
runs-on: "ubuntu-latest"
steps:
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Install Composer dependencies"
uses: ramsey/composer-install@v2
with:
custom-cache-suffix: $(date -u "+%Y-%m")
- name: "Check sniff feature completeness"
run: composer check:complete
lint:
name: "Lint: PHP ${{ matrix.php }}"
needs:
- "composer_validate"
- "ruleset_validate"
runs-on: "ubuntu-latest"
strategy:
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
steps:
- name: "Set up PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: cs2pr
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Composer: adjust dependencies"
# Remove PHPUnit requirement to save some bandwidth.
run: composer remove --dev --no-update phpunit/phpunit
- name: "Install Composer dependencies"
uses: ramsey/composer-install@v2
with:
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Lint against parse errors
run: composer lint:ci | cs2pr
phpstan:
name: "PHPStan checks"
needs:
- "composer_validate"
- "ruleset_validate"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
tools: phpstan
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"
with:
custom-cache-suffix: $(date -u "+%Y-%m")
- name: "Run PHPStan"
run: phpstan analyse
tests:
name: "PHP ${{ matrix.php }} with PHPCS ${{ matrix.phpcs_branch }}/WordPressCS ${{ matrix.wpcs_branch }}"
needs:
- "composer_validate"
- "ruleset_validate"
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allowed_failure }}
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
phpcs_branch: [ 'lowest', 'dev-master' ]
wpcs_branch: [ '3.0.0', 'dev-develop' ]
allowed_failure: [ false ]
exclude:
# Only run low WordPressCS in combination with low PHPCS and high WordPressCS with high PHPCS.
- phpcs_branch: '3.7.2'
wpcs_branch: '3.0.0'
- phpcs_branch: 'dev-master'
wpcs_branch: 'dev-develop'
# Allow failure on non-released version of PHP.
include:
- php: '8.3'
phpcs_branch: 'dev-master'
wpcs_branch: 'dev-develop'
allowed_failure: true
steps:
# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
- name: "Setup ini config"
id: set_ini
run: |
if [ "${{ matrix.phpcs_branch }}" != "dev-master" ]; then
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
else
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
fi
# Setup PHP versions, run checks
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set the minimum stability requirement for develop branch of WordPressCS"
if: ${{ matrix.wpcs_branch == 'dev-develop' }}
run: composer config minimum-stability dev
- name: "Install Composer dependencies (PHP < 8.0 )"
if: ${{ matrix.php < 8.0 }}
uses: ramsey/composer-install@v2
with:
custom-cache-suffix: $(date -u "+%Y-%m")
- name: "Install Composer dependencies (PHP >= 8.0)"
if: ${{ matrix.php >= 8.0 }}
uses: ramsey/composer-install@v2
with:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")
- name: "Set the required PHPCS and WordPressCS versions"
if: ${{ matrix.phpcs_branch != 'lowest' }}
env:
PHPCS_BRANCH: ${{ matrix.phpcs_branch }}
WPCS_BRANCH: ${{ matrix.wpcs_branch }}
run: composer require squizlabs/php_codesniffer:${PHPCS_BRANCH} wp-coding-standards/wpcs:${WPCS_BRANCH} --no-update --no-scripts --no-interaction
- name: "Set PHPCS version (lowest)"
if: ${{ matrix.phpcs_version == 'lowest' }}
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction
- name: "Test the Eightshift ruleset"
run: composer tests:checkcs
# Test for fixer conflicts by running the auto-fixers of the complete WordPressCS over the test case files.
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
# If only fixable errors are found, the exit code will be 1, which can be interpreted as success.
- name: "Test for fixer conflicts (fixes expected)"
if: ${{ matrix.phpcs_branch == 'dev-master' }}
continue-on-error: true
run: |
$(pwd)/vendor/bin/phpcbf -pq ./Eightshift/Tests/ --standard=Eightshift --extensions=inc --exclude=Generic.PHP.Syntax --report=summary
if [ $? -eq 1 ]; then exit 0; fi
- name: "Run the unit tests - PHP 7.4 - 8.0"
if: ${{ matrix.php < '8.1' }}
run: composer tests:run
- name: "Run the unit tests - PHP >= 8.1"
if: ${{ matrix.php >= '8.1' }}
run: composer tests:run -- --no-configuration --bootstrap=./Tests/bootstrap.php --dont-report-useless-tests