diff --git a/.travis.yml b/.travis.yml index 99471e800a7..db63faf3f96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,7 +95,7 @@ script: linux-amd64-functional) docker run --rm \ --volume=`pwd`:/go/src/go.etcd.io/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \ - /bin/bash -c "GO_BUILD_FLAGS='-v -mod=mod' ./build && GOARCH=amd64 PASSES='functional' ./test" + /bin/bash -c "GO_BUILD_FLAGS='-v -mod=readonly' ./build && GOARCH=amd64 PASSES='functional' ./test" ;; linux-amd64-unit) docker run --rm \ @@ -107,12 +107,12 @@ script: --volume=`pwd`:/go/src/go.etcd.io/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \ /bin/bash -c "GOARCH=amd64 PASSES='build' ./test \ && GOARCH=386 PASSES='build' ./test \ - && GO_BUILD_FLAGS='-v -mod=mod' GOOS=darwin GOARCH=amd64 ./build \ - && GO_BUILD_FLAGS='-v -mod=mod' GOOS=windows GOARCH=amd64 ./build \ - && GO_BUILD_FLAGS='-v -mod=mod' GOARCH=arm ./build \ - && GO_BUILD_FLAGS='-v -mod=mod' GOARCH=arm64 ./build \ - && GO_BUILD_FLAGS='-v -mod=mod' GOARCH=ppc64le ./build \ - && GO_BUILD_FLAGS='-v -mod=mod' GOARCH=s390x ./build" + && GO_BUILD_FLAGS='-v -mod=readonly' GOOS=darwin GOARCH=amd64 ./build \ + && GO_BUILD_FLAGS='-v -mod=readonly' GOOS=windows GOARCH=amd64 ./build \ + && GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=arm ./build \ + && GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=arm64 ./build \ + && GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=ppc64le ./build \ + && GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=s390x ./build" ;; linux-amd64-grpcproxy) sudo HOST_TMP_DIR=/tmp TEST_OPTS="PASSES='build grpcproxy'" make docker-test diff --git a/functional/build b/functional/build index 52ce832ee75..fd121eaf457 100755 --- a/functional/build +++ b/functional/build @@ -5,7 +5,7 @@ if ! [[ "$0" =~ "functional/build" ]]; then exit 255 fi -CGO_ENABLED=0 go build -v -mod=mod -installsuffix cgo -ldflags "-s" -o ./bin/etcd-agent ./functional/cmd/etcd-agent -CGO_ENABLED=0 go build -v -mod=mod -installsuffix cgo -ldflags "-s" -o ./bin/etcd-proxy ./functional/cmd/etcd-proxy -CGO_ENABLED=0 go build -v -mod=mod -installsuffix cgo -ldflags "-s" -o ./bin/etcd-runner ./functional/cmd/etcd-runner -CGO_ENABLED=0 go build -v -mod=mod -installsuffix cgo -ldflags "-s" -o ./bin/etcd-tester ./functional/cmd/etcd-tester +CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-agent ./functional/cmd/etcd-agent +CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-proxy ./functional/cmd/etcd-proxy +CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-runner ./functional/cmd/etcd-runner +CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-tester ./functional/cmd/etcd-tester diff --git a/test b/test index 1cf4c247a16..ae3ca76eb0e 100755 --- a/test +++ b/test @@ -393,6 +393,8 @@ function shellcheck_pass { echo -e "shellcheck checking failed:\\n${shellcheckResult}" exit 255 fi + else + echo "Shellcheck not found !!! Check: https://github.com/koalaman/shellcheck#installing" fi } @@ -627,6 +629,7 @@ function fmt_pass { license_header \ receiver_name \ commit_title \ + mod_tidy \ ; do echo "'$p' started at $(date)" "${p}"_pass "$@" @@ -684,6 +687,38 @@ function build_pass { GO_BUILD_FLAGS="-v" tools_build } +function mod_tidy_pass { + # Watch for upstream solution: https://github.com/golang/go/issues/27005 + local tmpModDir + tmpModDir=$(mktemp -d --suffix "etcd-mod") + cp "./go.mod" "./go.sum" "${tmpModDir}" + + go mod tidy + + set +e + local tmpFileGoModInSync + diff -C 5 "${tmpModDir}/go.mod" "./go.mod" + tmpFileGoModInSync="$?" + + local tmpFileGoSumInSync + diff -C 5 "${tmpModDir}/go.sum" "./go.sum" + tmpFileGoSumInSync="$?" + set -e + + # Bring back initial state + mv "${tmpModDir}/go.mod" "./go.mod" + mv "${tmpModDir}/go.sum" "./go.sum" + + if [ "${tmpFileGoModInSync}" -ne 0 ]; then + echo "./go.mod is not in sync with 'go mod tidy'" + exit 255 + fi + if [ "${tmpFileGoSumInSync}" -ne 0 ]; then + echo "./go.sum is not in sync with 'go mod tidy'" + exit 255 + fi +} + for pass in $PASSES; do echo "Starting '$pass' pass at $(date)" "${pass}"_pass "$@"