circle-test-backend.sh 927 B

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