test: add coveralls support
This commit is contained in:
parent
18874aac7d
commit
229ec3602d
@ -29,6 +29,9 @@ matrix:
|
|||||||
install:
|
install:
|
||||||
- go get github.com/onsi/ginkgo/ginkgo
|
- go get github.com/onsi/ginkgo/ginkgo
|
||||||
- go get github.com/containernetworking/cni/cnitool
|
- go get github.com/containernetworking/cni/cnitool
|
||||||
|
- go get golang.org/x/tools/cmd/cover
|
||||||
|
- go get github.com/modocache/gover
|
||||||
|
- go get github.com/mattn/goveralls
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
|
@ -6,35 +6,53 @@
|
|||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# switch into the repo root directory
|
||||||
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
|
# Build all plugins before testing
|
||||||
source ./build_linux.sh
|
source ./build_linux.sh
|
||||||
|
|
||||||
echo "Running tests"
|
echo "Running tests"
|
||||||
|
|
||||||
GINKGO_FLAGS="-p --randomizeAllSpecs --randomizeSuites --failOnPending --progress --skipPackage=pkg/hns"
|
function testrun {
|
||||||
|
sudo -E bash -c "umask 0; cd ${GOPATH}/src; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} go test $@"
|
||||||
|
}
|
||||||
|
|
||||||
# user has not provided PKG override
|
COVERALLS=${COVERALLS:-""}
|
||||||
if [ -z "$PKG" ]; then
|
|
||||||
GINKGO_FLAGS="$GINKGO_FLAGS -r ."
|
|
||||||
LINT_TARGETS="./..."
|
|
||||||
|
|
||||||
# user has provided PKG override
|
if [ -n "${COVERALLS}" ]; then
|
||||||
|
echo "with coverage profile generation..."
|
||||||
else
|
else
|
||||||
GINKGO_FLAGS="$GINKGO_FLAGS $PKG"
|
echo "without coverage profile generation..."
|
||||||
LINT_TARGETS="$PKG"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo -E bash -c "umask 0; cd ${GOPATH}/src/${REPO_PATH}; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} ginkgo ${GINKGO_FLAGS}"
|
PKG=${PKG:-$(cd ${GOPATH}/src/${REPO_PATH}; go list ./... | xargs echo)}
|
||||||
|
|
||||||
|
# coverage profile only works per-package
|
||||||
|
i=0
|
||||||
|
for t in ${PKG}; do
|
||||||
|
if [ -n "${COVERALLS}" ]; then
|
||||||
|
COVERFLAGS="-covermode set -coverprofile ${i}.coverprofile"
|
||||||
|
fi
|
||||||
|
testrun "${COVERFLAGS:-""} ${t}"
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Submit coverage information
|
||||||
|
if [ -n "${COVERALLS}" ]; then
|
||||||
|
gover
|
||||||
|
goveralls -service=travis-ci -coverprofile=gover.coverprofile
|
||||||
|
fi
|
||||||
|
|
||||||
cd ${GOPATH}/src/${REPO_PATH};
|
|
||||||
echo "Checking gofmt..."
|
echo "Checking gofmt..."
|
||||||
fmtRes=$(go fmt $LINT_TARGETS)
|
fmtRes=$(go fmt $PKG)
|
||||||
if [ -n "${fmtRes}" ]; then
|
if [ -n "${fmtRes}" ]; then
|
||||||
echo -e "go fmt checking failed:\n${fmtRes}"
|
echo -e "go fmt checking failed:\n${fmtRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking govet..."
|
echo "Checking govet..."
|
||||||
vetRes=$(go vet $LINT_TARGETS)
|
vetRes=$(go vet $PKG)
|
||||||
if [ -n "${vetRes}" ]; then
|
if [ -n "${vetRes}" ]; then
|
||||||
echo -e "govet checking failed:\n${vetRes}"
|
echo -e "govet checking failed:\n${vetRes}"
|
||||||
exit 255
|
exit 255
|
||||||
|
Loading…
x
Reference in New Issue
Block a user