mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
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:
parent
b70fefe642
commit
58af541321
@ -48,7 +48,7 @@ commands:
|
||||
- run:
|
||||
name: "Install Grafana build pipeline tool"
|
||||
command: |
|
||||
VERSION=0.5.5
|
||||
VERSION=0.5.6
|
||||
curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v${VERSION}/grabpl
|
||||
chmod +x grabpl
|
||||
mv grabpl /tmp
|
||||
@ -852,7 +852,11 @@ jobs:
|
||||
- node_modules
|
||||
- run:
|
||||
name: frontend tests
|
||||
command: "./scripts/circle-test-frontend.sh"
|
||||
command: |
|
||||
yarn run ci:test-frontend
|
||||
if [[ $CIRCLE_BRANCH == "master" ]]; then
|
||||
./scripts/ci-frontend-metrics.sh | ./bin/grabpl publish-metrics ${GRAFANA_MISC_STATS_API_KEY}
|
||||
fi
|
||||
- store_test_results:
|
||||
path: reports/junit
|
||||
- run:
|
||||
|
20
.drone.yml
20
.drone.yml
@ -26,7 +26,7 @@ steps:
|
||||
- yarn install --frozen-lockfile --no-progress
|
||||
environment:
|
||||
DOCKERIZE_VERSION: 0.6.1
|
||||
GRABPL_VERSION: 0.5.5
|
||||
GRABPL_VERSION: 0.5.6
|
||||
|
||||
- name: lint-backend
|
||||
image: grafana/build-container:1.2.26
|
||||
@ -74,10 +74,7 @@ steps:
|
||||
- name: test-frontend
|
||||
image: grafana/build-container:1.2.26
|
||||
commands:
|
||||
- yarn run prettier:check
|
||||
- yarn run packages:typecheck
|
||||
- yarn run typecheck
|
||||
- yarn run test
|
||||
- yarn run ci:test-frontend
|
||||
environment:
|
||||
TEST_MAX_WORKERS: 50%
|
||||
depends_on:
|
||||
@ -252,7 +249,7 @@ steps:
|
||||
- yarn install --frozen-lockfile --no-progress
|
||||
environment:
|
||||
DOCKERIZE_VERSION: 0.6.1
|
||||
GRABPL_VERSION: 0.5.5
|
||||
GRABPL_VERSION: 0.5.6
|
||||
|
||||
- name: lint-backend
|
||||
image: grafana/build-container:1.2.26
|
||||
@ -300,12 +297,11 @@ steps:
|
||||
- name: test-frontend
|
||||
image: grafana/build-container:1.2.26
|
||||
commands:
|
||||
- yarn run prettier:check
|
||||
- yarn run packages:typecheck
|
||||
- yarn run typecheck
|
||||
- yarn run test
|
||||
- yarn run ci:test-frontend
|
||||
- ./scripts/ci-frontend-metrics.sh | ./bin/grabpl publish-metrics $${GRAFANA_MISC_STATS_API_KEY}
|
||||
environment:
|
||||
TEST_MAX_WORKERS: 50%
|
||||
GRAFANA_MISC_STATS_API_KEY:
|
||||
from_secret: grafana_misc_stats_api_key
|
||||
depends_on:
|
||||
- initialize
|
||||
|
||||
@ -519,7 +515,7 @@ steps:
|
||||
- gcloud auth activate-service-account --key-file=gcpkey.json
|
||||
- rm gcpkey.json
|
||||
- $$ProgressPreference = "SilentlyContinue"
|
||||
- Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.5.5/windows/grabpl.exe -OutFile grabpl.exe
|
||||
- Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.5.6/windows/grabpl.exe -OutFile grabpl.exe
|
||||
- Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/oss/master/grafana-7.2.0-9fffe273pre.windows-amd64.zip -OutFile grafana.zip
|
||||
- cp C:\App\nssm-2.24.zip .
|
||||
- ./grabpl.exe windows-installer --edition oss grafana.zip
|
||||
|
@ -40,7 +40,8 @@
|
||||
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"plugins:build-bundled": "grafana-toolkit plugin:bundle-managed",
|
||||
"watch": "yarn start -d watch,start core:start --watchTheme "
|
||||
"watch": "yarn start -d watch,start core:start --watchTheme",
|
||||
"ci:test-frontend": "yarn run prettier:check && yarn run packages:typecheck && yarn run typecheck && yarn run test"
|
||||
},
|
||||
"grafana": {
|
||||
"whatsNewUrl": "https://grafana.com/docs/grafana/latest/guides/whats-new-in-v7-1/",
|
||||
|
@ -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)"
|
||||
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)"
|
||||
|
||||
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}\"
|
||||
}"
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user