mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
./test: Add PASSES="mod_tidy" check
Added check that ensures that go.mod & go.sum files are up-to-date. The check verifies whether 'go mod tidy' does not generate any mutations in these files. The check can be run on its own: PASSES="mod_tidy" ./test Or as part of "fmt" pass: PASSES="fmt" ./test Examplar outputs: ``` % PASSES="fmt" ./test Running with TEST_CPUS: 1,2,4 Starting 'fmt' pass at Fri 11 Sep 2020 11:07:54 PM CEST 'shellcheck' started at Fri 11 Sep 2020 11:07:54 PM CEST 'shellcheck' completed at Fri 11 Sep 2020 11:07:54 PM CEST 'markdown_you' started at Fri 11 Sep 2020 11:07:54 PM CEST 'markdown_you' completed at Fri 11 Sep 2020 11:07:54 PM CEST 'goword' started at Fri 11 Sep 2020 11:07:54 PM CEST 'goword' completed at Fri 11 Sep 2020 11:07:54 PM CEST 'gofmt' started at Fri 11 Sep 2020 11:07:54 PM CEST 'gofmt' completed at Fri 11 Sep 2020 11:07:55 PM CEST 'govet' started at Fri 11 Sep 2020 11:07:55 PM CEST 'govet' completed at Fri 11 Sep 2020 11:07:57 PM CEST 'revive' started at Fri 11 Sep 2020 11:07:57 PM CEST Skipping revive... 'revive' completed at Fri 11 Sep 2020 11:07:57 PM CEST 'license_header' started at Fri 11 Sep 2020 11:07:57 PM CEST 'license_header' completed at Fri 11 Sep 2020 11:07:58 PM CEST 'receiver_name' started at Fri 11 Sep 2020 11:07:58 PM CEST 'receiver_name' completed at Fri 11 Sep 2020 11:07:58 PM CEST 'commit_title' started at Fri 11 Sep 2020 11:07:58 PM CEST 'commit_title' completed at Fri 11 Sep 2020 11:07:58 PM CEST 'mod_tidy' started at Fri 11 Sep 2020 11:07:58 PM CEST *** /tmp/fileiALKRA_go.mod 2020-09-11 23:07:58.838010716 +0200 --- ./go.mod 2020-09-11 23:07:58.974010922 +0200 *************** *** 29,39 **** github.com/mattn/go-runewidth v0.0.2 // indirect github.com/modern-go/reflect2 v1.0.1 github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5 github.com/prometheus/client_golang v1.0.0 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 - github.com/prometheus/common v0.4.1 github.com/sirupsen/logrus v1.4.2 // indirect github.com/soheilhy/cmux v0.1.4 github.com/spf13/cobra v0.0.3 github.com/spf13/pflag v1.0.1 github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 --- 29,38 ---- ./go.mod is not in sync with 'go mod tidy' ``` ``` % PASSES="mod_tidy" ./test Running with TEST_CPUS: 1,2,4 Starting 'mod_tidy' pass at Fri 11 Sep 2020 11:09:21 PM CEST *** /tmp/file9gy4so_go.mod 2020-09-11 23:09:21.166133290 +0200 --- ./go.mod 2020-09-11 23:09:21.286133466 +0200 *************** *** 29,39 **** github.com/mattn/go-runewidth v0.0.2 // indirect github.com/modern-go/reflect2 v1.0.1 github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5 github.com/prometheus/client_golang v1.0.0 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 - github.com/prometheus/common v0.4.1 github.com/sirupsen/logrus v1.4.2 // indirect github.com/soheilhy/cmux v0.1.4 github.com/spf13/cobra v0.0.3 github.com/spf13/pflag v1.0.1 github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 --- 29,38 ---- ./go.mod is not in sync with 'go mod tidy' ```
This commit is contained in:
parent
0f195baca1
commit
aa10b1ee7f
14
.travis.yml
14
.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
|
||||
|
@ -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
|
||||
|
35
test
35
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 "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user