diff --git a/Makefile b/Makefile index 2c5112d248..0fe4ec0afa 100644 --- a/Makefile +++ b/Makefile @@ -48,14 +48,9 @@ install-lll: check-fmt: install-lll etc/check_fmt.sh -# check-modules runs "go mod tidy" and exits with a non-zero exit code if there -# are any module changes. The intent is to confirm that exactly the required -# modules are declared as dependencies. We should always be able to run "go mod -# tidy" and expect that no unrelated changes are made to the "go.mod" file. .PHONY: check-modules check-modules: - go mod tidy -v - git diff --exit-code go.mod go.sum + etc/check_modules.sh .PHONY: doc doc: diff --git a/etc/check_modules.sh b/etc/check_modules.sh new file mode 100755 index 0000000000..da0cb6e751 --- /dev/null +++ b/etc/check_modules.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# check-modules runs "go mod tidy" on each module and exits with a non-zero exit code if there +# are any module changes. The intent is to confirm that exactly the required +# modules are declared as dependencies. We should always be able to run "go mod +# tidy" and expect that no unrelated changes are made to the "go.mod" file. +set -eu + +mods=$(find . -name go.mod) +for mod in $mods; do + pushd $(dirname $mod) > /dev/null + echo "Checking $mod..." + go mod tidy -v + git diff --exit-code go.mod go.sum + echo "Checking $mod... done" + popd > /dev/null +done