You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ncdns/.travis/script

122 lines
3.8 KiB
Bash

#!/bin/bash
# Upstream q is broken, and this also causes dns-prop279 to be broken.
#travis_retry go get github.com/tcnksm/ghr github.com/mitchellh/gox gopkg.in/alecthomas/gometalinter.v2 github.com/miekg/exdns/q github.com/namecoin/dns-prop279
travis_retry go get github.com/tcnksm/ghr github.com/mitchellh/gox gopkg.in/alecthomas/gometalinter.v2
GOX_TAGS=""
if [ "${NO_NAMECOIN_TLS}" = "1" ]; then
GOX_TAGS="no_namecoin_tls"
fi
go test -tags "${GOX_TAGS}" -v ./...
RESULT=$?
echo Done tests with exit code $RESULT
if [ "$RESULT" != "0" ]; then
return $RESULT
fi
# Static analysis for TLS mode will cover non-TLS mode as well.
if [ "${NO_NAMECOIN_TLS}" != "1" ]; then
# Static analysis
gometalinter.v2 --install
# maligned 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/
# gofmt is disabled because it's a subset of goimports.
# test is disabled because we already do tests earlier in the script.
# The --exclude line disables warnings on the portion of x509 that is copied
# verbatim from the Go standard library.
echo ""
echo "gometalinter critical (should be no warnings):"
gometalinter.v2 --enable-all \
--disable=deadcode \
--disable=dupl \
--disable=errcheck \
--disable=gas \
--disable=gochecknoglobals \
--disable=gocyclo \
--disable=gofmt \
--disable=golint \
--disable=gosec \
--disable=ineffassign \
--disable=lll \
--disable=maligned \
--disable=megacheck \
--disable=nakedret \
--disable=staticcheck \
--disable=test \
--disable=unconvert \
--disable=unparam \
--disable=unused \
--concurrency=3 \
--deadline=10m \
--exclude='^x509/([a-wy-z]|x509.go|x509_[a-rt-z])' \
./...
STATICRESULT1=$?
echo ""
echo "gometalinter non-critical (warnings expected):"
gometalinter.v2 --enable-all \
--disable=maligned \
--disable=gofmt \
--disable=test \
--concurrency=3 \
--deadline=10m \
--exclude='^x509/([a-wy-z]|x509.go|x509_[a-rt-z])' \
./...
STATICRESULT2=$?
fi
# 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"
GOX_PARA=3
# Upstream q is broken, and this also causes dns-prop279 to be broken.
#REPOS="github.com/$TRAVIS_REPO_SLUG/... github.com/miekg/exdns/q github.com/namecoin/dns-prop279/..."
REPOS="github.com/$TRAVIS_REPO_SLUG/..."
# cgo crosscompile
gox -tags="$GOX_TAGS" -parallel=$GOX_PARA -cgo -osarch 'linux/386 linux/amd64' -output "$GOPATH/releasing/idist/ncdns-$TRAVIS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" $REPOS
RESULT1=$?
# non-cgo crosscompile
# darwin/386 was removed in Go 1.15
if [[ "$(go version)" =~ go1.[56789] ]]; then
GOX_OPTIONAL_TARGETS="darwin/386 "
elif [[ "$(go version)" =~ go1.1[01234] ]]; then
GOX_OPTIONAL_TARGETS="darwin/386 "
else
GOX_OPTIONAL_TARGETS=""
fi
gox -tags="$GOX_TAGS" -parallel=$GOX_PARA -osarch "${GOX_OPTIONAL_TARGETS}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
RESULT2=$?
echo cgo crosscompile exited with code $RESULT1
echo non-cgo crosscompile exited with code $RESULT2
if [ "${NO_NAMECOIN_TLS}" != "1" ]; then
echo critical gometalinter exited with code $STATICRESULT1
echo non-critical gometalinter exited with code $STATICRESULT2
fi
if [ "$RESULT1" != "0" ]; then
return $RESULT1
fi
if [ "$RESULT2" != "0" ]; then
return $RESULT2
fi
if [ "${NO_NAMECOIN_TLS}" != "1" ]; then
if [ "$STATICRESULT1" != "0" ]; then
return $STATICRESULT1
fi
fi