2017-05-23 19:55:16 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-08-23 17:49:15 +00:00
|
|
|
|
2017-05-23 19:55:16 +00:00
|
|
|
set -ex
|
|
|
|
|
|
|
|
|
|
# The script does automatic checking on a Go package and its sub-packages,
|
|
|
|
|
# including:
|
2019-04-29 19:41:06 +00:00
|
|
|
# 1. gofmt (https://golang.org/cmd/gofmt/)
|
2018-08-23 17:49:15 +00:00
|
|
|
# 2. gosimple (https://github.com/dominikh/go-simple)
|
|
|
|
|
# 3. unconvert (https://github.com/mdempsky/unconvert)
|
|
|
|
|
# 4. ineffassign (https://github.com/gordonklaus/ineffassign)
|
2019-04-29 19:41:06 +00:00
|
|
|
# 5. go vet (https://golang.org/cmd/vet)
|
|
|
|
|
# 6. misspell (https://github.com/client9/misspell)
|
2017-05-23 19:55:16 +00:00
|
|
|
|
2019-08-16 22:37:58 +00:00
|
|
|
# golangci-lint (github.com/golangci/golangci-lint) is used to run each
|
2018-02-17 22:42:13 +00:00
|
|
|
# static checker.
|
2017-05-23 19:55:16 +00:00
|
|
|
|
2018-02-17 22:42:13 +00:00
|
|
|
REPO=dcrd
|
|
|
|
|
|
2019-07-17 19:46:46 +00:00
|
|
|
go version
|
|
|
|
|
|
|
|
|
|
# binary needed for RPC tests
|
|
|
|
|
env CC=gcc go build
|
2019-09-20 15:10:58 +00:00
|
|
|
cp "$REPO" "$(go env GOPATH)/bin/"
|
2019-07-17 19:46:46 +00:00
|
|
|
|
|
|
|
|
# run tests on all modules
|
|
|
|
|
ROOTPATH=$(go list -m)
|
|
|
|
|
ROOTPATHPATTERN=$(echo $ROOTPATH | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
|
|
|
|
|
MODPATHS=$(go list -m all | grep "^$ROOTPATHPATTERN" | cut -d' ' -f1)
|
|
|
|
|
for module in $MODPATHS; do
|
|
|
|
|
echo "==> ${module}"
|
|
|
|
|
env CC=gcc go test -short -tags rpctest ${module}/...
|
|
|
|
|
|
|
|
|
|
# check linters
|
|
|
|
|
MODNAME=$(echo $module | sed -E -e "s/^$ROOTPATHPATTERN//" \
|
|
|
|
|
-e 's,^/,,' -e 's,/v[0-9]+$,,')
|
|
|
|
|
if [ -z "$MODNAME" ]; then
|
|
|
|
|
MODNAME=.
|
|
|
|
|
fi
|
|
|
|
|
(cd $MODNAME && \
|
2019-07-22 00:29:24 +00:00
|
|
|
go mod download && \
|
2019-07-17 19:46:46 +00:00
|
|
|
golangci-lint run --build-tags=rpctest --disable-all --deadline=10m \
|
|
|
|
|
--enable=gofmt \
|
|
|
|
|
--enable=gosimple \
|
|
|
|
|
--enable=unconvert \
|
|
|
|
|
--enable=ineffassign \
|
|
|
|
|
--enable=govet \
|
|
|
|
|
--enable=misspell \
|
|
|
|
|
)
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "------------------------------------------"
|
|
|
|
|
echo "Tests completed successfully!"
|