circle-metrics.sh 1.2 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. echo "Collecting code stats (typescript errors & more)"
  3. ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --noImplicitAny true | grep -oP 'Found \K(\d+)')"
  4. DIRECTIVES="$(grep -r -o directive public/app/**/* | wc -l)"
  5. CONTROLLERS="$(grep -r -oP 'class .*Ctrl' public/app/**/* | wc -l)"
  6. echo "Typescript errors: $ERROR_COUNT"
  7. echo "Directives: $DIRECTIVES"
  8. echo "Controllers: $CONTROLLERS"
  9. curl \
  10. -d "{\"metrics\": {
  11. \"ci.code.noImplicitAny\": $ERROR_COUNT,
  12. \"ci.code.directives\": $DIRECTIVES,
  13. \"ci.code.controllers\": $CONTROLLERS
  14. }
  15. }" \
  16. -H "Content-Type: application/json" \
  17. -u ci:$CIRCLE_STATS_PWD \
  18. -X POST https://stats.grafana.org/metric-receiver
  19. curl https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics \
  20. -H 'Content-type: application/json' \
  21. -d '[
  22. {"name":"grafana.ci-code.noImplicitAny", "interval":60, "value": '$ERROR_COUNT', "mtype": "gauge", "time": '$(date +%s)'},
  23. {"name":"grafana.ci-code.directives", "interval":60, "value": '$DIRECTIVES', "mtype": "gauge", "time": '$(date +%s)'},
  24. {"name":"grafana.ci-code.controllers", "interval":60, "value": '$CONTROLLERS', "mtype": "gauge", "time": '$(date +%s)'}
  25. ]'