2016-03-20 11:54:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Issue: https://github.com/mattn/goveralls/issues/20
|
|
|
|
# Source: https://github.com/uber/go-torch/blob/63da5d33a225c195fea84610e2456d5f722f3963/.test-cover.sh
|
2017-11-14 18:33:28 +00:00
|
|
|
CI=$1
|
|
|
|
echo "run for $CI"
|
|
|
|
|
|
|
|
if [ "$CI" == "circle-ci" ]; then
|
|
|
|
cd ${GOPATH}/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
|
|
|
|
fi
|
2016-03-20 11:54:40 +00:00
|
|
|
|
|
|
|
echo "mode: count" > profile.cov
|
|
|
|
FAIL=0
|
|
|
|
|
|
|
|
# Standard go tooling behavior is to ignore dirs with leading underscors
|
|
|
|
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d);
|
|
|
|
do
|
|
|
|
if ls $dir/*.go &> /dev/null; then
|
|
|
|
go test -v -covermode=count -coverprofile=profile.tmp $dir || FAIL=$?
|
|
|
|
if [ -f profile.tmp ]
|
|
|
|
then
|
|
|
|
tail -n +2 < profile.tmp >> profile.cov
|
|
|
|
rm profile.tmp
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Failures have incomplete results, so don't send
|
|
|
|
if [ "$FAIL" -eq 0 ]; then
|
2017-11-14 18:33:28 +00:00
|
|
|
goveralls -service=$CI -v -coverprofile=profile.cov
|
2017-10-13 10:59:26 +00:00
|
|
|
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov
|
2016-03-20 11:54:40 +00:00
|
|
|
fi
|
|
|
|
|
2017-12-31 04:28:03 +00:00
|
|
|
# Test if every package has testfiles
|
|
|
|
for dir in $(find . -name "*.go" -printf '%h\0'| sort -zu | sed -z 's/$/\n/');
|
|
|
|
do
|
|
|
|
if [ "$(ls $dir/*_test.go 2> /dev/null | wc -l)" -eq "0" ]; then
|
|
|
|
echo -n "no test files for $dir";
|
|
|
|
case $dir in
|
|
|
|
'.' | './cmd' | './database/graphite')
|
|
|
|
echo " - but ignored";
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "";
|
|
|
|
FAIL=1;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-03-20 11:54:40 +00:00
|
|
|
exit $FAIL
|