diff --git a/.travis.yml b/.travis.yml index f056a60fec..351ab8ee03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ go: # add TF_ETCDV3_TEST=1 to run etcdv3 tests # if added, TF_ETCDV3_ENDPOINTS must be set to a comma-separated list of (insecure) etcd endpoints against which to test env: - - CONSUL_VERSION=0.7.5 GOMAXPROCS=4 + - CONSUL_VERSION=0.7.5 GOMAXPROCS=4 GO111MODULE=on # Fetch consul for the backend and provider tests before_install: diff --git a/Makefile b/Makefile index a4170404d7..1fc9488699 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,9 @@ WEBSITE_REPO=github.com/hashicorp/terraform-website default: test tools: - go get -u github.com/kardianos/govendor - go get -u golang.org/x/tools/cmd/stringer - go get -u golang.org/x/tools/cmd/cover + GO111MODULE=off go get -u golang.org/x/tools/cmd/stringer + GO111MODULE=off go get -u golang.org/x/tools/cmd/cover + GO111MODULE=off go get -u github.com/golang/mock/mockgen # bin generates the releaseable binaries for Terraform bin: fmtcheck generate @@ -17,10 +17,10 @@ bin: fmtcheck generate # dev creates binaries for testing Terraform locally. These are put # into ./bin/ as well as $GOPATH/bin dev: fmtcheck generate - @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" + go install -mod=vendor . quickdev: generate - @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" + go install -mod=vendor . # Shorthand for building and installing just one plugin for local testing. # Run as (for example): make plugin-dev PLUGIN=provider-aws @@ -32,34 +32,34 @@ plugin-dev: generate # we run this one package at a time here because running the entire suite in # one command creates memory usage issues when running in Travis-CI. test: fmtcheck generate - go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=2m -parallel=4 + go list -mod=vendor $(TEST) | xargs -t -n4 go test $(TESTARGS) -mod=vendor -timeout=2m -parallel=4 # testacc runs acceptance tests testacc: fmtcheck generate @if [ "$(TEST)" = "./..." ]; then \ echo "ERROR: Set TEST to a specific package. For example,"; \ - echo " make testacc TEST=./builtin/providers/aws"; \ + echo " make testacc TEST=./builtin/providers/test"; \ exit 1; \ fi - TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m + TF_ACC=1 go test $(TEST) -v $(TESTARGS) -mod=vendor -timeout 120m # e2etest runs the end-to-end tests against a generated Terraform binary # The TF_ACC here allows network access, but does not require any special # credentials since the e2etests use local-only providers such as "null". e2etest: generate - TF_ACC=1 go test -v ./command/e2etest + TF_ACC=1 go test -mod=vendor -v ./command/e2etest test-compile: fmtcheck generate @if [ "$(TEST)" = "./..." ]; then \ echo "ERROR: Set TEST to a specific package. For example,"; \ - echo " make test-compile TEST=./builtin/providers/aws"; \ + echo " make test-compile TEST=./builtin/providers/test"; \ exit 1; \ fi - go test -c $(TEST) $(TESTARGS) + go test -mod=vendor -c $(TEST) $(TESTARGS) # testrace runs the race checker testrace: fmtcheck generate - TF_ACC= go test -race $(TEST) $(TESTARGS) + TF_ACC= go test -mod=vendor -race $(TEST) $(TESTARGS) cover: @go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \ @@ -71,12 +71,14 @@ cover: # generate runs `go generate` to build the dynamically generated # source files. -generate: - @which stringer > /dev/null; if [ $$? -ne 0 ]; then \ - go get -u golang.org/x/tools/cmd/stringer; \ - fi - go generate ./... - @go fmt command/internal_plugin_list.go > /dev/null +generate: tools + GOFLAGS=-mod=vendor go generate ./... + # go fmt doesn't support -mod=vendor but it still wants to populate the + # module cache with everything in go.mod even though formatting requires + # no dependencies, and so we're disabling modules mode for this right + # now until the "go fmt" behavior is rationalized to either support the + # -mod= argument or _not_ try to install things. + GO111MODULE=off go fmt command/internal_plugin_list.go > /dev/null fmt: gofmt -w $(GOFMT_FILES) @@ -84,9 +86,6 @@ fmt: fmtcheck: @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" -vendor-status: - @govendor status - website: ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." diff --git a/scripts/build.sh b/scripts/build.sh index 3ec98d727f..72af007ee0 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -47,6 +47,10 @@ if [[ -n "${TF_RELEASE}" ]]; then LD_FLAGS="-s -w" fi +# Ensure all remote modules are downloaded and cached before build so that +# the concurrent builds launched by gox won't race to redundantly download them. +go mod download + # Build! echo "==> Building..." gox \