From 3a1ac8502009a462f9dbea69df9db2d2f29d20b0 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 19 Mar 2024 13:46:47 +0200 Subject: [PATCH 1/5] Bump golang version to 1.22.1 Signed-off-by: Evan Lezar --- versions.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.mk b/versions.mk index 8a3872e7..c9dae147 100644 --- a/versions.mk +++ b/versions.mk @@ -28,7 +28,7 @@ NVIDIA_DOCKER_VERSION := 2.14.0 NVIDIA_CONTAINER_RUNTIME_VERSION := 3.14.0 CUDA_VERSION := 12.3.2 -GOLANG_VERSION := 1.20.5 +GOLANG_VERSION := 1.22.1 BUILDIMAGE_TAG ?= devel-go$(GOLANG_VERSION) BUILDIMAGE ?= ghcr.io/nvidia/k8s-test-infra:$(BUILDIMAGE_TAG) From 98ad835a776b87d3a45730af28913317ddaeb0e8 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 19 Mar 2024 13:48:58 +0200 Subject: [PATCH 2/5] Add vendor and check-vendor make targets Signed-off-by: Evan Lezar --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 629b978b..ed23ef09 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) CHECK_TARGETS := golangci-lint -MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate licenses $(CHECK_TARGETS) +MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate licenses vendor check-vendor $(CHECK_TARGETS) TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS) @@ -90,6 +90,14 @@ goimports: golangci-lint: golangci-lint run ./... +vendor: + go mod tidy + go mod vendor + go mod verify + +check-vendor: vendor + git diff --quiet HEAD -- go.mod go.sum vendor + licenses: go-licenses csv $(MODULE)/... From cc6cbd4a89220cc71b2faa1b58061392e97028ee Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 19 Mar 2024 13:49:15 +0200 Subject: [PATCH 3/5] Use versions.mk GOLANG version in CI Signed-off-by: Evan Lezar --- .github/workflows/golang.yaml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 38a77a33..fc5acb4b 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -16,6 +16,9 @@ name: Golang on: pull_request: + types: + - opened + - synchronize branches: - main - release-* @@ -29,28 +32,45 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + name: Checkout code + - name: Get Golang version + id: vars + run: | + GOLANG_VERSION=$( grep "GOLANG_VERSION :=" versions.mk ) + echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GOLANG_VERSION }} - name: Lint uses: golangci/golangci-lint-action@v4 with: version: latest args: -v --timeout 5m skip-cache: true + - name: Check golang modules + run: make check-vendor test: name: Unit test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 + - name: Get Golang version + id: vars + run: | + GOLANG_VERSION=$( grep "GOLANG_VERSION :=" versions.mk ) + echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV - name: Install Go uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: ${{ env.GOLANG_VERSION }} - run: make test build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + name: Checkout code - name: Build run: make docker-build From 3f7ed7c8db616546cb6f35df2b8c7c757613d7a3 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 19 Mar 2024 13:51:39 +0200 Subject: [PATCH 4/5] Rename golangci-lint target to lint Signed-off-by: Evan Lezar --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ed23ef09..b0b66b7d 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ EXAMPLE_TARGETS := $(patsubst %,example-%, $(EXAMPLES)) CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) -CHECK_TARGETS := golangci-lint +CHECK_TARGETS := lint MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate licenses vendor check-vendor $(CHECK_TARGETS) TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS) @@ -87,7 +87,7 @@ goimports: go list -f {{.Dir}} $(MODULE)/... \ | xargs goimports -local $(MODULE) -w -golangci-lint: +lint: golangci-lint run ./... vendor: From c572c3b78740f2c2d0b90755c9e5d32f033752e2 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 19 Mar 2024 13:52:07 +0200 Subject: [PATCH 5/5] Remove lint-internal make target Signed-off-by: Evan Lezar --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b0b66b7d..dd3e3a5e 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) CHECK_TARGETS := lint -MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate licenses vendor check-vendor $(CHECK_TARGETS) +MAKE_TARGETS := binaries build check fmt test examples cmds coverage generate licenses vendor check-vendor $(CHECK_TARGETS) TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS)