Skip to content

Commit

Permalink
Add new makefile targets for go mod verification
Browse files Browse the repository at this point in the history
Run 'go mod' functions to search for tidy, vendor changes and verify it
  • Loading branch information
razo7 committed May 22, 2024
1 parent e88bd57 commit e002c6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ GATEKEEPER_VERSION = v3.10.0
GATEKEEPER_IMAGE ?= ${RP_IMAGE_ACR}.azurecr.io/gatekeeper:$(GATEKEEPER_VERSION)
GOTESTSUM = gotest.tools/[email protected]

# Golang version go mod tidy compatibility
GOLANG_VERSION ?= 1.20

ifneq ($(shell uname -s),Darwin)
export CGO_CFLAGS=-Dgpgme_off_t=off_t
endif
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 0 additions & 2 deletions hack/update-go-module-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,3 @@ done

go get -u ./...

go mod tidy -compat=1.20
go mod vendor

0 comments on commit e002c6e

Please sign in to comment.