From ee7d44bd0196cb6c6191717254f0214cc79e8981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Sat, 25 Jan 2020 13:44:07 +0000 Subject: [PATCH] Adds XML linter Fixes #80 --- .travis.yml | 6 ++++++ ruleset.xml | 2 +- src/WebimpressCodingStandard/ruleset.xml | 4 +--- test/xmllint.sh | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100755 test/xmllint.sh diff --git a/.travis.yml b/.travis.yml index e9ff50e2..2112bafd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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 diff --git a/ruleset.xml b/ruleset.xml index a17265bd..6f887b40 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,4 +1,4 @@ - + diff --git a/src/WebimpressCodingStandard/ruleset.xml b/src/WebimpressCodingStandard/ruleset.xml index f76ffd7b..77210fca 100755 --- a/src/WebimpressCodingStandard/ruleset.xml +++ b/src/WebimpressCodingStandard/ruleset.xml @@ -1,7 +1,5 @@ - + Webimpress Coding Standard diff --git a/test/xmllint.sh b/test/xmllint.sh new file mode 100755 index 00000000..e0db8fa0 --- /dev/null +++ b/test/xmllint.sh @@ -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/