From ef7d44f5b7c1cb3dfaf1a58e37f25c0a53f5f518 Mon Sep 17 00:00:00 2001 From: Marco Braga Date: Fri, 24 Oct 2025 10:09:19 -0300 Subject: [PATCH] ci/gha: introduce step to check go.mod version Introduce the step to validate if the go.mod is in conformance with Kubernetes project standard by using the patch version from the build env (ending with .0, x.y.0). --- .github/workflows/deps.yml | 10 ++++++++++ Makefile | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deps.yml b/.github/workflows/deps.yml index e391216b90..e837984e87 100644 --- a/.github/workflows/deps.yml +++ b/.github/workflows/deps.yml @@ -47,3 +47,13 @@ jobs: uses: golang/govulncheck-action@v1 with: go-version-file: tests/e2e/go.mod + gomod-dotzero-check: + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v4 + with: + show-progress: false + - name: "Go directive must use Go version major.minor.0" + run: | + make verify-go-directive \ No newline at end of file diff --git a/Makefile b/Makefile index f3b597fa59..e759caab4f 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ OUTPUT ?= $(shell pwd)/_output INSTALL_PATH ?= $(OUTPUT)/bin LDFLAGS ?= -w -s -X k8s.io/component-base/version.gitVersion=$(VERSION) -X main.gitVersion=$(VERSION) +GOLANG_DIRECTIVE_VERSION ?= 1.24.0 +CURL_RETRIES ?= 3 + # flags for ecr-credential-provider artifact promotion UPLOAD ?= $(OUTPUT)/upload GCS_LOCATION ?= gs://k8s-staging-provider-aws/releases/ @@ -120,7 +123,7 @@ e2e.test: mv tests/e2e/e2e.test e2e.test .PHONY: check -check: verify-fmt verify-lint vet +check: verify-fmt verify-lint vet verify-go-directive .PHONY: develop develop: aws-cloud-controller-manager test update-fmt check @@ -142,6 +145,12 @@ verify-lint: verify-codegen: ./hack/verify-codegen.sh +.PHONY: verify-go-directive +verify-go-directive: + # use the core Cluster API script directly to verify the go directive matches the desired one. + # ref: https://github.com/kubernetes-sigs/cluster-api/blob/v1.10.7/hack/verify-go-directive.sh + curl --retry $(CURL_RETRIES) -fsL https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/refs/tags/v1.11.0/hack/verify-go-directive.sh | bash -s -- -g $(GOLANG_DIRECTIVE_VERSION) + .PHONY: vet vet: go vet ./...