Skip to content

Commit

Permalink
Merge pull request #78 from elezar/update-ci-defs
Browse files Browse the repository at this point in the history
Update ci defs
  • Loading branch information
elezar authored Feb 29, 2024
2 parents 887262d + b9c70f0 commit 11d749c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 18 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 NVIDIA CORPORATION
# Copyright 2023-2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,28 +29,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
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/))))
CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS))

CHECK_TARGETS := golangci-lint
MAKE_TARGETS := binaries build check fmt vendor lint-internal test examples cmds coverage generate $(CHECK_TARGETS)
MAKE_TARGETS := binaries build check fmt lint-internal test examples cmds coverage generate vendor check-vendor $(CHECK_TARGETS)

TARGETS := $(MAKE_TARGETS) $(CMD_TARGETS)

Expand Down Expand Up @@ -64,10 +64,6 @@ $(EXAMPLE_TARGETS): example-%:
all: check test build binaries
check: $(CHECK_TARGETS)

# Update the vendor folder
vendor:
go mod vendor

# Apply go fmt to the codebase
fmt:
go list -f '{{.Dir}}' $(MODULE)/... \
Expand All @@ -84,6 +80,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

COVERAGE_FILE := coverage.out
test: build cmds
go test -race -cover -v -coverprofile=$(COVERAGE_FILE) $(MODULE)/...
Expand Down Expand Up @@ -135,7 +139,7 @@ generate-clientset: .remove-clientset .remove-deepcopy .remove-crds
.remove-clientset:
rm -rf $(CURDIR)/$(PKG_BASE)/clientset

$(DOCKER_TARGETS): docker-%:
$(DOCKER_TARGETS): docker-%:
@echo "Running 'make $(*)' in container image $(BUILDIMAGE)"
$(DOCKER) run \
--rm \
Expand Down
10 changes: 5 additions & 5 deletions cmd/nvidia-dra-plugin/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ func (d *driver) CleanupStaleStateContinuously(ctx context.Context) {
for {
resourceVersion, err := d.cleanupStaleStateOnce(ctx)
if err != nil {
klog.Errorf("Error cleaning up stale claim state: %w", err)
klog.Errorf("Error cleaning up stale claim state: %v", err)
}

err = d.cleanupStaleStateContinuously(ctx, resourceVersion, err)
if err != nil {
klog.Errorf("Error cleaning up stale claim state: %w", err)
klog.Errorf("Error cleaning up stale claim state: %v", err)
time.Sleep(CleanupTimeoutSecondsOnError * time.Second)
}
}
Expand Down Expand Up @@ -279,7 +279,7 @@ func (d *driver) cleanupStaleState(ctx context.Context, nas *nascrd.NodeAllocati
go func() {
count := 0
for err := range caErrors {
klog.Errorf("Error cleaning up claim allocations: %w", err)
klog.Errorf("Error cleaning up claim allocations: %v", err)
count++
}
errorCounts <- count
Expand All @@ -290,7 +290,7 @@ func (d *driver) cleanupStaleState(ctx context.Context, nas *nascrd.NodeAllocati
go func() {
count := 0
for err := range cdiErrors {
klog.Errorf("Error cleaning up CDI files: %w", err)
klog.Errorf("Error cleaning up CDI files: %v", err)
count++
}
errorCounts <- count
Expand All @@ -301,7 +301,7 @@ func (d *driver) cleanupStaleState(ctx context.Context, nas *nascrd.NodeAllocati
go func() {
count := 0
for err := range mpsErrors {
klog.Errorf("Error cleaning up MPS control daemon artifacts: %w", err)
klog.Errorf("Error cleaning up MPS control daemon artifacts: %v", err)
count++
}
errorCounts <- count
Expand Down
2 changes: 1 addition & 1 deletion cmd/nvidia-dra-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func StartPlugin(ctx context.Context, config *Config) error {

err = driver.Shutdown(ctx)
if err != nil {
klog.Errorf("Unable to cleanly shutdown driver: %w", err)
klog.Errorf("Unable to cleanly shutdown driver: %v", err)
}

return nil
Expand Down
23 changes: 22 additions & 1 deletion deployments/container/Dockerfile.ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,28 @@ ARG GOLANG_VERSION=1.20.4
ARG CUDA_IMAGE=cuda
ARG CUDA_VERSION=11.8.0
ARG BASE_DIST=ubi8
FROM golang:${GOLANG_VERSION} as build
FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build

RUN yum install -y \
wget make git gcc \
&& \
rm -rf /var/cache/yum/*

ARG GOLANG_VERSION=x.x.x
RUN set -eux; \
\
arch="$(uname -m)"; \
case "${arch##*-}" in \
x86_64 | amd64) ARCH='amd64' ;; \
ppc64el | ppc64le) ARCH='ppc64le' ;; \
aarch64 | arm64) ARCH='arm64' ;; \
*) echo "unsupported architecture" ; exit 1 ;; \
esac; \
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
| tar -C /usr/local -xz

ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

WORKDIR /build
COPY . .
Expand Down
23 changes: 22 additions & 1 deletion deployments/container/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,28 @@ ARG GOLANG_VERSION=1.20.4
ARG CUDA_IMAGE=cuda
ARG CUDA_VERSION=11.8.0
ARG BASE_DIST=ubuntu20.04
FROM golang:${GOLANG_VERSION} as build
FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build

RUN apt-get update && \
apt-get install -y wget make git gcc \
&& \
rm -rf /var/lib/apt/lists/*

ARG GOLANG_VERSION=x.x.x
RUN set -eux; \
\
arch="$(uname -m)"; \
case "${arch##*-}" in \
x86_64 | amd64) ARCH='amd64' ;; \
ppc64el | ppc64le) ARCH='ppc64le' ;; \
aarch64 | arm64) ARCH='arm64' ;; \
*) echo "unsupported architecture" ; exit 1 ;; \
esac; \
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
| tar -C /usr/local -xz

ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

WORKDIR /build
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) YEAR, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2023, 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.
Expand Down

0 comments on commit 11d749c

Please sign in to comment.