Validate HTML and CSS in Travis
This commit is contained in:
parent
f5d76dd5bb
commit
a98a223e13
|
@ -36,6 +36,11 @@ jobs:
|
|||
addons:
|
||||
before_script:
|
||||
script: npm run lint
|
||||
-
|
||||
env:
|
||||
addons:
|
||||
before_script:
|
||||
script: git ls-tree --name-only -r HEAD | grep -E "[.](html|css)$" | xargs ./utils/validate
|
||||
- stage: deploy
|
||||
env:
|
||||
addons:
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RET=0
|
||||
|
||||
OUT=`mktemp`
|
||||
|
||||
for fn in "$@"; do
|
||||
echo "Validating $fn..."
|
||||
echo
|
||||
|
||||
case $fn in
|
||||
*.html)
|
||||
type="text/html"
|
||||
;;
|
||||
*.css)
|
||||
type="text/css"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown format!"
|
||||
echo
|
||||
RET=1
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
curl --silent \
|
||||
--header "Content-Type: ${type}; charset=utf-8" \
|
||||
--data-binary @${fn} \
|
||||
https://validator.w3.org/nu/?out=text > $OUT
|
||||
cat $OUT
|
||||
echo
|
||||
|
||||
# We don't fail the check for warnings as some warnings are
|
||||
# not relevant for us, and we don't currently have a way to
|
||||
# ignore just those
|
||||
if grep -q -s -E "^Error:" $OUT; then
|
||||
RET=1
|
||||
fi
|
||||
done
|
||||
|
||||
rm $OUT
|
||||
|
||||
exit $RET
|
Loading…
Reference in New Issue