-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (70 loc) · 3.39 KB
/
Copy pathMakefile
File metadata and controls
88 lines (70 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright 2025 NVIDIA CORPORATION
# SPDX-License-Identifier: Apache-2.0
CONTROLLER_TOOLS_VERSION ?= v0.20.1
CHANGIE_VERSION ?= v1.25.0
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
CHANGIE ?= $(LOCALBIN)/changie
# CRDs derived from Kubernetes projects that require the Kubernetes copyright header.
K8S_COPYRIGHTED_MANIFEST_FILES := config/crd/kai.scheduler_topologies.yaml
.PHONY: all
all: generate manifests clients
.PHONY: build
build: ## Build all packages.
go build ./...
.PHONY: test
test: ## Run all tests with coverage.
mkdir -p coverage
go test -coverprofile=coverage/coverage.out ./...
.PHONY: validate
validate: ## Check formatting and vet without writing files (CI).
@if [ -n "$$(gofmt -l .)" ]; then echo "Files need formatting:"; gofmt -l .; exit 1; fi
go vet ./...
.PHONY: lint
lint: ## Format and vet.
gofmt -l -w .
go vet ./...
.PHONY: generate
generate: controller-gen ## Generate DeepCopy method implementations.
$(CONTROLLER_GEN) object:headerFile="./hack/boilerplate.go.txt" paths="./scheduling/..." paths="./kai/..."
.PHONY: manifests
manifests: controller-gen ## Generate CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd:allowDangerousTypes=true,generateEmbeddedObjectMeta=true,headerFile="./hack/boilerplate.yaml.txt" paths="./scheduling/..." paths="./kai/..." output:crd:artifacts:config=config/crd
# Prepend Kubernetes copyright to CRDs derived from Kubernetes projects.
@for f in $(K8S_COPYRIGHTED_MANIFEST_FILES); do \
cat ./hack/boilerplate.yaml.kb.txt $$f > $$f.tmp && mv $$f.tmp $$f; \
done
.PHONY: clients
clients: ## Generate clientset, listers, and informers.
hack/update-client.sh
.PHONY: changie
changie: $(CHANGIE) ## Download changie locally if necessary.
$(CHANGIE): $(LOCALBIN)
test -s $(LOCALBIN)/changie || GOBIN=$(LOCALBIN) go install github.com/miniscruff/changie@$(CHANGIE_VERSION)
.PHONY: changelog
changelog: changie ## Add a changelog entry. Agents: make changelog KIND=Fixed BODY="...". Humans: make changelog (interactive).
@if [ -n "$(KIND)" ] && [ -n "$(BODY)" ]; then \
kind_lower=$$(echo "$(KIND)" | tr '[:upper:]' '[:lower:]'); \
ts=$$(date '+%Y%m%d-%H%M%S'); \
out=".changes/unreleased/$${kind_lower}-$${ts}.yaml"; \
printf 'kind: %s\nbody: |-\n %s\n' "$(KIND)" "$(BODY)" > "$${out}"; \
echo "Created $${out}"; \
elif [ -n "$(KIND)" ] || [ -n "$(BODY)" ]; then \
echo "Both KIND and BODY must be set for non-interactive mode"; exit 1; \
else \
$(CHANGIE) new; \
fi
.PHONY: changelog-release
changelog-release: changie ## Fold unreleased fragments into CHANGELOG.md as VERSION and clear them. Usage: make changelog-release VERSION=v0.1.1
@test -n "$(VERSION)" || { echo "VERSION is required, e.g. make changelog-release VERSION=v0.1.1"; exit 1; }
CHANGIE=$(CHANGIE) bash hack/changelog-fold.sh $(VERSION)
.PHONY: changelog-preview
changelog-preview: changie ## Preview the next release section without writing anything. Usage: make changelog-preview VERSION=v0.1.1
@test -n "$(VERSION)" || { echo "VERSION is required, e.g. make changelog-preview VERSION=v0.1.1"; exit 1; }
$(CHANGIE) batch $(VERSION) --dry-run
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)