From cf9d306965db073e2d727597080a1dcfcc73c6ed Mon Sep 17 00:00:00 2001
From: oraz <oraz@redhat.com>
Date: Tue, 31 Dec 2024 12:38:21 +0200
Subject: [PATCH] Add go-verify target

Test go depedencies on test target by adding the go-verify target
---
 Makefile | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 904ad32d..c0aedc22 100644
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@ ENVTEST = $(shell pwd)/bin/setup-envtest
 # Use TEST_OPS to pass further options to `go test` (e.g. -gingo.v and/or -ginkgo.focus)
 export TEST_OPS ?= ""
 .PHONY: test
-test: envtest generate fix-imports manifests fmt vet ## Run tests.
+test: go-verify envtest generate fix-imports manifests fmt vet ## Run tests.
 	KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/testbin)" \
 		KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT="60s"\
 		go test ./api/... ./controllers/... ./pkg/... -coverprofile cover.out -v ${TEST_OPS}
@@ -488,18 +488,22 @@ container-build: docker-build bundle-build ## Build containers
 container-push: ## Push containers (NOTE: catalog can't be build before bundle was pushed)
 	make docker-push bundle-push catalog-build catalog-push
 
+.PHONY: tidy
+tidy: # Run go mod tidy - add missing and remove unused modules.
+	go mod tidy
+
 .PHONY: vendor
-vendor: ## Runs go mod vendor
+vendor: # Run go mod vendor - make vendored copy of dependencies.
 	go mod vendor
 
-.PHONY: tidy
-tidy: ## Runs go mod tidy
-	go mod tidy
+.PHONY: go-verify
+go-verify: tidy vendor # Run go mod verify - verify dependencies have expected content
+	go mod verify
 
-.PHONY:verify-vendor
-verify-vendor: tidy vendor verify-no-changes ##Verifies vendor and tidy didn't cause changes
+.PHONY: verify-vendor
+verify-vendor: go-verify verify-no-changes ##Verifies vendor and tidy didn't cause changes
 
-.PHONY:verify-bundle
+.PHONY: verify-bundle
 verify-bundle: manifests bundle bundle-reset verify-no-changes ##Verifies bundle and manifests didn't cause changes
 
 # Revert all version or build date related changes