Skip to content

Commit ba31298

Browse files
committed
[no-relnote] Add local devel image
Signed-off-by: Evan Lezar <[email protected]>
1 parent fdb0412 commit ba31298

File tree

1,344 files changed

+613402
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,344 files changed

+613402
-45
lines changed

.github/workflows/golang.yaml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024 NVIDIA CORPORATION
1+
# Copyright 2024 NVIDIA CORPORATION
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@ name: Golang
1616

1717
on:
1818
pull_request:
19+
types:
20+
- opened
21+
- synchronize
1922
branches:
2023
- main
2124
- release-*
@@ -33,8 +36,8 @@ jobs:
3336
- name: Get Golang version
3437
id: vars
3538
run: |
36-
GOLANG_VERSION=$( grep "GOLANG_VERSION ?=" versions.mk )
37-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
39+
GOLANG_VERSION=$(./hack/golang-version.sh)
40+
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV
3841
- name: Install Go
3942
uses: actions/setup-go@v5
4043
with:
@@ -46,32 +49,35 @@ jobs:
4649
args: -v --timeout 5m
4750
skip-cache: true
4851
- name: Check golang modules
49-
run: make check-vendor
52+
run: |
53+
make check-modules
54+
make -C deployments/devel check-modules
5055
test:
51-
name: Unit test
52-
runs-on: ubuntu-latest
53-
steps:
54-
- name: Checkout code
55-
uses: actions/checkout@v4
56-
- name: Get Golang version
57-
id: vars
58-
run: |
59-
GOLANG_VERSION=$( grep "GOLANG_VERSION ?=" versions.mk )
60-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
61-
- name: Install Go
62-
uses: actions/setup-go@v5
63-
with:
64-
go-version: ${{ env.GOLANG_VERSION }}
65-
- run: make test
56+
name: Unit test
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
- name: Get Golang version
62+
id: vars
63+
run: |
64+
GOLANG_VERSION=$(./hack/golang-version.sh)
65+
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
66+
- name: Install Go
67+
uses: actions/setup-go@v5
68+
with:
69+
go-version: ${{ env.GOLANG_VERSION }}
70+
- run: make test
6671
build:
72+
name: Build
6773
runs-on: ubuntu-latest
6874
steps:
69-
- uses: actions/checkout@v4
70-
name: Checkout code
75+
- name: Checkout code
76+
uses: actions/checkout@v4
7177
- name: Get Golang version
7278
id: vars
7379
run: |
74-
GOLANG_VERSION=$( grep "GOLANG_VERSION ?=" versions.mk )
80+
GOLANG_VERSION=$(./hack/golang-version.sh)
7581
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
7682
- name: Install Go
7783
uses: actions/setup-go@v5

Makefile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/))))
3131
CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS))
3232

3333
CHECK_TARGETS := golangci-lint
34-
MAKE_TARGETS := binaries build build-image check fmt lint-internal test examples cmds coverage generate vendor check-vendor $(CHECK_TARGETS)
34+
MAKE_TARGETS := binaries build build-image check fmt lint-internal test examples cmds coverage generate vendor check-modules $(CHECK_TARGETS)
3535

3636
TARGETS := $(MAKE_TARGETS) $(CMD_TARGETS)
3737

3838
DOCKER_TARGETS := $(patsubst %,docker-%, $(TARGETS))
3939
.PHONY: $(TARGETS) $(DOCKER_TARGETS)
40-
DOCKERFILE_DEVEL ?= "images/devel/Dockerfile"
41-
DOCKERFILE_CONTEXT ?= "https://github.com/NVIDIA/k8s-test-infra.git"
4240

4341
GOOS ?= linux
4442
GOARCH ?= $(shell uname -m | sed -e 's,aarch64,arm64,' -e 's,x86_64,amd64,')
@@ -90,7 +88,7 @@ vendor:
9088
go mod vendor
9189
go mod verify
9290

93-
check-vendor: vendor
91+
check-modules: vendor
9492
git diff --quiet HEAD -- go.mod go.sum vendor
9593

9694
COVERAGE_FILE := coverage.out
@@ -116,24 +114,24 @@ generate-deepcopy: .remove-deepcopy
116114
rm -f $(CURDIR)/$${dir}/zz_generated.deepcopy.go; \
117115
done
118116

119-
build-image:
120-
$(DOCKER) build \
121-
--progress=plain \
122-
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
123-
--build-arg CLIENT_GEN_VERSION="$(CLIENT_GEN_VERSION)" \
124-
--build-arg CONTROLLER_GEN_VERSION="$(CONTROLLER_GEN_VERSION)" \
125-
--build-arg GOLANGCI_LINT_VERSION="$(GOLANGCI_LINT_VERSION)" \
126-
--build-arg MOQ_VERSION="$(MOQ_VERSION)" \
127-
--tag $(BUILDIMAGE) \
128-
-f $(DOCKERFILE_DEVEL) \
129-
$(DOCKERFILE_CONTEXT)
117+
# Generate an image for containerized builds
118+
# Note: This image is local only
119+
.PHONY: .build-image
120+
.build-image:
121+
make -f deployments/devel/Makefile .build-image
122+
123+
ifeq ($(BUILD_DEVEL_IMAGE),yes)
124+
$(DOCKER_TARGETS): .build-image
125+
.shell: .build-image
126+
endif
130127

