ci-frontend-metrics.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. echo -e "Collecting code stats (typescript errors & more)"
  3. ERROR_COUNT_LIMIT=6843
  4. DIRECTIVES_LIMIT=173
  5. CONTROLLERS_LIMIT=137
  6. ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --noImplicitAny true | grep -oP 'Found \K(\d+)')"
  7. DIRECTIVES="$(grep -r -o directive public/app/**/* | wc -l)"
  8. CONTROLLERS="$(grep -r -oP 'class .*Ctrl' public/app/**/* | wc -l)"
  9. if [ $ERROR_COUNT -gt $ERROR_COUNT_LIMIT ]; then
  10. echo -e "Typescript errors $ERROR_COUNT exceeded $ERROR_COUNT_LIMIT so failing build"
  11. exit -1
  12. fi
  13. if [ $DIRECTIVES -gt $DIRECTIVES_LIMIT ]; then
  14. echo -e "Directive count $DIRECTIVES exceeded $DIRECTIVES_LIMIT so failing build"
  15. exit -1
  16. fi
  17. if [ $CONTROLLERS -gt $CONTROLLERS_LIMIT ]; then
  18. echo -e "Controllers count $CONTROLLERS exceeded $CONTROLLERS_LIMIT so failing build"
  19. exit -1
  20. fi
  21. echo -e "Typescript errors: $ERROR_COUNT"
  22. echo -e "Directives: $DIRECTIVES"
  23. echo -e "Controllers: $CONTROLLERS"
  24. if [ "${CIRCLE_BRANCH}" == "master" ]; then
  25. ./scripts/ci-metrics-publisher.sh \
  26. grafana.ci-code.noImplicitAny=$ERROR_COUNT \
  27. grafana.ci-code.directives=$DIRECTIVES \
  28. grafana.ci-code.controllers=$CONTROLLERS
  29. fi