Typescript: Fixing typescript strict error, and separate check from publishing (#29679)

* Typescript: Fixing typescript string error, and seperate check from publishing

* now should pass
This commit is contained in:
Torkel Ödegaard 2020-12-08 12:56:37 +01:00 committed by GitHub
parent 9668c172b3
commit a7afab4b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 53 deletions

View File

@ -43,7 +43,7 @@
"typecheck": "tsc --noEmit && yarn run packages:typecheck",
"plugins:build-bundled": "grafana-toolkit plugin:bundle-managed",
"watch": "yarn start -d watch,start core:start --watchTheme",
"ci:test-frontend": "yarn run prettier:check && yarn run typecheck && yarn run lint && yarn run test:ci && yarn grafana-toolkit node-version-check"
"ci:test-frontend": "yarn run prettier:check && yarn run typecheck && yarn run lint && yarn run test:ci && yarn grafana-toolkit node-version-check && ./scripts/ci-check-strict.sh"
},
"grafana": {
"whatsNewUrl": "https://grafana.com/docs/grafana/latest/guides/whats-new-in-v7-3/",

View File

@ -58,7 +58,7 @@ class GraphElement {
annotations: object[];
panel: any;
plot: any;
sortedSeries: any[];
sortedSeries?: any[];
data: any[];
panelWidth: number;
eventManager: EventManager;

View File

@ -52,10 +52,10 @@ class SingleStatCtrl extends MetricsPanelCtrl {
data: Partial<ShowData> = {};
fontSizes: any[];
fontSizes: any[] = [];
fieldNames: string[] = [];
invalidGaugeRange: boolean;
invalidGaugeRange = false;
panel: any;
events: any;
valueNameOptions: any[] = [

13
scripts/ci-check-strict.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
echo -e "Collecting code stats (typescript errors & more)"
ERROR_COUNT_LIMIT=579
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
echo -e "Typescript strict errors $ERROR_COUNT exceeded $ERROR_COUNT_LIMIT so failing build"
exit 1
fi

View File

@ -1,12 +1,6 @@
#!/bin/bash
set -e
echo -e "Collecting code stats (typescript errors & more)"
ERROR_COUNT_LIMIT=580
DIRECTIVES_LIMIT=172
CONTROLLERS_LIMIT=139
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)"
@ -14,21 +8,6 @@ STORIES_COUNT="$(find ./packages/grafana-ui/src/components -name "*.story.tsx" |
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"
exit 1
fi
if [ "$DIRECTIVES" -gt $DIRECTIVES_LIMIT ]; then
echo -e "Directive count $DIRECTIVES exceeded $DIRECTIVES_LIMIT so failing build"
exit 1
fi
if [ "$CONTROLLERS" -gt $CONTROLLERS_LIMIT ]; then
echo -e "Controllers count $CONTROLLERS exceeded $CONTROLLERS_LIMIT so failing build"
exit 1
fi
echo -e "Typescript errors: $ERROR_COUNT"
echo -e "Directives: $DIRECTIVES"
echo -e "Controllers: $CONTROLLERS"

View File

@ -1,28 +0,0 @@
#!/bin/bash
echo "Publishing CI Metrics"
data=""
for ((i = 1; i <= $#; i++ )); do
remainder="${!i}"
# Find everything until last = character (= is included in the result)
# This allows to add tags to metric names
metricName=$(grep -o "\(.*\)=" <<< "$remainder")
# Get the metric value
value=${remainder#"$metricName"}
# Remove remaining = character from metric name
metricName=${metricName%?};
if [ -n "$data" ]; then
data="$data,"
fi
data=''$data'{"name": "'${metricName}'", "value": '${value}', "interval": 60, "mtype": "gauge", "time": '$(date +%s)'}'
done
echo "Publishing metrics:"
echo "$data"
curl "https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics" \
-H 'Content-type: application/json' \
-d "[$data]"