Skip to content

Commit 7f33f89

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 37381a3 commit 7f33f89

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

.github/workflows/deps.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,20 @@ 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: "tests/e2e/go.mod must use Go version major.minor.0"
58+
env:
59+
GO_MOD_FILE: go.mod
60+
run: |
61+
test $(grep "^go " $GO_MOD_FILE | awk '{print $2}' | cut -d. -f3) != 0 && exit 1
62+
- name: "tests/e2e/go.mod must use Go version major.minor.0"
63+
env:
64+
GO_MOD_FILE: tests/e2e/go.mod
65+
run: |
66+
test $(grep "^go " $GO_MOD_FILE | awk '{print $2}' | cut -d. -f3) != 0 && exit 1

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SHELL := /bin/bash
1818
GOOS ?= $(shell go env GOOS)
1919
GOARCH ?= $(shell go env GOARCH)
2020
GOPROXY ?= $(shell go env GOPROXY)
21+
GO_DIRECTIVE_VERSION ?= 1.24.0
2122
GIT_VERSION ?= $(shell git describe --dirty --tags --match='v*')
2223
VERSION ?= $(GIT_VERSION)
2324
IMAGE_REPOSITORY ?= provider-aws/cloud-controller-manager
@@ -120,7 +121,7 @@ e2e.test:
120121
mv tests/e2e/e2e.test e2e.test
121122

122123
.PHONY: check
123-
check: verify-fmt verify-lint vet
124+
check: verify-fmt verify-lint vet verify-go-directive
124125

125126
.PHONY: develop
126127
develop: aws-cloud-controller-manager test update-fmt check
@@ -142,6 +143,12 @@ verify-lint:
142143
verify-codegen:
143144
./hack/verify-codegen.sh
144145

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

0 commit comments

Comments
 (0)