Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This package contains Composer scripts to quickly run the developer checks which

After `composer install`, you can do:

- `composer lint`: Lint PHP and XML files in against parse errors.
- `composer lint`: Lint PHP files against parse errors.
- `composer cs`: Check the code style and code quality of the codebase via PHPCS.
- `composer test`: Run the unit tests for the VIPCS sniffs.
- `composer test-coverage`: Run the unit tests for the VIPCS sniffs with coverage enabled.
Expand Down
57 changes: 40 additions & 17 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
name: 'Basic CS and QA checks'
runs-on: ubuntu-latest

env:
XMLLINT_INDENT: ' ' # This is a tab character.

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -33,21 +36,6 @@ jobs:
coverage: none
tools: cs2pr

# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
# This should not be blocking for this job, so ignore any errors from this step.
# Ref: https://github.com/dotnet/core/issues/4167
- name: Update the available packages list
continue-on-error: true
run: sudo apt-get update

- name: Install xmllint
run: sudo apt-get install --no-install-recommends -y libxml2-utils

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

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
Expand All @@ -65,8 +53,43 @@ jobs:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: 'Validate XML against schema and check code style'
run: ./bin/xml-lint
# Validate the XML file.
- name: Validate rulesets against schema
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "./*/ruleset.xml"
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"

# Check the code-style consistency of the XML file.
# Note: this needs xmllint, but that will be installed via the phpcsstandards/xmllint-validate action runner in the previous step.
- name: Check XML code style
run: |
diff -B --tabsize=4 ./WordPressVIPMinimum/ruleset.xml <(xmllint --format "./WordPressVIPMinimum/ruleset.xml")
diff -B --tabsize=4 ./WordPress-VIP-Go/ruleset.xml <(xmllint --format "./WordPress-VIP-Go/ruleset.xml")

# Validate dev tool related XML files.
- name: Validate Project PHPCS ruleset against schema
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: ".phpcs.xml.dist"
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"

# Notes:
# - PHPUnit 9.5 (which will be installed in this job) doesn't ship XSD files further back than 8.5.
# - PHPUnit 9.3 introduced some new configuration options and deprecated the old versions of those.
# For cross-version compatibility with older PHPUnit versions, those new config options cannot be used yet,
# which is why the PHPUnit 9 validation is done against the PHPUnit 9.2 schema.
- name: "Validate PHPUnit config for use with PHPUnit 8"
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpunit.xml.dist"
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"

- name: "Validate PHPUnit config for use with PHPUnit 9"
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpunit.xml.dist"
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"

# Check the code-style consistency of the PHP files.
- name: Check PHP code style
Expand Down
17 changes: 0 additions & 17 deletions bin/xml-lint

This file was deleted.

5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"scripts": {
"test-ruleset": "bin/ruleset-tests",
"lint": [
"bin/php-lint",
"bin/xml-lint"
"bin/php-lint"
],
"cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
"test": "bin/unit-tests",
Expand All @@ -57,7 +56,7 @@
]
},
"scripts-descriptions": {
"lint": "VIPCS: Lint PHP and XML files in against parse errors.",
"lint": "VIPCS: Lint PHP files against parse errors.",
"cs": "VIPCS: Check the code style and code quality of the codebase via PHPCS.",
"test": "VIPCS: Run the unit tests for the VIPCS sniffs.",
"test-coverage": "VIPCS: Run the unit tests for the VIPCS sniffs with coverage enabled.",
Expand Down