2016-09-14 16:16:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
function exit_if_fail {
|
|
|
|
|
command=$@
|
|
|
|
|
echo "Executing '$command'"
|
|
|
|
|
eval $command
|
|
|
|
|
rc=$?
|
|
|
|
|
if [ $rc -ne 0 ]; then
|
|
|
|
|
echo "'$command' returned $rc."
|
|
|
|
|
exit $rc
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-06 15:55:22 +01:00
|
|
|
echo "running go fmt"
|
2017-01-27 12:41:05 +01:00
|
|
|
exit_if_fail test -z "$(gofmt -s -l ./pkg | tee /dev/stderr)"
|
2017-02-06 15:55:22 +01:00
|
|
|
|
|
|
|
|
echo "running go vet"
|
2017-02-05 21:21:05 +01:00
|
|
|
exit_if_fail test -z "$(go vet ./pkg/... | tee /dev/stderr)"
|
2017-02-06 15:55:22 +01:00
|
|
|
|
2017-10-23 09:06:08 +02:00
|
|
|
echo "building backend with install to cache pkgs"
|
|
|
|
|
exit_if_fail time go install ./pkg/cmd/grafana-server
|
2016-09-15 13:52:38 +02:00
|
|
|
|
2017-02-24 09:22:57 +01:00
|
|
|
echo "running go test"
|
2018-04-17 09:00:55 +02:00
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
echo "" > coverage.txt
|
|
|
|
|
|
|
|
|
|
time for d in $(go list ./pkg/...); do
|
|
|
|
|
exit_if_fail go test -coverprofile=profile.out -covermode=atomic $d
|
|
|
|
|
if [ -f profile.out ]; then
|
|
|
|
|
cat profile.out >> coverage.txt
|
|
|
|
|
rm profile.out
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "Publishing go code coverage"
|
|
|
|
|
bash <(curl -s https://codecov.io/bash) -cF go
|