Skip to content

Commit

Permalink
Adds XML linter
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Jan 25, 2020
1 parent 0ed287f commit ee7d44b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ matrix:
- LEGACY_DEPS="phpunit/phpunit"
- CS_CHECK=true
- TEST_COVERAGE=true
- XMLLINT=true
addons:
apt:
packages:
- libxml2-utils
- php: 7.1
env:
- DEPS=latest
Expand Down Expand Up @@ -67,6 +72,7 @@ install:
script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $XMLLINT == 'true' ]]; then test/xmllint.sh ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi
Expand Down
2 changes: 1 addition & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<ruleset name="Webimpress Coding Standard">
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WebimpressCodingStandard" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<rule ref="vendor/webimpress/coding-standard/src/WebimpressCodingStandard/ruleset.xml"/>
</ruleset>
4 changes: 1 addition & 3 deletions src/WebimpressCodingStandard/ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
<ruleset name="Webimpress Coding Standard"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd">
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WebimpressCodingStandard" xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Webimpress Coding Standard</description>

<!-- display progress -->
Expand Down
18 changes: 18 additions & 0 deletions test/xmllint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

RULESET="src/WebimpressCodingStandard/ruleset.xml"
LOCAL="ruleset.xml"

set -e

wget -nv -N -P tmp/ "https://github.com/squizlabs/PHP_CodeSniffer/raw/master/phpcs.xsd"
wget -nv -N -P tmp/ "https://www.w3.org/2012/04/XMLSchema.xsd"

xmllint --noout --schema tmp/XMLSchema.xsd tmp/phpcs.xsd
xmllint --noout --schema tmp/phpcs.xsd "$RULESET"
diff -B "$RULESET" <(XMLLINT_INDENT=" " xmllint --format "$RULESET")

xmllint --noout --schema tmp/phpcs.xsd "$LOCAL"
diff -B "$LOCAL" <(XMLLINT_INDENT=" " xmllint --format "$LOCAL")

rm -Rf tmp/

0 comments on commit ee7d44b

Please sign in to comment.