Skip to content

Commit 7eda814

Browse files
committed
CI: switch to GitHub Actions - step 2: XML and PEAR validation
This commit: * Adds a GH Actions workflow for the build which validated the XML file against schema and checked their code style consistency, as well as validate the PEAR package file, as was previously run on Travis. * Removes that part of the `.travis.yml` configuration. Notes: Builds will run on all pushes and on pull requests, with the exception of those just modifying files which are irrelevant to this workflow.
1 parent 63fd430 commit 7eda814

File tree

2 files changed

+73
-30
lines changed

2 files changed

+73
-30
lines changed

.github/workflows/validate.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Validate
2+
3+
on:
4+
# Run on all pushes and on all pull requests.
5+
# Prevent the build from running when there are only irrelevant changes.
6+
push:
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
checkxml:
15+
name: Check XML files
16+
runs-on: ubuntu-latest
17+
18+
env:
19+
XMLLINT_INDENT: ' '
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Install xmllint
26+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
27+
28+
- name: Retrieve XML Schema
29+
run: curl -O https://www.w3.org/2012/04/XMLSchema.xsd
30+
31+
# Show XML violations inline in the file diff.
32+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
33+
- uses: korelstar/xmllint-problem-matcher@v1
34+
35+
# Validate the XML ruleset files.
36+
# @link http://xmlsoft.org/xmllint.html
37+
- name: Validate rulesets against schema
38+
run: xmllint --noout --schema phpcs.xsd ./src/Standards/*/ruleset.xml
39+
40+
# Validate the XSD file.
41+
# @link http://xmlsoft.org/xmllint.html
42+
- name: Validate XSD against schema
43+
run: xmllint --noout --schema ./XMLSchema.xsd ./phpcs.xsd
44+
45+
# Check the code-style consistency of the XML files.
46+
- name: Check XML code style
47+
run: |
48+
diff -B ./phpcs.xml.dist <(xmllint --format "./phpcs.xml.dist")
49+
diff -B ./src/Standards/Generic/ruleset.xml <(xmllint --format "./src/Standards/Generic/ruleset.xml")
50+
diff -B ./src/Standards/MySource/ruleset.xml <(xmllint --format "./src/Standards/MySource/ruleset.xml")
51+
diff -B ./src/Standards/PEAR/ruleset.xml <(xmllint --format "./src/Standards/PEAR/ruleset.xml")
52+
diff -B ./src/Standards/PSR1/ruleset.xml <(xmllint --format "./src/Standards/PSR1/ruleset.xml")
53+
diff -B ./src/Standards/PSR2/ruleset.xml <(xmllint --format "./src/Standards/PSR2/ruleset.xml")
54+
diff -B ./src/Standards/PSR12/ruleset.xml <(xmllint --format "./src/Standards/PSR12/ruleset.xml")
55+
diff -B ./src/Standards/Squiz/ruleset.xml <(xmllint --format "./src/Standards/Squiz/ruleset.xml")
56+
diff -B ./src/Standards/Zend/ruleset.xml <(xmllint --format "./src/Standards/Zend/ruleset.xml")
57+
58+
pear:
59+
name: "PHP: 7.4 | PEAR package validation"
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v2
65+
66+
- name: Install PHP
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: '7.4'
70+
coverage: none
71+
72+
- name: Validate the PEAR package file contents
73+
run: php scripts/validate-pear-package.php

.travis.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,6 @@ jobs:
4646
- php bin/phpcs --config-set php_path php
4747
- vendor/bin/phpunit tests/AllTests.php
4848

49-
# Build running just the PEAR package file and XML file validation and code style check.
50-
- php: 7.4
51-
name: "PHP: 7.4 | Pear + XML validate"
52-
addons:
53-
apt:
54-
packages:
55-
- libxml2-utils
56-
before_install:
57-
- export XMLLINT_INDENT=" "
58-
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
59-
install:
60-
- curl -O https://www.w3.org/2012/04/XMLSchema.xsd
61-
script:
62-
# Validate the Pear Package file contents.
63-
- php scripts/validate-pear-package.php
64-
# Validate the xml ruleset files.
65-
# @link http://xmlsoft.org/xmllint.html
66-
- xmllint --noout --schema phpcs.xsd ./src/Standards/*/ruleset.xml
67-
- xmllint --noout --schema ./XMLSchema.xsd ./phpcs.xsd
68-
# Check the code-style consistency of the xml files.
69-
- diff -B ./phpcs.xml.dist <(xmllint --format "./phpcs.xml.dist")
70-
- diff -B ./src/Standards/Generic/ruleset.xml <(xmllint --format "./src/Standards/Generic/ruleset.xml")
71-
- diff -B ./src/Standards/MySource/ruleset.xml <(xmllint --format "./src/Standards/MySource/ruleset.xml")
72-
- diff -B ./src/Standards/PEAR/ruleset.xml <(xmllint --format "./src/Standards/PEAR/ruleset.xml")
73-
- diff -B ./src/Standards/PSR1/ruleset.xml <(xmllint --format "./src/Standards/PSR1/ruleset.xml")
74-
- diff -B ./src/Standards/PSR2/ruleset.xml <(xmllint --format "./src/Standards/PSR2/ruleset.xml")
75-
- diff -B ./src/Standards/PSR12/ruleset.xml <(xmllint --format "./src/Standards/PSR12/ruleset.xml")
76-
- diff -B ./src/Standards/Squiz/ruleset.xml <(xmllint --format "./src/Standards/Squiz/ruleset.xml")
77-
- diff -B ./src/Standards/Zend/ruleset.xml <(xmllint --format "./src/Standards/Zend/ruleset.xml")
78-
7949
allow_failures:
8050
- php: nightly
8151

0 commit comments

Comments
 (0)