circle-test-backend.sh 738 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. function exit_if_fail {
  3. command=$@
  4. echo "Executing '$command'"
  5. eval $command
  6. rc=$?
  7. if [ $rc -ne 0 ]; then
  8. echo "'$command' returned $rc."
  9. exit $rc
  10. fi
  11. }
  12. echo "running go fmt"
  13. exit_if_fail test -z "$(gofmt -s -l ./pkg | tee /dev/stderr)"
  14. echo "building backend with install to cache pkgs"
  15. exit_if_fail time go install ./pkg/cmd/grafana-server
  16. echo "running go test"
  17. set -e
  18. echo "" > coverage.txt
  19. time for d in $(go list ./pkg/...); do
  20. exit_if_fail go test -coverprofile=profile.out -covermode=atomic $d
  21. if [ -f profile.out ]; then
  22. cat profile.out >> coverage.txt
  23. rm profile.out
  24. fi
  25. done
  26. echo "Publishing go code coverage"
  27. bash <(curl -s https://codecov.io/bash) -cF go