Commit 4f6fdd86 by Torkel Ödegaard

Refactoring the ci metrics a bit more making it easier to re-use

parent aa6a9329
#!/bin/bash
echo "Collecting code stats (typescript errors & more)"
echo -e "Collecting code stats (typescript errors & more)"
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --noImplicitAny 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)"
echo "Typescript errors: $ERROR_COUNT"
echo "Directives: $DIRECTIVES"
echo "Controllers: $CONTROLLERS"
echo -e "Typescript errors: $ERROR_COUNT"
echo -e "Directives: $DIRECTIVES"
echo -e "Controllers: $CONTROLLERS"
curl \
-d "{\"metrics\": {
......@@ -21,10 +21,12 @@ curl \
-u ci:$CIRCLE_STATS_PWD \
-X POST https://stats.grafana.org/metric-receiver
curl https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics \
-H 'Content-type: application/json' \
-d '[
{"name":"grafana.ci-code.noImplicitAny", "interval":60, "value": '$ERROR_COUNT', "mtype": "gauge", "time": '$(date +%s)'},
{"name":"grafana.ci-code.directives", "interval":60, "value": '$DIRECTIVES', "mtype": "gauge", "time": '$(date +%s)'},
{"name":"grafana.ci-code.controllers", "interval":60, "value": '$CONTROLLERS', "mtype": "gauge", "time": '$(date +%s)'}
]'
echo -e ""
./scripts/ci-metrics-publisher.sh \
grafana.ci-code.noImplicitAny=$ERROR_COUNT \
grafana.ci-code.directives=$DIRECTIVES \
grafana.ci-code.controllers=$CONTROLLERS \
#!/bin/bash
echo "Publishing CI Metrics"
data=""
for ((i = 1; i <= $#; i++ )); do
remainder="${!i}"
first="${remainder%%=*}"; remainder="${remainder#*=}"
if [ -n "$data" ]; then
data="$data,"
fi
data=''$data'{"name": "'${first}'", "value": '${remainder}', "interval": 60, "mtype": "gauge", "time": '$(date +%s)'}'
done
curl https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics \
-H 'Content-type: application/json' \
-d "[$data]"
#!/bin/bash
function exit_if_fail {
command=$@
echo "Executing '$command'"
......@@ -10,11 +11,16 @@ function exit_if_fail {
fi
}
start=$(date +%s)
exit_if_fail npm run prettier:check
exit_if_fail npm run test
# exit_if_fail npm run test
end=$(date +%s)
seconds=$((end - start))
# if [ "${CIRCLE_BRANCH}" == "master" ]; then
exit_if_fail ./scripts/ci-frontend-metrics.sh
exit_if_fail ./scripts/ci-metrics-publisher.sh grafana.ci-performance.frontend-tests=$seconds
# fi
# On master also collect some and send some metrics
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "${branch}" == "master" ]; then
exit_if_fail ./scripts/circle-metrics.sh
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment