2015-12-06 05:28:47 +00:00
#!/bin/bash
2017-11-03 04:32:01 +00:00
travis_retry go get github.com/tcnksm/ghr github.com/mitchellh/gox gopkg.in/alecthomas/gometalinter.v1 github.com/miekg/exdns/q github.com/namecoin/dns-prop279
2015-12-06 05:32:18 +00:00
2015-12-06 05:28:47 +00:00
go test -v ./...
RESULT=$?
echo Done tests with exit code $RESULT
if [ "$RESULT" != "0" ]; then
return $RESULT
fi
2017-07-14 02:23:31 +00:00
# Static analysis
gometalinter.v1 --install
2017-11-04 19:55:47 +00:00
# aligncheck is disabled because of these comments:
# * https://www.reddit.com/r/golang/comments/3lahav/aligncheck_helps_to_find_inefficiently_packed/cv4u4lg/
# * https://www.reddit.com/r/golang/comments/3lahav/aligncheck_helps_to_find_inefficiently_packed/cv5wnom/
2017-07-28 02:38:10 +00:00
# The --exclude line disables warnings on the portion of x509 that is copied
# verbatim from the Go standard library.
2017-07-14 02:23:31 +00:00
echo ""
echo "gometalinter critical (should be no warnings):"
gometalinter.v1 --enable-all \
--disable=aligncheck \
--disable=deadcode \
--disable=dupl \
--disable=errcheck \
--disable=gas \
--disable=gocyclo \
--disable=goimports \
--disable=golint \
--disable=ineffassign \
--disable=lll \
--disable=misspell \
--disable=staticcheck \
--disable=unconvert \
--disable=unparam \
--disable=unused \
--concurrency=3 \
--deadline=10m \
2017-07-28 02:38:10 +00:00
--exclude='^x509/([a-wy-z]|x509.go|x509_[a-rt-z])' \
2017-07-14 02:23:31 +00:00
./...
STATICRESULT1=$?
echo ""
echo "gometalinter non-critical (warnings expected):"
gometalinter.v1 --enable-all \
--concurrency=3 \
--deadline=10m \
2017-07-28 02:38:10 +00:00
--exclude='^x509/([a-wy-z]|x509.go|x509_[a-rt-z])' \
2017-07-14 02:23:31 +00:00
./...
STATICRESULT2=$?
2015-12-06 05:28:47 +00:00
# Test cross-compilation. The binaries produced are also used for release
# upload in after_success if this is a release tag.
echo Cross-compiling releases...
mkdir -p "$GOPATH/releasing/idist" "$GOPATH/releasing/dist"
2017-09-14 05:13:57 +00:00
GOX_PARA=3
2017-07-01 09:29:11 +00:00
2017-11-03 04:32:01 +00:00
REPOS="github.com/$TRAVIS_REPO_SLUG/... github.com/miekg/exdns/q github.com/namecoin/dns-prop279/..."
2017-11-03 04:18:01 +00:00
# cgo crosscompile
2017-07-01 09:29:11 +00:00
gox -parallel=$GOX_PARA -cgo -osarch 'linux/386 linux/amd64' -output "$GOPATH/releasing/idist/ncdns-$TRAVIS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" $REPOS
2015-12-06 05:28:47 +00:00
RESULT1=$?
# non-cgo crosscompile
2017-07-01 09:29:11 +00:00
gox -parallel=$GOX_PARA -osarch 'darwin/386 darwin/amd64 linux/arm linux/arm64 linux/ppc64 linux/ppc64le freebsd/386 freebsd/amd64 freebsd/arm openbsd/386 openbsd/amd64 netbsd/386 netbsd/amd64 netbsd/arm dragonfly/amd64 solaris/amd64 windows/386 windows/amd64' -output "$GOPATH/releasing/idist/ncdns-$TRAVIS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" $REPOS
2015-12-06 05:28:47 +00:00
RESULT2=$?
echo cgo crosscompile exited with code $RESULT1
echo non-cgo crosscompile exited with code $RESULT2
2017-07-14 02:23:31 +00:00
echo critical gometalinter exited with code $STATICRESULT1
echo non-critical gometalinter exited with code $STATICRESULT2
2015-12-06 05:28:47 +00:00
if [ "$RESULT1" != "0" ]; then
return $RESULT1
fi
if [ "$RESULT2" != "0" ]; then
return $RESULT2
fi
2017-07-14 02:23:31 +00:00
if [ "$STATICRESULT1" != "0" ]; then
return $STATICRESULT1
fi