Drone: Report front-end test metrics (#27395)

* Drone: Report front-end test metrics

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* ci-frontend-metrics.sh: Fix collection bugs; print JSON

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Add Yarn script ci:test-frontend
This commit is contained in:
Arve Knudsen
2020-09-07 13:17:03 +02:00
committed by GitHub
parent b70fefe642
commit 58af541321
5 changed files with 50 additions and 42 deletions
+16 -17
View File
@@ -1,18 +1,18 @@
#!/bin/bash
set -eo pipefail
echo -e "Collecting code stats (typescript errors & more)"
ERROR_COUNT_LIMIT=398
ERROR_COUNT_LIMIT=580
DIRECTIVES_LIMIT=172
CONTROLLERS_LIMIT=139
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strictNullChecks true | grep -oP 'Found \K(\d+)')"
DIRECTIVES="$(grep -r -o directive public/app/**/* | wc -l)"
CONTROLLERS="$(grep -r -oP 'class .*Ctrl' public/app/**/* | wc -l)"
STORIES_COUNT="$(find ./packages/grafana-ui/src/components -name "*.story.tsx" | wc -l)"
MDX_COUNT="$(find ./packages/grafana-ui/src/components -name "*.mdx" | wc -l)"
LEGACY_FORMS="$(grep -r -oP 'LegacyForms;' public/app/**/* | wc -l)"
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
DIRECTIVES="$(grep -r -o directive public/app/ | wc -l)"
CONTROLLERS="$(grep -r -oP 'class .*Ctrl' public/app/ | wc -l)"
STORIES_COUNT="$(find ./packages/grafana-ui/src/components -name "*.story.tsx" | wc -l)"
MDX_COUNT="$(find ./packages/grafana-ui/src/components -name "*.mdx" | wc -l)"
LEGACY_FORMS="$(grep -r -oP 'LegacyForms;' public/app | wc -l)"
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
echo -e "Typescript strict errors $ERROR_COUNT exceeded $ERROR_COUNT_LIMIT so failing build"
@@ -36,12 +36,11 @@ echo -e "Stories: $STORIES_COUNT"
echo -e "Documented stories: $MDX_COUNT"
echo -e "Legacy forms: $LEGACY_FORMS"
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./scripts/ci-metrics-publisher.sh \
grafana.ci-code.strictErrors="$ERROR_COUNT" \
grafana.ci-code.directives="$DIRECTIVES" \
grafana.ci-code.controllers="$CONTROLLERS" \
grafana.ci-code.grafana-ui.stories="$STORIES_COUNT" \
grafana.ci-code.grafana-ui.mdx="$MDX_COUNT" \
grafana.ci-code.legacyForms="$LEGACY_FORMS"
fi
echo "Metrics: {
\"grafana.ci-code.strictErrors\": \"${ERROR_COUNT}\",
\"grafana.ci-code.directives\": \"${DIRECTIVES}\",
\"grafana.ci-code.controllers\": \"${CONTROLLERS}\",
\"grafana.ci-code.grafana-ui.stories\": \"${STORIES_COUNT}\",
\"grafana.ci-code.grafana-ui.mdx\": \"${MDX_COUNT}\",
\"grafana.ci-code.legacyForms\": \"${LEGACY_FORMS}\"
}"
+18 -10
View File
@@ -3,7 +3,7 @@ publish_image = 'grafana/grafana-ci-deploy:1.2.5'
grafana_docker_image = 'grafana/drone-grafana-docker:0.2.0'
alpine_image = 'alpine:3.12'
windows_image = 'mcr.microsoft.com/windows:1809'
grabpl_version = '0.5.5'
grabpl_version = '0.5.6'
def pr_pipelines(edition):
services = [
@@ -82,7 +82,7 @@ def master_pipelines(edition):
codespell_step(),
shellcheck_step(),
test_backend_step(),
test_frontend_step(),
test_frontend_step(publish_metrics=True),
build_backend_step(edition=edition),
build_frontend_step(edition=edition),
build_plugins_step(edition=edition),
@@ -353,8 +353,13 @@ def test_backend_step():
],
}
def test_frontend_step():
return {
def test_frontend_step(publish_metrics=False):
cmds = [
'yarn run ci:test-frontend',
]
if publish_metrics:
cmds.append('./scripts/ci-frontend-metrics.sh | ./bin/grabpl publish-metrics $${GRAFANA_MISC_STATS_API_KEY}')
dct = {
'name': 'test-frontend',
'image': build_image,
'depends_on': [
@@ -363,13 +368,16 @@ def test_frontend_step():
'environment': {
'TEST_MAX_WORKERS': '50%',
},
'commands': [
'yarn run prettier:check',
'yarn run packages:typecheck',
'yarn run typecheck',
'yarn run test',
],
'commands': cmds,
}
if publish_metrics:
dct['environment'] = {
'GRAFANA_MISC_STATS_API_KEY': {
'from_secret': 'grafana_misc_stats_api_key',
},
}
return dct
def codespell_step():
return {