131128
$(DOCKER_TARGETS): docker-%:
132129
@echo "Running 'make $(*)' in container image $(BUILDIMAGE)"
133130
$(DOCKER) run \
134131
--rm \
135132
-e GOCACHE=/tmp/.cache/go \
136133
-e GOMODCACHE=/tmp/.cache/gomod \
134+
-e GOLANGCI_LINT_CACHE=/tmp/.cache/golangci-lint \
137135
-v $(PWD):/work \
138136
-w /work \
139137
--user $$(id -u):$$(id -g) \
@@ -148,6 +146,7 @@ PHONY: .shell
148146
-ti \
149147
-e GOCACHE=/tmp/.cache/go \
150148
-e GOMODCACHE=/tmp/.cache/gomod \
149+
-e GOLANGCI_LINT_CACHE=/tmp/.cache/golangci-lint \
151150
-v $(PWD):/work \
152151
-w /work \
153152
--user $$(id -u):$$(id -g) \

deployments/devel/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This Dockerfile is also used to define the golang version used in this project
16+
# This allows dependabot to manage this version in addition to other images.
17+
FROM golang:1.23.1
18+
19+
WORKDIR /work
20+
COPY * .
21+
22+
RUN make install-tools
23+
24+
# We need to set the /work directory as a safe directory.
25+
# This allows git commands to run in the container.
26+
RUN git config --file=/.gitconfig --add safe.directory /work
27+

deployments/devel/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2024 NVIDIA CORPORATION
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
download:
16+
@echo Download go.mod dependencies
17+
@go mod download
18+
19+
install-tools: download
20+
@echo Installing tools from tools.go
21+
@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
22+
23+
24+
DOCKER ?= docker
25+
-include $(CURDIR)/versions.mk
26+
27+
DOCKERFILE_DEVEL = deployments/devel/Dockerfile
28+
DOCKERFILE_CONTEXT = deployments/devel
29+
30+
.PHONY: .build-image
31+
.build-image:
32+
$(DOCKER) build \
33+
--progress=plain \
34+
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
35+
--tag $(BUILDIMAGE) \
36+
-f $(DOCKERFILE_DEVEL) \
37+
$(DOCKERFILE_CONTEXT)
38+
39+
modules:
40+
go mod tidy
41+
go mod verify
42+
43+
check-modules: modules
44+
git diff --quiet HEAD -- go.mod go.sum

deployments/devel/go.mod

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module github.com/NVIDIA/k8s-dra-driver/deployments/devel
2+
3+
go 1.23.1
4+
5+
require (
6+
github.com/matryer/moq v0.5.0
7+
k8s.io/code-generator v0.32.0
8+
sigs.k8s.io/controller-tools v0.17.1
9+
)
10+
11+
require (
12+
github.com/fatih/color v1.18.0 // indirect
13+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
14+
github.com/go-logr/logr v1.4.2 // indirect
15+
github.com/gobuffalo/flect v1.0.3 // indirect
16+
github.com/gogo/protobuf v1.3.2 // indirect
17+
github.com/google/gofuzz v1.2.0 // indirect
18+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
19+
github.com/json-iterator/go v1.1.12 // indirect
20+
github.com/mattn/go-colorable v0.1.13 // indirect
21+
github.com/mattn/go-isatty v0.0.20 // indirect
22+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
23+
github.com/modern-go/reflect2 v1.0.2 // indirect
24+
github.com/spf13/cobra v1.8.1 // indirect
25+
github.com/spf13/pflag v1.0.5 // indirect
26+
github.com/x448/float16 v0.8.4 // indirect
27+
golang.org/x/mod v0.22.0 // indirect
28+
golang.org/x/net v0.34.0 // indirect
29+
golang.org/x/sync v0.10.0 // indirect
30+
golang.org/x/sys v0.29.0 // indirect
31+
golang.org/x/text v0.21.0 // indirect
32+
golang.org/x/tools v0.29.0 // indirect
33+
gopkg.in/inf.v0 v0.9.1 // indirect
34+
gopkg.in/yaml.v2 v2.4.0 // indirect
35+
gopkg.in/yaml.v3 v3.0.1 // indirect
36+
k8s.io/api v0.32.0 // indirect
37+
k8s.io/apiextensions-apiserver v0.32.0 // indirect
38+
k8s.io/apimachinery v0.32.0 // indirect
39+
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect
40+
k8s.io/klog/v2 v2.130.1 // indirect
41+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
42+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
43+
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
44+
sigs.k8s.io/yaml v1.4.0 // indirect
45+
)

0 commit comments

Comments
 (0)