circle-test.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. rm -rf node_modules
  14. npm install -g yarn --quiet
  15. yarn install --pure-lockfile --no-progress
  16. exit_if_fail npm run test-ci
  17. exit_if_fail npm run build
  18. # publish code coverage
  19. echo "Publishing javascript code coverage"
  20. bash <(curl -s https://codecov.io/bash) -cF javascript
  21. rm -rf coverage
  22. # npm install -g codecov
  23. # codecov
  24. # cat ./coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls.js
  25. echo "running go fmt"
  26. exit_if_fail test -z "$(gofmt -s -l ./pkg | tee /dev/stderr)"
  27. echo "running go vet"
  28. exit_if_fail test -z "$(go vet ./pkg/... | tee /dev/stderr)"
  29. echo "building binaries"
  30. exit_if_fail go run build.go build
  31. echo "running go test"
  32. set -e
  33. echo "" > coverage.txt
  34. for d in $(go list ./pkg/...); do
  35. exit_if_fail go test -race -coverprofile=profile.out -covermode=atomic $d
  36. if [ -f profile.out ]; then
  37. cat profile.out >> coverage.txt
  38. rm profile.out
  39. fi
  40. done
  41. echo "Publishing go code coverage"
  42. bash <(curl -s https://codecov.io/bash) -cF go