grafana/scripts/ci-reference-docs-lint.sh
Marcus Andersson b5196f531c
Build: added steps to generate packages api documentation. (#27930)
* added steps to generate docs.

* re-generated the drone.yml file.

* removed metrics reporting from pr pipeline.

* fixed spelling issues.

* fixed so package generation should work.

* some small refactorings.

* fixed spelling error.

* adding echo to verify that we execute the correct script.

* removed echo statement.

* changed scripts a bit.

* added ci flag to script.

* adding exit 1

* increased the limit.

* added missing space.

* fixed shellcheck error.

* fixing lint errors.

* renamed build step.

* changed logic.

* increased limit.

* changed to echo instead of echo -e

* fixed shellcheck errors.

* trying to debug script,

* trying to simplify the find statement.

* fixed issue with text formatting on linux.

* imported build step.

* Update scripts/ci-reference-docs-lint.sh

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* removed cleanup of packages.

* increased limit.

* will build frontend docs on master but not lint it.

* will always run the linting step.

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-10-14 14:35:55 +02:00

45 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# abort if we get any error
set -eo pipefail
pretty_print_result_of_report() {
# $1 = result of current report
echo -e "\n\n"
echo -e "-----------------------------------------------------\n"
echo -e "$1\n"
echo "-----------------------------------------------------"
}
BUILD_MODE="${1-local}"
REPORT_PATH="$(realpath "$(dirname "$0")/../reports/docs/")"
BUILD_SCRIPT_PATH="$(realpath "$(dirname "$0")/ci-reference-docs-build.sh")"
if [ ! -d "$REPORT_PATH" ]; then
# this script needs to be run after the packages have been built and the api-extractor has completed.
# shellcheck source=/scripts/ci-reference-docs-build.sh
if ! . "$BUILD_SCRIPT_PATH" "$BUILD_MODE";
then
echo "Failed to build packages and extract docs" >&2
exit 1
else
echo "Successfully built packages and extracted docs"
fi
fi
WARNINGS_COUNT="$(find "$REPORT_PATH" -type f -name \*.log -print0 | xargs -0 grep -o "Warning: " | wc -l | xargs)"
WARNINGS_COUNT_LIMIT=1077
if [ "$WARNINGS_COUNT" -gt $WARNINGS_COUNT_LIMIT ]; then
echo -e "API Extractor warnings/errors $WARNINGS_COUNT exceeded $WARNINGS_COUNT_LIMIT so failing build.\n"
echo "Please go to: https://github.com/grafana/grafana/blob/master/contribute/style-guides/code-comments.md for more information on how to add code comments."
exit 1
fi
if [ "$WARNINGS_COUNT" -lt $WARNINGS_COUNT_LIMIT ]; then
pretty_print_result_of_report "Wohoo! Fewer warnings compared to last build 🎉🎈🍾✨\n\nYou can lower the threshold from $WARNINGS_COUNT_LIMIT to $WARNINGS_COUNT in the:\nscripts/ci-reference-docs-metrics.sh"
fi
pretty_print_result_of_report "API Extractor total warnings: $WARNINGS_COUNT"