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

This commit is contained in:
Dan Kortschak
2019-05-01 03:02:31 +09:30
committed by GitHub
parent 2a1643c79a
commit ac0c935b54
3 changed files with 14 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ os:
env:
global:
- GO111MODULE=on
- GOFLAGS="-mod=readonly"
matrix:
- TAGS=""
- TAGS="-tags bounds"

View File

@@ -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

View File

@@ -2,6 +2,14 @@
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