Skip to content

Commit 13eba60

Browse files
committed
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).
1 parent bea9adf commit 13eba60

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/workflows/deps.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,13 @@ jobs:
4747
uses: golang/govulncheck-action@v1
4848
with:
4949
go-version-file: tests/e2e/go.mod
50+
gomod-dotzero-check:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: "Checkout Repository"
54+
uses: actions/checkout@v4
55+
with:
56+
show-progress: false
57+
- name: "Go directive must use Go version major.minor.0"
58+
run: |
59+
make verify-go-directive

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ OUTPUT ?= $(shell pwd)/_output
2626
INSTALL_PATH ?= $(OUTPUT)/bin
2727
LDFLAGS ?= -w -s -X k8s.io/component-base/version.gitVersion=$(VERSION) -X main.gitVersion=$(VERSION)
2828

29+
GOLANG_DIRECTIVE_VERSION ?= 1.24.0
30+
CURL_RETRIES ?= 3
31+
2932
# flags for ecr-credential-provider artifact promotion
3033
UPLOAD ?= $(OUTPUT)/upload
3134
GCS_LOCATION ?= gs://k8s-staging-provider-aws/releases/
@@ -120,7 +123,7 @@ e2e.test:
120123
mv tests/e2e/e2e.test e2e.test
121124

122125
.PHONY: check
123-
check: verify-fmt verify-lint vet
126+
check: verify-fmt verify-lint vet verify-go-directive
124127

125128
.PHONY: develop
126129
develop: aws-cloud-controller-manager test update-fmt check
@@ -142,6 +145,12 @@ verify-lint:
142145
verify-codegen:
143146
./hack/verify-codegen.sh
144147

148+
.PHONY: verify-go-directive
149+
verify-go-directive:
150+
# use the core Cluster API script directly to verify the go directive matches the desired one.
151+
# ref: https://github.com/kubernetes-sigs/cluster-api/blob/v1.10.7/hack/verify-go-directive.sh
152+
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)
153+
145154
.PHONY: vet
146155
vet:
147156
go vet ./...

0 commit comments

Comments
 (0)