travis: check for needed changes in go.mod and go.sum
MODIFY
.travis.yml
.travis.yml
@@ -18,6 +18,7 @@ os:
env:
global:
- GO111MODULE=on
+ - GOFLAGS="-mod=readonly"
matrix:
- TAGS=""
- TAGS="-tags bounds"

MODIFY
.travis/script.d/check-generate.sh
.travis/script.d/check-generate.sh
@@ -6,11 +6,6 @@ go generate gonum.org/v1/gonum/unit
go generate gonum.org/v1/gonum/unit/constant
go generate gonum.org/v1/gonum/graph/formats/dot
-# Discard changes to go.mod that have been made.
-# FIXME(kortschak): Sort out a policy of what we should do with go.mod changes.
-# If we want to check changes we should set `GOFLAGS=-mod=readonly` in .travis.yml.
-git checkout -- go.{mod,sum}
-
if [ -n "$(git diff)" ]; then
git diff
exit 1

MODIFY
.travis/script.d/deps.sh
.travis/script.d/deps.sh
set -ex
+# Avoid contaminating the go.mod/go.sum files.
+WORK=$(mktemp -d)
+pushd $WORK
+
+# Work around go1.11 issue where go get will not work outside a module.
+# TODO(kortschak): Remove when go1.11 is no longer supported.
+go mod init fake || true
+
# Required for format check.
go get golang.org/x/tools/cmd/goimports
# Required for imports check.
@@ -13,3 +21,8 @@ go get golang.org/x/tools/cmd/cover
go get github.com/mattn/goveralls
# Required for dot parser checks.
${TRAVIS_BUILD_DIR}/.travis/script.d/install-gocc.sh 66c61e91b3657c517a6f89d2837d370e61fb9430
+
+# Clean up.
+# TODO(kortschak): Remove when go1.11 is no longer supported.
+popd
+rm -rf $WORK

travis: check for needed changes in go.mod and go.sum