XMLLint Validate
ActionsGitHub Action to validate XML files for being well-formed and optionally validate against an XSD schema file.
Input | Required | Type | Notes |
---|---|---|---|
pattern |
yes | string | The file(s) to validate. The input expects a path to a single file or a glob pattern. |
xsd-file |
no | string | Path to a local file containing the XSD schema to validate against. |
xsd-url |
no | string | URL to a remote file containing the XSD schema to validate against. |
show-in-pr |
no | bool | Annotate any errors from xmllint inline in PRs ? Defaults to true . |
debug |
no | bool | Show verbose output to allow for debugging the action. Defaults to false . |
Note
If both an xsd-file
and an xsd-url
are passed, the xsd-file
takes precedence.
Validating the well-formedness of a single XML file:
jobs:
test:
name: "XMLLint validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate XML file
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "path/to/file.xml"
Glob patterns are also supported:
jobs:
test:
name: "XMLLint validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate XML files
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "path/to/*/docs/*.xml"
Validating XML files against a locally available XSD schema:
jobs:
test:
name: "XMLLint validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate XML file
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "path/to/*/docs/*.xml"
xsd-file: "path/to/docs.xsd"
Validating XML files against a remote XSD schema:
jobs:
test:
name: "XMLLint validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate XML file
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "path/to/*/docs/*.xml"
xsd-url: "https://examples.org/docs.xsd"
Some examples of how this action can be used:
jobs:
test:
name: "Validate XSD files"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate XSD files conform to the specs
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "path/to/*.xsd"
xsd-url: "https://www.w3.org/2012/04/XMLSchema.xsd"
The below workflow presumes PHP_CodeSniffer will be installed via Composer.
jobs:
test:
name: "XMLLint validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
- name: Validate PHP_CodeSniffer XML ruleset
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpcs.xml.dist"
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
The below workflow presumes PHPUnit will be installed via Composer.
jobs:
test:
name: "XMLLint validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
- name: Validate PHPUnit XML configuration against current
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpunit.xml.dist"
xsd-file: "vendor/phpunit/phpunit/phpunit.xsd"
# Or alternatively:
- name: Validate PHPUnit XML configuration against older XSD
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpunit.xml.dist"
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"
Contributions to this project are welcome. Clone this repository, create a new branch, make your changes, commit them and send in a pull request.
If unsure whether the changes you are proposing would be welcome, open an issue first to discuss your proposal.
This project is part of the PHPCSStandards Open Collective and financial support for this project is always appreciated!
The phpcsstandards/xmllint-validate GitHub Action is ©copyright PHPCSStandards and contributors and licensed for use under the terms of the MIT License (MIT). Please see LICENSE for more information.
This action gratefully makes use of the following externally provided tools which are each governed by their own licensing:
XMLLint Validate is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.