Skip to content

Commit cf28c84

Browse files
authoredMar 3, 2025··
Merge pull request #328 from PHPCSStandards/feature/ghactions-change-xmllint-validation
GH Actions: use the xmllint-validate action runner and enhance checks
2 parents 31ef149 + ce13c97 commit cf28c84

File tree

1 file changed

+57
-26
lines changed

1 file changed

+57
-26
lines changed
 

‎.github/workflows/basics.yml

+57-26
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
runs-on: ubuntu-latest
2121

2222
env:
23-
XMLLINT_INDENT: ' '
2423
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
2524
COMPOSER_ROOT_VERSION: '1.99.99'
2625

@@ -53,6 +52,63 @@ jobs:
5352
# Bust the cache at least once a month - output format: YYYY-MM.
5453
custom-cache-suffix: $(date -u "+%Y-%m")
5554

55+
# Validate XML files against schema.
56+
- name: Validate XML rulesets against schema
57+
uses: phpcsstandards/xmllint-validate@v1
58+
with:
59+
pattern: "./*/ruleset.xml"
60+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
61+
62+
- name: Validate documentation XML against schema
63+
uses: phpcsstandards/xmllint-validate@v1
64+
with:
65+
pattern: "./*/Docs/*/*Standard.xml"
66+
xsd-file: "vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd"
67+
68+
- name: Validate Project PHPCS ruleset against schema
69+
uses: phpcsstandards/xmllint-validate@v1
70+
with:
71+
pattern: "phpcs.xml.dist"
72+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
73+
74+
- name: "Validate PHPUnit config for use with PHPUnit 8"
75+
uses: phpcsstandards/xmllint-validate@v1
76+
with:
77+
pattern: "phpunit.xml.dist"
78+
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"
79+
80+
- name: "Validate PHPUnit config for use with PHPUnit 9"
81+
uses: phpcsstandards/xmllint-validate@v1
82+
with:
83+
pattern: "phpunit.xml.dist"
84+
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"
85+
86+
# Check the code-style consistency of the PHP files.
87+
- name: Check PHP code style
88+
id: phpcs
89+
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
90+
91+
- name: Show PHPCS results in PR
92+
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
93+
run: cs2pr ./phpcs-report.xml
94+
95+
# Check that the sniffs available are feature complete.
96+
# For now, just check that all sniffs have unit tests.
97+
# At a later stage the documentation check can be activated.
98+
- name: Check sniff feature completeness
99+
run: composer check-complete
100+
101+
xml-cs:
102+
name: 'XML Code style'
103+
runs-on: ubuntu-latest
104+
105+
env:
106+
XMLLINT_INDENT: ' '
107+
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v4
111+
56112
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
57113
# This should not be blocking for this job, so ignore any errors from this step.
58114
# Ref: https://github.com/dotnet/core/issues/4167
@@ -64,41 +120,16 @@ jobs:
64120
run: sudo apt-get install --no-install-recommends -y libxml2-utils
65121

66122
# Show XML violations inline in the file diff.
67-
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
68123
- name: Enable showing XML issues inline
69124
uses: korelstar/xmllint-problem-matcher@v1
70125

71-
# Validate the Ruleset XML file.
72-
# @link http://xmlsoft.org/xmllint.html
73-
- name: Validate rulesets against schema
74-
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
75-
76126
# Check the code-style consistency of the XML ruleset files.
77127
- name: Check XML code style
78128
run: |
79129
diff -B ./Modernize/ruleset.xml <(xmllint --format "./Modernize/ruleset.xml")
80130
diff -B ./NormalizedArrays/ruleset.xml <(xmllint --format "./NormalizedArrays/ruleset.xml")
81131
diff -B ./Universal/ruleset.xml <(xmllint --format "./Universal/ruleset.xml")
82132
83-
# Validate the Documentation XML files.
84-
- name: Validate documentation against schema
85-
run: xmllint --noout --schema vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd ./*/Docs/*/*Standard.xml
86-
87-
# Check the code-style consistency of the PHP files.
88-
- name: Check PHP code style
89-
id: phpcs
90-
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
91-
92-
- name: Show PHPCS results in PR
93-
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
94-
run: cs2pr ./phpcs-report.xml
95-
96-
# Check that the sniffs available are feature complete.
97-
# For now, just check that all sniffs have unit tests.
98-
# At a later stage the documentation check can be activated.
99-
- name: Check sniff feature completeness
100-
run: composer check-complete
101-
102133
phpstan:
103134
name: "PHPStan"
104135
uses: PHPCSStandards/.github/.github/workflows/reusable-phpstan.yml@main

0 commit comments

Comments
 (0)
Please sign in to comment.