From ac0c935b54d838861dae42cda844cc71410035f6 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Wed, 1 May 2019 03:02:31 +0930 Subject: [PATCH] travis: check for needed changes in go.mod and go.sum --- .travis.yml | 1 + .travis/script.d/check-generate.sh | 5 ----- .travis/script.d/deps.sh | 13 +++++++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae8fd527..0596658c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ os: env: global: - GO111MODULE=on + - GOFLAGS="-mod=readonly" matrix: - TAGS="" - TAGS="-tags bounds" diff --git a/.travis/script.d/check-generate.sh b/.travis/script.d/check-generate.sh index 1e1d1e5c..96a6d7bd 100755 --- a/.travis/script.d/check-generate.sh +++ b/.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 diff --git a/.travis/script.d/deps.sh b/.travis/script.d/deps.sh index d14b2071..4eafe9c7 100755 --- a/.travis/script.d/deps.sh +++ b/.travis/script.d/deps.sh @@ -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