Skip to content

Commit 38168bc

Browse files
authored
GH Actions: use the xmllint-validate action runner and enhance checks (#2522)
* GH Actions: split XML code style check off from "Run code sniffs" check The intention is for there to be a dedicated action runner available at some point for XML code style checking, so let's move this to a separate job. Also see: PHPCSStandards/PHPCSDevTools#145 * GH Actions: use the xmllint-validate action runner Instead of doing all the installation steps for xmllint validation in the workflow, use the ✨ new dedicated `phpcsstandards/xmllint-validate` action runner instead. Ref: https://github.com/marketplace/actions/xmllint-validate * GH Actions: add some additional XML validation checks ... for dev tool files. --------- Co-authored-by: jrfnl <[email protected]>
1 parent 38c0039 commit 38168bc

File tree

1 file changed

+61
-27
lines changed

1 file changed

+61
-27
lines changed

.github/workflows/basic-qa.yml

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
name: Run code sniffs
2525
runs-on: ubuntu-latest
2626

27-
env:
28-
XMLLINT_INDENT: ' '
29-
3027
steps:
3128
- name: Checkout repository
3229
uses: actions/checkout@v4
@@ -56,21 +53,6 @@ jobs:
5653
# Bust the cache at least once a month - output format: YYYY-MM.
5754
custom-cache-suffix: $(date -u "+%Y-%m")
5855

59-
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
60-
# This should not be blocking for this job, so ignore any errors from this step.
61-
# Ref: https://github.com/dotnet/core/issues/4167
62-
- name: Update the available packages list
63-
continue-on-error: true
64-
run: sudo apt-get update
65-
66-
- name: Install xmllint
67-
run: sudo apt-get install --no-install-recommends -y libxml2-utils
68-
69-
# Show XML violations inline in the file diff.
70-
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
71-
- name: Enable showing XML issues inline
72-
uses: korelstar/xmllint-problem-matcher@v1
73-
7456
- name: Check the code style of the PHP files
7557
id: phpcs
7658
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
@@ -82,14 +64,72 @@ jobs:
8264
# Validate the Ruleset XML files.
8365
# @link http://xmlsoft.org/xmllint.html
8466
- name: Validate the WordPress rulesets
85-
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
67+
uses: phpcsstandards/xmllint-validate@v1
68+
with:
69+
pattern: "./*/ruleset.xml"
70+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
8671

8772
- name: Validate the sample ruleset
88-
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample
73+
uses: phpcsstandards/xmllint-validate@v1
74+
with:
75+
pattern: "phpcs.xml.dist.sample"
76+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
8977

9078
# Validate the Documentation XML files.
9179
- name: Validate documentation against schema
92-
run: xmllint --noout --schema vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd ./WordPress/Docs/*/*Standard.xml
80+
uses: phpcsstandards/xmllint-validate@v1
81+
with:
82+
pattern: "./WordPress/Docs/*/*Standard.xml"
83+
xsd-file: "vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd"
84+
85+
- name: Validate Project PHPCS ruleset against schema
86+
uses: phpcsstandards/xmllint-validate@v1
87+
with:
88+
pattern: ".phpcs.xml.dist"
89+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
90+
91+
- name: "Validate PHPUnit config for use with PHPUnit 8"
92+
uses: phpcsstandards/xmllint-validate@v1
93+
with:
94+
pattern: "phpunit.xml.dist"
95+
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"
96+
97+
- name: "Validate PHPUnit config for use with PHPUnit 9"
98+
uses: phpcsstandards/xmllint-validate@v1
99+
with:
100+
pattern: "phpunit.xml.dist"
101+
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"
102+
103+
# Check that the sniffs available are feature complete.
104+
# For now, just check that all sniffs have unit tests.
105+
# At a later stage the documentation check can be activated.
106+
- name: Check sniff feature completeness
107+
run: composer check-complete
108+
109+
xml-cs:
110+
name: 'XML Code style'
111+
runs-on: ubuntu-latest
112+
113+
env:
114+
XMLLINT_INDENT: ' '
115+
116+
steps:
117+
- name: Checkout code
118+
uses: actions/checkout@v4
119+
120+
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
121+
# This should not be blocking for this job, so ignore any errors from this step.
122+
# Ref: https://github.com/dotnet/core/issues/4167
123+
- name: Update the available packages list
124+
continue-on-error: true
125+
run: sudo apt-get update
126+
127+
- name: Install xmllint
128+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
129+
130+
# Show XML violations inline in the file diff.
131+
- name: Enable showing XML issues inline
132+
uses: korelstar/xmllint-problem-matcher@v1
93133

94134
- name: Check the code-style consistency of the xml files
95135
run: |
@@ -99,12 +139,6 @@ jobs:
99139
diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml")
100140
diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample")
101141
102-
# Check that the sniffs available are feature complete.
103-
# For now, just check that all sniffs have unit tests.
104-
# At a later stage the documentation check can be activated.
105-
- name: Check sniff feature completeness
106-
run: composer check-complete
107-
108142
# Makes sure the rulesets don't throw unexpected errors or warnings.
109143
# This workflow needs to be run against a high PHP version to prevent triggering the syntax error check.
110144
# It also needs to be run against all dependency versions WPCS is tested against.

0 commit comments

Comments
 (0)