From fb3fe32ae96579d0b682880cb6b0c0595e985181 Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Wed, 19 Jun 2024 23:21:29 +0200 Subject: [PATCH 1/4] Fix dependency inconsistency detection and add make verify-dep Makefile's target `verify-dep` current behavior is to use `go list` to check consistent dependency versions from direct dependencies. Ignoring indirect dependencies in a multi-module project could lead to version mismatches. If module A imports module B, module B's dependency will be an indirect dependency in module A. Which can potentially have a version mismatch. Therefore, use `go mod edit` with indirect dependencies, too. So it can work with all dependencies defined in go.mod. Fix displaying dependencies with mismatches, as the old code was searching with grep just for the prefix, which would show other dependencies that shared the same prefix. Reference: - https://github.com/etcd-io/etcd/pull/18205 Signed-off-by: Ivan Valdes Signed-off-by: Chun-Hung Tseng --- Makefile | 6 +++++- test.sh | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8cfd790e002..928f9ac092e 100644 --- a/Makefile +++ b/Makefile @@ -582,12 +582,16 @@ gofail-disable: install-gofail PASSES="toggle_failpoints" ./test.sh .PHONY: verify -verify: verify-go-versions +verify: verify-go-versions verify-dep .PHONY: verify-go-versions verify-go-versions: ./scripts/verify_go_versions.sh +.PHONY: verify-dep +verify-dep: + PASSES="dep" ./test.sh 2<&1 + .PHONY: fix fix: sync-toolchain-directive ./scripts/fix.sh diff --git a/test.sh b/test.sh index a9c883e047c..e14bb424959 100755 --- a/test.sh +++ b/test.sh @@ -610,7 +610,7 @@ function dump_deps_of_module() { if ! module=$(run go list -m); then return 255 fi - run go list -f "{{if not .Indirect}}{{if .Version}}{{.Path}},{{.Version}},${module}{{end}}{{end}}" -m all + run go mod edit -json | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module}"'"' } # Checks whether dependencies are consistent across modules @@ -623,7 +623,7 @@ function dep_pass { for dup in ${duplicates}; do log_error "FAIL: inconsistent versions for depencency: ${dup}" - echo "${all_dependencies}" | grep "${dup}" | sed "s|\\([^,]*\\),\\([^,]*\\),\\([^,]*\\)| - \\1@\\2 from: \\3|g" + echo "${all_dependencies}" | grep "${dup}," | sed 's|\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\)| - \1@\2\3 from: \4|g' done if [[ -n "${duplicates}" ]]; then log_error "FAIL: inconsistent dependencies" From 5362dcec3dbc1fc1d61fcf37bf73ffcdd99b9674 Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Wed, 19 Jun 2024 23:28:12 +0200 Subject: [PATCH 2/4] dependency: bump github.com/google/go-cmp to the highest version v0.6.0 Signed-off-by: Chun-Hung Tseng --- raft/go.mod | 2 +- raft/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/raft/go.mod b/raft/go.mod index 1e386eda8db..f88e004e0cc 100644 --- a/raft/go.mod +++ b/raft/go.mod @@ -12,7 +12,7 @@ require ( ) require ( - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect google.golang.org/protobuf v1.33.0 // indirect ) diff --git a/raft/go.sum b/raft/go.sum index e984a081655..f093e2cf213 100644 --- a/raft/go.sum +++ b/raft/go.sum @@ -4,8 +4,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= From 9e4c045a08e8b0f0364e0132d6cb63f6889736af Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Wed, 19 Jun 2024 23:29:39 +0200 Subject: [PATCH 3/4] dependency: bump github.com/modern-go/concurrent to the highest version v0.0.0-20180306012644-bacd9c7ef1dd Signed-off-by: Chun-Hung Tseng --- client/v2/go.mod | 2 +- client/v2/go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/v2/go.mod b/client/v2/go.mod index 0c1e34bbb3a..4cdd80cdad7 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -13,7 +13,7 @@ require ( require ( github.com/coreos/go-semver v0.3.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect ) replace ( diff --git a/client/v2/go.sum b/client/v2/go.sum index 45edf6fc36e..429a4722146 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -6,8 +6,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= From 49a0263016907e00f38d0cadb860c790d983b249 Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Wed, 19 Jun 2024 23:30:38 +0200 Subject: [PATCH 4/4] dependency: dump golang.org/x/sys to the highest version v0.18.0 Signed-off-by: Chun-Hung Tseng --- client/pkg/go.mod | 2 +- client/pkg/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/pkg/go.mod b/client/pkg/go.mod index 06c1138da67..bfac9f0d2a0 100644 --- a/client/pkg/go.mod +++ b/client/pkg/go.mod @@ -8,7 +8,7 @@ require ( github.com/coreos/go-systemd/v22 v22.3.2 github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.17.0 - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad + golang.org/x/sys v0.18.0 ) require ( diff --git a/client/pkg/go.sum b/client/pkg/go.sum index e7f8c92cfdf..3eb65292d4c 100644 --- a/client/pkg/go.sum +++ b/client/pkg/go.sum @@ -19,8 +19,8 @@ go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=