2021-05-04 09:58:49 +02:00
|
|
|
#!/bin/bash
|
2021-05-05 07:53:30 +02:00
|
|
|
set -uo pipefail
|
2021-05-04 09:58:49 +02:00
|
|
|
|
2021-06-08 15:21:29 +02:00
|
|
|
./ci/generate_html.sh
|
2021-05-04 09:58:49 +02:00
|
|
|
|
2021-05-05 07:53:30 +02:00
|
|
|
exit_code=0
|
|
|
|
|
2021-05-04 09:58:49 +02:00
|
|
|
#validate sections in asciidoc
|
|
|
|
cd rspec-tools
|
|
|
|
pipenv install -e .
|
2021-05-05 07:53:30 +02:00
|
|
|
if pipenv run rspec-tools check-sections --d ../out; then
|
2021-05-05 09:40:19 +02:00
|
|
|
echo "Sections are fine"
|
|
|
|
else
|
2021-05-05 07:53:30 +02:00
|
|
|
echo "ERROR: incorrect section names"
|
|
|
|
exit_code=1
|
|
|
|
fi
|
2021-05-04 09:58:49 +02:00
|
|
|
cd ..
|
|
|
|
|
2020-06-23 11:33:04 +02:00
|
|
|
for dir in rules/*
|
|
|
|
do
|
2021-01-07 17:15:42 +01:00
|
|
|
dir=${dir%*/}
|
2020-06-26 15:25:20 +02:00
|
|
|
echo ${dir##*/}
|
2021-01-07 17:15:42 +01:00
|
|
|
|
|
|
|
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
|
2021-06-08 14:23:48 +02:00
|
|
|
if grep -q '"status": "deprecated"\|"status": "closed"' "$dir/metadata.json"; then
|
|
|
|
echo "INFO: deprecated generic rule $dir with no language specializations"
|
2020-06-23 11:33:04 +02:00
|
|
|
else
|
2021-06-08 14:23:48 +02:00
|
|
|
echo "ERROR: non-deprecated generic rule $dir with no language specializations"
|
|
|
|
exit_code=1
|
2020-06-23 11:33:04 +02:00
|
|
|
fi
|
2021-01-07 17:15:42 +01:00
|
|
|
else
|
|
|
|
#validate asciidoc
|
2021-05-03 21:31:58 +02:00
|
|
|
supportedLanguages=$(sed 's/ or//' supported_languages.adoc | tr -d '`,')
|
|
|
|
for language in $dir/*/
|
2021-01-07 17:15:42 +01:00
|
|
|
do
|
|
|
|
language=${language%*/}
|
|
|
|
echo ${language##*/}
|
2021-05-03 21:31:58 +02:00
|
|
|
if [[ ! "${supportedLanguages[@]}" =~ "${language##*/}" ]]; then
|
|
|
|
echo "ERROR: ${language##*/} is not a supported language"
|
|
|
|
exit_code=1
|
|
|
|
fi
|
2021-01-07 17:15:42 +01:00
|
|
|
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
|
2020-06-23 11:33:04 +02:00
|
|
|
done
|
|
|
|
|
2021-05-03 21:31:58 +02:00
|
|
|
exit $exit_code
|