From af9d1b86815869264ee368f475c947e7148530c1 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Fri, 26 Jan 2024 12:43:43 +0100 Subject: [PATCH] Use k8s-test-infra devel image Signed-off-by: Carlos Eduardo Arango Gutierrez --- .../{golang-build.yaml => golang.yaml} | 3 -- .../{build-images.yaml => images.yaml} | 1 - .gitignore | 1 + Makefile | 44 +++++-------------- docker/Dockerfile.devel | 21 --------- versions.mk | 3 ++ 6 files changed, 14 insertions(+), 59 deletions(-) rename .github/workflows/{golang-build.yaml => golang.yaml} (95%) rename .github/workflows/{build-images.yaml => images.yaml} (99%) delete mode 100644 docker/Dockerfile.devel diff --git a/.github/workflows/golang-build.yaml b/.github/workflows/golang.yaml similarity index 95% rename from .github/workflows/golang-build.yaml rename to .github/workflows/golang.yaml index 5c8af05d..07205159 100644 --- a/.github/workflows/golang-build.yaml +++ b/.github/workflows/golang.yaml @@ -52,8 +52,5 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build dev image - run: make .build-image - - name: Build run: make docker-build diff --git a/.github/workflows/build-images.yaml b/.github/workflows/images.yaml similarity index 99% rename from .github/workflows/build-images.yaml rename to .github/workflows/images.yaml index cfe91801..798dabde 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/images.yaml @@ -74,4 +74,3 @@ jobs: run: | echo "${VERSION}" make -f deployments/container/Makefile build-${{ matrix.dist }} - diff --git a/.gitignore b/.gitignore index 250f4bdd..bbb463c6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /nvidia-dra-plugin .idea [._]*.sw[a-p] +coverage.out diff --git a/Makefile b/Makefile index ee262d18..f3713969 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,6 @@ ifeq ($(IMAGE_NAME),) IMAGE_NAME = $(REGISTRY)/$(DRIVER_NAME) endif -BUILDIMAGE_TAG ?= golang$(GOLANG_VERSION) -BUILDIMAGE ?= $(IMAGE_NAME)-build:$(BUILDIMAGE_TAG) - CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) @@ -138,34 +135,14 @@ generate-clientset: .remove-clientset .remove-deepcopy .remove-crds .remove-clientset: rm -rf $(CURDIR)/$(PKG_BASE)/clientset -# Generate an image for containerized builds -# Note: This image is local only -.PHONY: .build-image .pull-build-image .push-build-image -.build-image: docker/Dockerfile.devel - if [ x"$(SKIP_IMAGE_BUILD)" = x"" ]; then \ - $(DOCKER) build \ - --progress=plain \ - --build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \ - --tag $(BUILDIMAGE) \ - -f $(^) \ - docker; \ - fi - -.pull-build-image: - $(DOCKER) pull $(BUILDIMAGE) - -.push-build-image: - $(DOCKER) push $(BUILDIMAGE) - -$(DOCKER_TARGETS): docker-%: .build-image - @echo "Running 'make $(*)' in docker container $(BUILDIMAGE)" +$(DOCKER_TARGETS): docker-%: + @echo "Running 'make $(*)' in container image $(BUILDIMAGE)" $(DOCKER) run \ --rm \ - -e HOME=$(PWD) \ - -e GOCACHE=$(PWD)/.cache/go \ - -e GOPATH=$(PWD)/.cache/gopath \ - -v $(PWD):$(PWD) \ - -w $(PWD) \ + -e GOCACHE=/tmp/.cache/go \ + -e GOMODCACHE=/tmp/.cache/gomod \ + -v $(PWD):/work \ + -w /work \ --user $$(id -u):$$(id -g) \ $(BUILDIMAGE) \ make $(*) @@ -176,10 +153,9 @@ PHONY: .shell $(DOCKER) run \ --rm \ -ti \ - -e HOME=$(PWD) \ - -e GOCACHE=$(PWD)/.cache/go \ - -e GOPATH=$(PWD)/.cache/gopath \ - -v $(PWD):$(PWD) \ - -w $(PWD) \ + -e GOCACHE=/tmp/.cache/go \ + -e GOMODCACHE=/tmp/.cache/gomod \ + -v $(PWD):/work \ + -w /work \ --user $$(id -u):$$(id -g) \ $(BUILDIMAGE) diff --git a/docker/Dockerfile.devel b/docker/Dockerfile.devel deleted file mode 100644 index 9377d399..00000000 --- a/docker/Dockerfile.devel +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -ARG GOLANG_VERSION=x.x.x -FROM golang:${GOLANG_VERSION} - -RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.0 - -RUN go install github.com/matryer/moq@latest -RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2 -RUN go install k8s.io/code-generator/cmd/client-gen@v0.26.1 diff --git a/versions.mk b/versions.mk index 6fcfd741..b187aad3 100644 --- a/versions.mk +++ b/versions.mk @@ -24,4 +24,7 @@ vVERSION := v$(VERSION:v%=%) GOLANG_VERSION ?= 1.20.4 CUDA_VERSION ?= 11.8.0 +BUILDIMAGE_TAG ?= devel-go$(GOLANG_VERSION) +BUILDIMAGE ?= ghcr.io/nvidia/k8s-test-infra:$(BUILDIMAGE_TAG) + GIT_COMMIT ?= $(shell git describe --match="" --dirty --long --always --abbrev=40 2> /dev/null || echo "")