Skip to content

GH Actions: Bump the action-runners group with 4 updates #275

GH Actions: Bump the action-runners group with 4 updates

GH Actions: Bump the action-runners group with 4 updates #275

Workflow file for this run

name: Test
on:
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
yamllint:
name: 'Lint Yaml'
uses: PHPCSStandards/.github/.github/workflows/reusable-yamllint.yml@c535983699986d1c538d4e47f33e813fcfbcc8a0 # v1.2.2
with:
strict: true
markdownlint:
name: 'Lint Markdown'
uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@c535983699986d1c538d4e47f33e813fcfbcc8a0 # v1.2.2
remark:
name: 'QA Markdown'
uses: PHPCSStandards/.github/.github/workflows/reusable-remark.yml@c535983699986d1c538d4e47f33e813fcfbcc8a0 # v1.2.2
# Validate the "valid" XSD files used in the tests.
validate-xsds:
name: 'Validate XSD files'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Validate XSD file [1]
uses: ./
with:
pattern: tests/fixtures/xsd-files/valid-local.xsd
xsd-url: https://www.w3.org/2012/04/XMLSchema.xsd
- name: Validate XSD file [2]
uses: ./
with:
pattern: docs/test-fixtures/valid-remote.xsd
xsd-url: https://www.w3.org/2012/04/XMLSchema.xsd
test:
needs: [yamllint, validate-xsds]
name: "${{ matrix.name }}"
runs-on: ubuntu-latest
strategy:
matrix:
include:
####################################################
# Basic action input handling.
####################################################
# Test input handling: missing required input.
- name: "Test required input missing"
expected: "fail"
####################################################
# Basic well-formedness tests.
####################################################
# Test basic well-formedness validation.
- name: "Test no XSD, valid XML"
pattern: tests/fixtures/valid-basic.xml
expected: success
- name: "Test no XSD, invalid XML"
pattern: tests/fixtures/invalid-basic.xml
expected: fail
# Test that glob patterns are handled correctly.
- name: "Test no XSD, glob, valid XML files"
pattern: ./tests/fixtures/all-valid-basic/*.xml
expected: success
- name: "Test no XSD, glob, invalid XML files"
pattern: ./tests/*/some-valid-basic/*.xml
expected: fail
####################################################
# Validate against a local XSD file.
####################################################
# Test input handling: optional XSD file.
- name: "Test XSD file wrong file extension"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/wrong-extension.notxsd
expected: "fail"
- name: "Test XSD file doesn't exist"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/file-does-not-exist.xsd
expected: "fail"
- name: "Test XSD file empty"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/file-is-empty.xsd
expected: "fail"
# Test validating against a local XSD schema.
- name: "Test XSD file, valid XML + schema"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "success"
- name: "Test XSD file, invalid XML"
pattern: tests/fixtures/invalid-basic.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "fail"
- name: "Test XSD file, valid XML, not schema"
pattern: tests/fixtures/invalid-local.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "fail"
# Test that glob patterns are handled correctly in combination with a local XSD schema.
- name: "Test XSD file, glob, valid XML + schema"
pattern: ./tests/fixtures/all-valid-local-xsd/*.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "success"
- name: "Test XSD file, glob, valid XML, not schema"
pattern: ./tests/fixtures/some-*-local-xsd/*.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "fail"
####################################################
# Validate against an (originally) remote XSD file.
####################################################
# Test input handling: optional XSD URL.
- name: "Test XSD URL wrong scheme"
pattern: tests/fixtures/valid-local.xml
xsd-url: file://tests/fixtures/valid-local.xml
expected: "fail"
- name: "Test XSD URL wrong file extension"
pattern: tests/fixtures/valid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/wrong-extension.notxsd
expected: "fail"
- name: "Test XSD URL doesn't exist"
pattern: tests/fixtures/valid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/file-does-not-exist.xsd
expected: "fail"
- name: "Test XSD URL empty"
pattern: tests/fixtures/valid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/file-is-empty.xsd
expected: "fail"
# Test validating against a (originally) remote XSD schema.
- name: "Test remote XSD file, valid XML"
pattern: tests/fixtures/valid-remote.xml
xsd-url: http://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "success"
- name: "Test remote XSD file, valid XML, not valid against schema"
pattern: tests/fixtures/invalid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "fail"
# Safeguard that a local XSD file always takes precedence over a remote XSD URL.
- name: "Test local XSD overrules remote [1]"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "success"
- name: "Test local XSD overrules remote [2]"
pattern: tests/fixtures/valid-remote.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "fail"
####################################################
# Support "Show in PR".
####################################################
# The default behaviour (enabled, not explicitly passed) is tested via all the other tests.
# Even though we can't safeguard the underlying functionality via CI, it can be
# confirmed the toggle functionality works correctly by looking at the "Annotations" fold-out
# above the logs for the individual jobs which have a "fail" expectation.
# Safeguard that explicitly enabling/disabling the show-in-pr option doesn't break anything.
- name: "Test show-in-pr: bool true"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: true
expected: "fail"
- name: "Test show-in-pr: string true"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: 'true'
expected: "fail"
- name: "Test show-in-pr: bool false"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: false
expected: "fail"
- name: "Test show-in-pr: string false"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: 'false'
expected: "fail"
# Any other value should have no influence and the default behaviour (annotations = on) should prevail.
- name: "Test show-in-pr: unsupported value"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: somethingElse
expected: "fail"
####################################################
# Verbose vs non-verbose output.
####################################################
# Re-run a few tests with verbosity on to allow for viewing the difference in the output.
# Safeguard that explicitly enabling/disabling the debug option doesn't break anything.
- name: "Debug off, valid XML"
pattern: tests/fixtures/valid-basic.xml
debug: false
expected: "success"
- name: "Debug on, invalid XML"
pattern: ./tests/*/some-valid-basic/*.xml
debug: true
expected: "fail"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run the test
id: xmllint-validate
continue-on-error: true
uses: ./
with:
pattern: ${{ matrix.pattern }}
xsd-file: ${{ matrix.xsd-file }}
xsd-url: ${{ matrix.xsd-url }}
show-in-pr: ${{ matrix.show-in-pr }}
debug: ${{ matrix.debug }}
- name: "Check the result of a successful test against expectation"
if: ${{ steps.xmllint-validate.outcome == 'success' }}
run: |
if [ "${{ matrix.expected == 'fail' }}" == "true" ]; then
exit 1
fi
- name: "Check the result of a failed test against expectation"
if: ${{ steps.xmllint-validate.outcome != 'success' }}
run: |
if [ "${{ matrix.expected == 'success' }}" == "true" ]; then
exit 1
fi