TravisCI: Test and lint latest version modules.

The current approach of the CI tests of specifying the path to the
directory that contains the module only tests version 1 of the module
despite there being newer version available.  The same is true for the
lints.

This resolves the test portion by obtaining a list of all modules
required by the root go.mod file and providing the entire module path,
which includes the version, to the go test command instead of the
directory.

Unfortunately, the linter does not recognize full module paths, however
it will lint the latest module version from within the module directory
itself, so this resolves the linting case by stripping the full module
path and version down to the directory and changing into the directory
to perform the lint checks.
This commit is contained in:
Dave Collins 2019-06-26 19:29:41 -05:00
parent 1d133626ba
commit 9df07027ae
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -41,23 +41,28 @@ testrepo () {
cp "$REPO" "$GOPATH/bin/"
# run tests on all modules
ROOTPATH=$($GO list -m -f {{.Dir}} 2>/dev/null)
ROOTPATH=$($GO list -m)
ROOTPATHPATTERN=$(echo $ROOTPATH | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
MODPATHS=$($GO list -m -f {{.Dir}} all 2>/dev/null | grep "^$ROOTPATHPATTERN"\
| sed -e "s/^$ROOTPATHPATTERN//" -e 's/^\\//' -e 's/^\///')
MODPATHS=". $MODPATHS"
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}/...
env CC=gcc $GO test -short -tags rpctest ${module}/...
# check linters
golangci-lint run --build-tags rpctest --disable-all --deadline=10m \
--enable=gofmt \
--enable=gosimple \
--enable=unconvert \
--enable=ineffassign \
--enable=govet \
--enable=misspell ./${module}/...
MODNAME=$(echo $module | sed -e "s/^$ROOTPATHPATTERN//" \
-e 's/^\///' -e 's/\/v[0-9]\+$//')
if [ -z "$MODNAME" ]; then
MODNAME=.
fi
(cd $MODNAME && \
golangci-lint run --build-tags=rpctest --disable-all --deadline=10m \
--enable=gofmt \
--enable=gosimple \
--enable=unconvert \
--enable=ineffassign \
--enable=govet \
--enable=misspell \
)
done
echo "------------------------------------------"