Skip to content

Commit

Permalink
Enable local selection of dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
  • Loading branch information
ArangoGutierrez committed Mar 8, 2024
1 parent 1646035 commit 00504af
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Checkout code

- name: Build
run: make docker-build
- 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 }}
- run: make build
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ 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 vendor check-vendor $(CHECK_TARGETS)
MAKE_TARGETS := binaries build build-image check fmt lint-internal test examples cmds coverage generate vendor check-vendor $(CHECK_TARGETS)

TARGETS := $(MAKE_TARGETS) $(CMD_TARGETS)

DOCKER_TARGETS := $(patsubst %,docker-%, $(TARGETS))
.PHONY: $(TARGETS) $(DOCKER_TARGETS)
DOCKERFILE_DEVEL := $(CURDIR)/deployments/container/Dockerfile.devel

GOOS ?= linux
ifeq ($(VERSION),)
Expand Down Expand Up @@ -139,6 +140,18 @@ generate-clientset: .remove-clientset .remove-deepcopy .remove-crds
.remove-clientset:
rm -rf $(CURDIR)/$(PKG_BASE)/clientset

build-image: $(DOCKERFILE_DEVEL)
$(DOCKER) build \
--progress=plain \
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
--build-arg CLIENT_GEN_VERSION="$(CLIENT_GEN_VERSION)" \
--build-arg CONTROLLER_GEN_VERSION="$(CONTROLLER_GEN_VERSION)" \
--build-arg GOLANGCI_LINT_VERSION="$(GOLANGCI_LINT_VERSION)" \
--build-arg MOQ_VERSION="$(MOQ_VERSION)" \
--tag $(BUILDIMAGE) \
-f $(DOCKERFILE_DEVEL) \
.

$(DOCKER_TARGETS): docker-%:
@echo "Running 'make $(*)' in container image $(BUILDIMAGE)"
$(DOCKER) run \
Expand Down
29 changes: 29 additions & 0 deletions deployments/container/Dockerfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2024, 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}

ARG CLIENT_GEN_VERSION=v0.26.1
ARG CONTROLLER_GEN_VERSION=v0.9.2
ARG GOLANGCI_LINT_VERSION=v1.52.0
ARG MOQ_VERSION=v0.3.4

RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_GEN_VERSION} \
&& go install k8s.io/code-generator/cmd/client-gen@${CLIENT_GEN_VERSION} \
&& go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} \
&& go install github.com/matryer/moq@${MOQ_VERSION}

# We need to set the /work directory as a safe directory.
# This allows git commands to run in the container.
RUN git config --file=/.gitconfig --add safe.directory /work
9 changes: 7 additions & 2 deletions versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ 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)
# these variables are only needed when building a local image
CLIENT_GEN_VERSION ?= v0.26.1
CONTROLLER_GEN_VERSION ?= v0.9.2
GOLANGCI_LINT_VERSION ?= v1.52.0
MOQ_VERSION ?= v0.3.4

BUILDIMAGE ?= ghcr.io/nvidia/k8s-test-infra:devel-go$(GOLANG_VERSION)

GIT_COMMIT ?= $(shell git describe --match="" --dirty --long --always --abbrev=40 2> /dev/null || echo "")

0 comments on commit 00504af

Please sign in to comment.