Build: scripts to build and measure packages reference docs (#24876)

* added script to check docs metrics.

* added information link on how to add code comments.

* added script for build and measure code comment metrics.

* fixed issues according to shellcheck.

* Added so we build the metrics if report folder is missing.

* added some spacing and a devider.

* Added so we can send metrics to grafana.

* added shellcheck attribute.

* Fixed spelling according to feedback.

* see if shellcheck passes.

* fixed issue with shellcheck.

* Explore/Logs: Fix tooltip display for log graph (#25544)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
This commit is contained in:
Marcus Andersson
2020-06-16 09:33:23 +02:00
committed by GitHub
co-authored by Arve Knudsen kay delaney
parent 3e81a626a4
commit a5b38b799a
5 changed files with 102 additions and 80 deletions
@@ -1,14 +1,7 @@
#!/usr/bin/env bash
#!/bin/bash
# abort if we get any error
set -e
# always make sure we have a clean workspace
if ! git diff-index --quiet HEAD --; then
echo -e "\033[91mgit workspace is dirty and contains changes\033[0"
echo -e "\033[91mmake sure you have a clean workspace before running this script\033[0m"
exit 1
fi
set -eo pipefail
# building grafana packages
echo "building grafana packages..."
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
# abort if we get any error
set -eo pipefail
report_reference_docs_metrics() {
# $1 = branch that the script is running on.
# $2 = number of warnings in current version of the code.
if [ "${1}" == "master" ]; then
./scripts/ci-metrics-publisher.sh \
grafana.ci-code.reference-docs.warnings="$2"
fi
}
pretty_print_result_of_report() {
# $1 = result of current report
echo -e "\n\n"
echo -e "-----------------------------------------------------\n"
echo -e "$1\n"
echo -e "-----------------------------------------------------"
}
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
. "$BUILD_SCRIPT_PATH"
fi
WARNINGS_COUNT="$(find "$REPORT_PATH" -type f -name \*.log -print0 | xargs -0 grep -o "\[33mWarning:" | wc -l | xargs)"
WARNINGS_COUNT_LIMIT=900
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 -e "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."
report_reference_docs_metrics "$CIRCLE_BRANCH" "$WARNINGS_COUNT"
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"
report_reference_docs_metrics "$CIRCLE_BRANCH" "$WARNINGS_COUNT"
exit 0
fi
pretty_print_result_of_report "API Extractor total warnings: $WARNINGS_COUNT"
report_reference_docs_metrics "$CIRCLE_BRANCH" "$WARNINGS_COUNT"
-61
View File
@@ -1,61 +0,0 @@
#!/usr/bin/env bash
# abort if we get any error
set -e
_current="$(git rev-parse --abbrev-ref HEAD)"
_branch="${_current}-docs"
if [ "${_current}" == "master" ]; then
echo -e "\033[91myou cannot generate api docs from the master branch\033[0m"
echo "please checkout the release branch"
echo "ex 'git checkout v5.1.x'"
exit 1
fi
# always make sure we have a clean workspace
if ! git diff-index --quiet HEAD --; then
echo -e "\033[91mgit workspace is dirty and contains changes\033[0"
echo -e "\033[91mmake sure you have a clean workspace before running this script\033[0m"
exit 1
fi
# always make sure to pull latest changes from origin
echo "pulling latest changes from ${_current}"
git pull origin "${_current}"
# creating new branch for docs update
echo "creating new branch ${_branch}"
git checkout -b "${_branch}"
# building grafana packages
echo "building grafana packages..."
yarn packages:build
# extract packages api documentation json
echo "extracting packages documentation data..."
yarn packages:docsExtract
# generating api documentation markdown
echo "generating markdown from documentation data..."
yarn packages:docsToMarkdown
echo "updated files:"
git status --porcelain | sed s/^...//
echo "press [y] to commit documentation update"
read -n 1 confirm
if [ "${confirm}" == "y" ]; then
git add --all docs/sources/packages_api
git commit -m "docs: updated packages api documentation"
git push origin "${_branch}"
git checkout "${_current}"
echo -e "\033[92mPackages docs successfully updated. Please open a PR from ${_branch} to master.\033[0m"
else
git checkout -- .
git clean -f docs/sources/packages_api
git checkout "${_current}"
git branch -d "${_branch}"
echo -e "\033[91mAbort!\033[0m"
fi