Skip to content

Commit f2cd323

Browse files
committed
GH Actions/linting: lint XML files
The `phpcsstandards/xmllint-validate` action runner can validate XML files for both well-formedness, as well as validating the XML against an XSD schema. This commit adds a new lint job to the `linting` workflow to take advantage of that to validate: * Dev tool config files against their applicable XSD files. * PHPCS rulesets used in the tests against the PHPCS XSD ruleset. Ref: https://github.com/marketplace/actions/xmllint-validate
1 parent 7e6a7a3 commit f2cd323

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/workflows/linting.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020
with:
2121
persist-credentials: false
22-
- name: Validate composer.json and composer.lock
22+
- name: Validate composer.json
2323
uses: "docker://composer"
2424
with:
2525
args: "composer validate --no-check-lock"
@@ -61,3 +61,33 @@ jobs:
6161
persist-credentials: false
6262
- name: Check markdown
6363
uses: pipeline-components/remark-lint@master
64+
65+
lint-xml:
66+
name: Check XML files
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
72+
with:
73+
persist-credentials: false
74+
75+
# Validate the XML ruleset files used in the tests.
76+
- name: Validate rulesets against schema
77+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
78+
with:
79+
pattern: "./tests/*/ruleset.xml"
80+
xsd-file: "https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/refs/heads/4.x/phpcs.xsd"
81+
82+
# Validate dev tool related XML files.
83+
- name: Validate Project PHPCS ruleset against schema
84+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
85+
with:
86+
pattern: "phpcs.xml.dist"
87+
xsd-file: "https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/refs/heads/4.x/phpcs.xsd"
88+
89+
- name: "Validate PHPUnit config against schema"
90+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
91+
with:
92+
pattern: "phpunit.xml.dist"
93+
xsd-file: "https://raw.githubusercontent.com/sebastianbergmann/phpunit/refs/heads/main/schema/9.5.xsd"

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ The non-PHP specific tools used by this build are:
109109
- [jsonlint][] to verify that all JSON files use a consistent code style.
110110
- [remark-lint][] to verify that all markdown files use a consistent code style.
111111
- [yamllint][] to verify that all Yaml files use a consistent code style.
112+
- [xmllint][] to verify that XML files are well-formed and validated against the applicable XSD file.
112113

113114
These tools are also run as [GitHub actions][].
114115
All the checks can be run locally using [`act`][].
@@ -121,6 +122,7 @@ is written in. For details please consult the relevant tool's documentation.
121122
[jsonlint]: https://www.npmjs.com/package/jsonlint
122123
[remark-lint]: https://www.npmjs.com/package/remark-lint
123124
[yamllint]: https://yamllint.readthedocs.io/en/stable/
125+
[xmllint]: https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html
124126
[`act`]: https://github.com/nektos/act
125127

126128
## Release process

0 commit comments

Comments
 (0)