circle-test-backend.sh 822 B

123456789101112131415161718192021222324252627282930313233343536
  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 "running go vet"
  15. exit_if_fail test -z "$(go vet ./pkg/... | tee /dev/stderr)"
  16. echo "building backend with install to cache pkgs"
  17. exit_if_fail time go install ./pkg/cmd/grafana-server
  18. echo "running go test"
  19. set -e
  20. echo "" > coverage.txt
  21. time for d in $(go list ./pkg/...); do
  22. exit_if_fail go test -coverprofile=profile.out -covermode=atomic $d
  23. if [ -f profile.out ]; then
  24. cat profile.out >> coverage.txt
  25. rm profile.out
  26. fi
  27. done
  28. echo "Publishing go code coverage"
  29. bash <(curl -s https://codecov.io/bash) -cF go