Improve CI consistency checks
- Ignore deprecated rules with no specializations - Add "Description" header that is implicit in rspecs - Prevent stopping on first warning encountered in an adoc, go through all the rspecs
This commit is contained in:
parent
fb261af631
commit
c1524a4d7b
59
tests.sh
59
tests.sh
@ -4,34 +4,55 @@ exit_code=0
|
||||
|
||||
for dir in rules/*
|
||||
do
|
||||
dir=${dir%*/}
|
||||
dir=${dir%*/}
|
||||
echo ${dir##*/}
|
||||
#validate metadata
|
||||
FILE="$dir/metadata.json"
|
||||
if test -f $FILE; then
|
||||
echo "$FILE exists."
|
||||
validate-json $FILE ./validation/schema.json
|
||||
validate-json $FILE ./validation/schema.json
|
||||
else
|
||||
echo "no $FILE"
|
||||
echo "ERROR: no metadata file $FILE"
|
||||
exit_code=1
|
||||
fi
|
||||
#validate asciidoc
|
||||
for language in $dir/*/
|
||||
do
|
||||
language=${language%*/}
|
||||
echo ${language##*/}
|
||||
#validate metadata
|
||||
RULE="$language/rule.adoc"
|
||||
if test -f $RULE; then
|
||||
echo "$RULE exists."
|
||||
asciidoctor --failure-level=WARNING -o /dev/null $RULE
|
||||
else
|
||||
echo "no $RULE"
|
||||
exit_code=1
|
||||
fi
|
||||
#validate asciidoc
|
||||
|
||||
done
|
||||
subdircount=$(find $dir -maxdepth 1 -type d | wc -l)
|
||||
|
||||
# check if there are language specializations
|
||||
if [[ "$subdircount" -eq 1 ]]
|
||||
then
|
||||
# no specializations, that's fine if the rule is deprecated
|
||||
if grep -q '"status": "deprecated"' "$dir/metadata.json"; then
|
||||
echo "INFO: deprecated generic rule $dir with no language specializations"
|
||||
else
|
||||
echo "ERROR: non-deprecated generic rule $dir with no language specializations"
|
||||
exit_code=1
|
||||
fi
|
||||
else
|
||||
#validate asciidoc
|
||||
for language in $dir/*/
|
||||
do
|
||||
language=${language%*/}
|
||||
echo ${language##*/}
|
||||
RULE="$language/rule.adoc"
|
||||
if test -f $RULE; then
|
||||
echo "$RULE exists."
|
||||
TMP_ADOC="$language/tmp.adoc"
|
||||
echo "== Description" > $TMP_ADOC
|
||||
cat $RULE >> $TMP_ADOC
|
||||
if asciidoctor --failure-level=WARNING -o /dev/null $TMP_ADOC; then
|
||||
echo "$RULE syntax is fine"
|
||||
else
|
||||
echo "ERROR: $RULE has incorrect asciidoc"
|
||||
exit_code=1
|
||||
fi
|
||||
rm $TMP_ADOC
|
||||
else
|
||||
echo "ERROR: no asciidoc file $RULE"
|
||||
exit_code=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
exit $exit_code
|
||||
|
Loading…
x
Reference in New Issue
Block a user