Skip to content

Commit cd4b684

Browse files
authored
Merge pull request #32 from elezar/add-actions
Add github actions
2 parents 54ed933 + 6f613fe commit cd4b684

File tree

9 files changed

+195
-205
lines changed

9 files changed

+195
-205
lines changed

.github/workflows/blossom-ci.yml

-113
This file was deleted.

.github/workflows/golang.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
name: Golang
16+
17+
on:
18+
pull_request:
19+
branches:
20+
- main
21+
- release-*
22+
push:
23+
branches:
24+
- main
25+
- release-*
26+
27+
jobs:
28+
check:
29+
# TODO: Disable golangci-lint until the repo has been onboarded.
30+
# See https://github.com/NVIDIA/mig-parted/issues/34
31+
if: false
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Lint
37+
uses: golangci/golangci-lint-action@v3
38+
with:
39+
version: latest
40+
args: -v --timeout 5m
41+
skip-cache: true
42+
test:
43+
name: Unit test
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
- name: Install Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: '1.20'
52+
- run: make test
53+
build:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Build
59+
run: make docker-build

.github/workflows/image.yaml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
# Run this workflow on pull requests
16+
name: image
17+
18+
on:
19+
pull_request:
20+
types:
21+
- opened
22+
- synchronize
23+
branches:
24+
- main
25+
- release-*
26+
push:
27+
branches:
28+
- main
29+
- release-*
30+
31+
jobs:
32+
build:
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
dist: [ubuntu20.04, ubi8]
37+
steps:
38+
- uses: actions/checkout@v4
39+
name: Check out code
40+
- name: Calculate build vars
41+
id: vars
42+
run: |
43+
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
44+
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
45+
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
46+
echo "${REPO_FULL_NAME}"
47+
echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV
48+
49+
GENERATE_ARTIFACTS="false"
50+
if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then
51+
GENERATE_ARTIFACTS="false"
52+
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
53+
GENERATE_ARTIFACTS="true"
54+
elif [[ "${{ github.event_name }}" == "push" ]]; then
55+
GENERATE_ARTIFACTS="true"
56+
fi
57+
echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
58+
echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
59+
- name: Set up QEMU
60+
uses: docker/setup-qemu-action@v3
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
- name: Login to GitHub Container Registry
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
- name: Build image
70+
env:
71+
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-device-plugin
72+
VERSION: ${COMMIT_SHORT_SHA}
73+
run: |
74+
echo "${VERSION}"
75+
make -f deployments/gpu-operator/Makefile build-${{ matrix.dist }}

.github/workflows/pre-sanity.yml

-22
This file was deleted.

Makefile

+6-26
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ REGISTRY ?= nvidia
2121
IMAGE_NAME=$(REGISTRY)/mig-parted
2222
endif
2323

24-
BUILDIMAGE_TAG ?= golang$(GOLANG_VERSION)
25-
BUILDIMAGE ?= $(IMAGE_NAME)-build:$(BUILDIMAGE_TAG)
26-
2724
EXAMPLES := $(patsubst ./examples/%/,%,$(sort $(dir $(wildcard ./examples/*/))))
2825
EXAMPLE_TARGETS := $(patsubst %,example-%,$(EXAMPLES))
2926

@@ -106,30 +103,12 @@ coverage: test
106103
cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks
107104
go tool cover -func=$(COVERAGE_FILE).no-mocks
108105

109-
# Generate an image for containerized builds
110-
# Note: This image is local only
111-
.PHONY: .build-image .pull-build-image .push-build-image
112-
.build-image: docker/Dockerfile.devel
113-
if [ x"$(SKIP_IMAGE_BUILD)" = x"" ]; then \
114-
$(DOCKER) build \
115-
--progress=plain \
116-
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
117-
--tag $(BUILDIMAGE) \
118-
-f $(^) \
119-
docker; \
120-
fi
121-
122-
.pull-build-image:
123-
$(DOCKER) pull $(BUILDIMAGE)
124-
125-
.push-build-image:
126-
$(DOCKER) push $(BUILDIMAGE)
127-
128-
$(DOCKER_TARGETS): docker-%: .build-image
129-
@echo "Running 'make $(*)' in docker container $(BUILDIMAGE)"
106+
$(DOCKER_TARGETS): docker-%:
107+
@echo "Running 'make $(*)' in container image $(BUILDIMAGE)"
130108
$(DOCKER) run \
131109
--rm \
132-
-e GOCACHE=/tmp/.cache \
110+
-e GOCACHE=/tmp/.cache/go \
111+
-e GOMODCACHE=/tmp/.cache/gomod \
133112
-v $(PWD):/work \
134113
-w /work \
135114
--user $$(id -u):$$(id -g) \
@@ -142,7 +121,8 @@ PHONY: .shell
142121
$(DOCKER) run \
143122
--rm \
144123
-ti \
145-
-e GOCACHE=/tmp/.cache \
124+
-e GOCACHE=/tmp/.cache/go \
125+
-e GOMODCACHE=/tmp/.cache/gomod \
146126
-v $(PWD):/work \
147127
-w /work \
148128
--user $$(id -u):$$(id -g) \

deployments/gpu-operator/Dockerfile.ubi8

+25-9
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,33 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
ARG CUDA_VERSION=12.2.0
1516
ARG BASE_DIST=ubi8
16-
ARG CUDA_VERSION
17-
ARG GOLANG_VERSION=x.x.x
18-
19-
# NOTE: In cases where the libc version is a concern, we would have to use an
20-
# image based on the target OS to build the golang executables here -- especially
21-
# if cgo code is included.
22-
FROM golang:${GOLANG_VERSION} AS build
17+
FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build
2318

2419
SHELL ["/bin/bash", "-c"]
2520

26-
ARG TARGETARCH
21+
RUN yum install -y \
22+
wget make git gcc \
23+
&& \
24+
rm -rf /var/cache/yum/*
25+
26+
ARG GOLANG_VERSION=1.20.4
27+
RUN set -eux; \
28+
\
29+
arch="$(uname -m)"; \
30+
case "${arch##*-}" in \
31+
x86_64 | amd64) ARCH='amd64' ;; \
32+
ppc64el | ppc64le) ARCH='ppc64le' ;; \
33+
aarch64) ARCH='arm64' ;; \
34+
*) echo "unsupported architecture" ; exit 1 ;; \
35+
esac; \
36+
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
37+
| tar -C /usr/local -xz
38+
39+
ENV GOPATH /go
40+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
41+
2742
WORKDIR /build
2843
COPY . .
2944

@@ -34,7 +49,8 @@ RUN make PREFIX=/artifacts cmds
3449

3550
RUN cp ./deployments/gpu-operator/reconfigure-mig.sh /artifacts/reconfigure-mig.sh
3651

37-
RUN OS_ARCH=${TARGETARCH/x86_64/amd64} && OS_ARCH=${OS_ARCH/aarch64/arm64} && curl -o /artifacts/kubectl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${OS_ARCH}/kubectl";
52+
ARG TARGETARCH
53+
RUN OS_ARCH=${TARGETARCH/x86_64/amd64} && OS_ARCH=${OS_ARCH/aarch64/arm64} && curl -o /artifacts/kubectl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${OS_ARCH}/kubectl"
3854
RUN chmod a+x /artifacts/kubectl
3955

4056
# Install the nvidia-ctk binary as a go executable

0 commit comments

Comments
 (0)