Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ==============================================================================
# GIT ATTRIBUTES
# ==============================================================================
# Use 'linguist-generated=true' to hide generated code from GitHub PR diffs.
# ==============================================================================

# Hide Kubernetes generated helpers (DeepCopy, Defaults, Conversions, OpenAPI, etc)
zz_generated.*.go linguist-generated=true

# Hide generated Protobuf Go bindings
*.pb.go linguist-generated=true

# Hide generated client library
client-go/client/** linguist-generated=true
client-go/listers/** linguist-generated=true
client-go/informers/** linguist-generated=true

# Hide copied, unmodified upstream code
code-generator/cmd/client-gen/types/** linguist-generated=true
code-generator/cmd/client-gen/generators/scheme/** linguist-generated=true
code-generator/cmd/client-gen/generators/util/** linguist-generated=true
37 changes: 17 additions & 20 deletions .github/workflows/device-api-ci.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Device API CI
name: CI

on:
push:
Expand All @@ -31,7 +31,8 @@ permissions:
contents: read

jobs:
lint-test:
go:
name: Go
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -42,36 +43,32 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: api/go.mod
cache-dependency-path: api/go.sum
cache-dependency-path: "**/go.sum"

- name: Install yq
- name: Install tools
run: |
echo "Installing yq..."
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq

- name: Install protoc
run: |
echo "Installing protoc..."
PROTOC_VERSION=$(yq eval '.protobuf.protobuf' .versions.yaml | sed 's/v//')
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
sudo unzip -o protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local
rm protoc-${PROTOC_VERSION}-linux-x86_64.zip

- name: Generate protobuf code
run: make -C api protos-generate
echo "Installing golangci-lint..."
LINT_VERSION=$(yq eval '.go_tools.golangci_lint' .versions.yaml)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $LINT_VERSION

- name: Verify no changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Generated code is out of date. Please run 'make protos-generate' and commit the changes."
git diff
exit 1
fi
- name: Generate
run: make verify-codegen

- name: Run go vet
run: cd api && go vet ./...
- name: Lint
run: make lint

- name: Build
run: make -C api build
run: make build

- name: Run tests
run: cd api && go test -v ./...
- name: Test
run: make test
77 changes: 0 additions & 77 deletions .github/workflows/lint-test.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
*.test

# Output of the go coverage tool
*.out
**/*.out
code-quality-report.json

# Go workspace file
go.work
go.work.sum

# Local tool binaries (managed by api/Makefile)
api/bin/*

# ==============================================================================
# IDE & Editor Configurations
# ==============================================================================
Expand Down
14 changes: 10 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ run:
modules-download-mode: readonly
issues-exit-code: 1
tests: false
allow-parallel-runners: false
allow-parallel-runners: true

output:
formats:
text:
Expand All @@ -28,6 +29,7 @@ output:
code-climate:
path: code-quality-report.json
path-prefix: ""

linters:
enable:
- asciicheck
Expand All @@ -46,14 +48,14 @@ linters:
- goconst
- gocritic
- gosec
- govet
- lll
- misspell
- nestif
- nilerr
- noctx
- whitespace
- wsl_v5
- gosec
exclusions:
generated: lax
presets:
Expand All @@ -65,8 +67,8 @@ linters:
- third_party$
- builtin$
- examples$
issues:
uniq-by-line: false
- code-generator/cmd$

formatters:
enable:
- gofmt
Expand All @@ -77,3 +79,7 @@ formatters:
- third_party$
- builtin$
- examples$
- code-generator/cmd$

issues:
uniq-by-line: false
17 changes: 12 additions & 5 deletions .versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@

# Language Versions
languages:
go: '1.25'
go: '1.25.5'

# Go Development Tools
go_tools:
golangci_lint: 'v2.5.0'
gotestsum: 'v1.13.0'
gocover_cobertura: 'v1.4.0'
setup_envtest: 'latest'
goimports: 'v0.30.0'
crane: 'v0.20.2'
goverter: 'v1.9.3'
kubernetes_code_gen: 'v0.34.1'

# Protocol Buffers / gRPC
protobuf:
protobuf: 'v33.0'
protoc_gen_go: 'v1.36.10'
protoc_gen_go_grpc: 'v1.5.1'

# Go Development Tools
go_tools:
golangci_lint: 'v2.5.0'
94 changes: 67 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,80 @@
# limitations under the License.

# Main Makefile for NVIDIA Device API
# Delegates to api/Makefile for all operations

# ==============================================================================
# Configuration
# ==============================================================================

SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

# Modules to manaage.
MODULES := api client-go code-generator

# ==============================================================================
# Targets
# ==============================================================================

.PHONY: all
all: ## Build and generate all (delegates to api/)
$(MAKE) -C api all
all: code-gen test build ## Run code generation, test, and build for all modules.

.PHONY: build
build: ## Build the Go module (delegates to api/)
$(MAKE) -C api build
##@ General

.PHONY: protos-generate
protos-generate: ## Generate Go code from Proto definitions (delegates to api/)
$(MAKE) -C api protos-generate
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: protos-clean
protos-clean: ## Remove generated code (delegates to api/)
$(MAKE) -C api protos-clean
##@ Development

.PHONY: lint
lint: ## Run linting checks
cd api && go vet ./...
.PHONY: code-gen
code-gen: ## Run code generation in all modules.
$(MAKE) -C api code-gen
$(MAKE) -C client-go code-gen

.PHONY: verify-codegen
verify-codegen: code-gen ## Verify generated code is up-to-date.
@if [ -n "$$(git status --porcelain)" ]; then \
echo "ERROR: Generated code is out of date. Run 'make code-gen'."; \
git status --porcelain; \
git --no-pager diff; \
exit 1; \
fi

.PHONY: build
build: ## Build all modules.
@for mod in $(MODULES); do \
if [ -f $$mod/Makefile ]; then \
$(MAKE) -C $$mod build; \
fi \
done

.PHONY: test
test: ## Run tests
cd api && go test ./...
test: ## Run tests in all modules.
@for mod in $(MODULES); do \
if [ -f $$mod/Makefile ]; then \
$(MAKE) -C $$mod test; \
fi \
done

.PHONY: clean
clean: protos-clean ## Clean all generated and build artifacts
rm -rf api/bin/
.PHONY: lint
lint: ## Run linting on all modules.
@for mod in $(MODULES); do \
if [ -f $$mod/Makefile ]; then \
$(MAKE) -C $$mod lint; \
fi \
done

.PHONY: help
help: ## Display this help
@echo "NVIDIA Device API Makefile"
@echo ""
@echo "Available targets:"
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort -u | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
clean: ## Clean generated artifacts in all modules.
@for mod in $(MODULES); do \
if [ -f $$mod/Makefile ]; then \
$(MAKE) -C $$mod clean; \
fi \
done

.PHONY: tidy
tidy: ## Run go mod tidy on all modules.
@for mod in $(MODULES); do \
echo "Tidying $$mod..."; \
(cd $$mod && go mod tidy); \
done
Loading