diff --git a/.github/workflows/ci-go.yml b/.github/workflows/ci-go.yml index d55e553282b..cade78041fa 100644 --- a/.github/workflows/ci-go.yml +++ b/.github/workflows/ci-go.yml @@ -37,8 +37,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - run: | - go mod vendor - go mod tidy -compat=1.20 + make go-verify hack/ci-utils/isClean.sh generate-check: diff --git a/Makefile b/Makefile index a0953075d9e..42803ae621d 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,9 @@ GATEKEEPER_VERSION = v3.10.0 GATEKEEPER_IMAGE ?= ${RP_IMAGE_ACR}.azurecr.io/gatekeeper:$(GATEKEEPER_VERSION) GOTESTSUM = gotest.tools/gotestsum@v1.11.0 +# Golang version go mod tidy compatibility +GOLANG_VERSION ?= 1.20 + ifneq ($(shell uname -s),Darwin) export CGO_CFLAGS=-Dgpgme_off_t=off_t endif @@ -275,9 +278,22 @@ admin.kubeconfig: aks.kubeconfig: hack/get-admin-aks-kubeconfig.sh +.PHONY: go-tidy +go-tidy: # Run go mod tidy - add missing and remove unused modules. + go mod tidy -compat=${GOLANG_VERSION} + +.PHONY: go-vendor +go-vendor: # Run go mod vendor - only modules that are used in the source code will be vendored in (make vendored copy of dependencies). + go mod vendor + +.PHONY: go-verify +go-verify: go-tidy go-vendor # Run go mod verify - verify dependencies have expected content + go mod verify + vendor: # See comments in the script for background on why we need it hack/update-go-module-dependencies.sh + $(MAKE) go-verify install-go-tools: go install ${GOTESTSUM} diff --git a/hack/update-go-module-dependencies.sh b/hack/update-go-module-dependencies.sh index 454a676e82b..819ef5fa695 100755 --- a/hack/update-go-module-dependencies.sh +++ b/hack/update-go-module-dependencies.sh @@ -41,5 +41,3 @@ done go get -u ./... -go mod tidy -compat=1.20 -go mod vendor