Skip to content

Commit ac9c5fc

Browse files
authored
Merge pull request #830 from Automattic/feature/ghactions-change-xmllint-validation
GH Actions: use the xmllint-validate action runner + add some extra checks
2 parents 7ed6c5d + 5e62512 commit ac9c5fc

File tree

4 files changed

+43
-38
lines changed

4 files changed

+43
-38
lines changed

.github/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This package contains Composer scripts to quickly run the developer checks which
6161

6262
After `composer install`, you can do:
6363

64-
- `composer lint`: Lint PHP and XML files in against parse errors.
64+
- `composer lint`: Lint PHP files against parse errors.
6565
- `composer cs`: Check the code style and code quality of the codebase via PHPCS.
6666
- `composer test`: Run the unit tests for the VIPCS sniffs.
6767
- `composer test-coverage`: Run the unit tests for the VIPCS sniffs with coverage enabled.

.github/workflows/basics.yml

+40-17
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
name: 'Basic CS and QA checks'
2323
runs-on: ubuntu-latest
2424

25+
env:
26+
XMLLINT_INDENT: ' ' # This is a tab character.
27+
2528
steps:
2629
- name: Checkout code
2730
uses: actions/checkout@v4
@@ -33,21 +36,6 @@ jobs:
3336
coverage: none
3437
tools: cs2pr
3538

36-
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
37-
# This should not be blocking for this job, so ignore any errors from this step.
38-
# Ref: https://github.com/dotnet/core/issues/4167
39-
- name: Update the available packages list
40-
continue-on-error: true
41-
run: sudo apt-get update
42-
43-
- name: Install xmllint
44-
run: sudo apt-get install --no-install-recommends -y libxml2-utils
45-
46-
# Show XML violations inline in the file diff.
47-
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
48-
- name: Enable showing XML issues inline
49-
uses: korelstar/xmllint-problem-matcher@v1
50-
5139
# Validate the composer.json file.
5240
# @link https://getcomposer.org/doc/03-cli.md#validate
5341
- name: Validate Composer installation
@@ -65,8 +53,43 @@ jobs:
6553
# Bust the cache at least once a month - output format: YYYY-MM.
6654
custom-cache-suffix: $(date -u "+%Y-%m")
6755

68-
- name: 'Validate XML against schema and check code style'
69-
run: ./bin/xml-lint
56+
# Validate the XML file.
57+
- name: Validate rulesets against schema
58+
uses: phpcsstandards/xmllint-validate@v1
59+
with:
60+
pattern: "./*/ruleset.xml"
61+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
62+
63+
# Check the code-style consistency of the XML file.
64+
# Note: this needs xmllint, but that will be installed via the phpcsstandards/xmllint-validate action runner in the previous step.
65+
- name: Check XML code style
66+
run: |
67+
diff -B --tabsize=4 ./WordPressVIPMinimum/ruleset.xml <(xmllint --format "./WordPressVIPMinimum/ruleset.xml")
68+
diff -B --tabsize=4 ./WordPress-VIP-Go/ruleset.xml <(xmllint --format "./WordPress-VIP-Go/ruleset.xml")
69+
70+
# Validate dev tool related XML files.
71+
- name: Validate Project PHPCS ruleset against schema
72+
uses: phpcsstandards/xmllint-validate@v1
73+
with:
74+
pattern: ".phpcs.xml.dist"
75+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
76+
77+
# Notes:
78+
# - PHPUnit 9.5 (which will be installed in this job) doesn't ship XSD files further back than 8.5.
79+
# - PHPUnit 9.3 introduced some new configuration options and deprecated the old versions of those.
80+
# For cross-version compatibility with older PHPUnit versions, those new config options cannot be used yet,
81+
# which is why the PHPUnit 9 validation is done against the PHPUnit 9.2 schema.
82+
- name: "Validate PHPUnit config for use with PHPUnit 8"
83+
uses: phpcsstandards/xmllint-validate@v1
84+
with:
85+
pattern: "phpunit.xml.dist"
86+
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"
87+
88+
- name: "Validate PHPUnit config for use with PHPUnit 9"
89+
uses: phpcsstandards/xmllint-validate@v1
90+
with:
91+
pattern: "phpunit.xml.dist"
92+
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"
7093

7194
# Check the code-style consistency of the PHP files.
7295
- name: Check PHP code style

bin/xml-lint

-17
This file was deleted.

composer.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
"scripts": {
4040
"test-ruleset": "bin/ruleset-tests",
4141
"lint": [
42-
"bin/php-lint",
43-
"bin/xml-lint"
42+
"bin/php-lint"
4443
],
4544
"cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
4645
"test": "bin/unit-tests",
@@ -57,7 +56,7 @@
5756
]
5857
},
5958
"scripts-descriptions": {
60-
"lint": "VIPCS: Lint PHP and XML files in against parse errors.",
59+
"lint": "VIPCS: Lint PHP files against parse errors.",
6160
"cs": "VIPCS: Check the code style and code quality of the codebase via PHPCS.",
6261
"test": "VIPCS: Run the unit tests for the VIPCS sniffs.",
6362
"test-coverage": "VIPCS: Run the unit tests for the VIPCS sniffs with coverage enabled.",

0 commit comments

Comments
 (0)