-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (140 loc) · 5.04 KB
/
Copy pathMakefile
File metadata and controls
164 lines (140 loc) · 5.04 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
CURRENT_DIR=$(shell pwd)
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# Run go vet against code
vet:
go vet ./...
# Generate code
generate: controller-gen
#$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@hack/generate_client.sh
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
ifeq ("$(shell $(CONTROLLER_GEN) --version 2> /dev/null)", "Version: v0.18.0")
else
rm -rf $(CONTROLLER_GEN)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.18.0)
endif
OPENAPI_GEN = $(shell pwd)/bin/openapi-gen
module=$(shell go list -f '{{.Module}}' k8s.io/kube-openapi/cmd/openapi-gen | awk '{print $$1}')
module_version=$(shell go list -m $(module) | awk '{print $$NF}' | head -1)
openapi-gen: ## Download openapi-gen locally if necessary.
ifeq ("$(shell command -v $(OPENAPI_GEN) 2> /dev/null)", "")
$(call go-get-tool,$(OPENAPI_GEN),k8s.io/kube-openapi/cmd/openapi-gen@$(module_version))
else
@echo "openapi-gen is already installed."
endif
# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
# Update CRD YAML and Go type definitions from upstream openkruise/agents
.PHONY: update-upstream
update-upstream:
@hack/update_upstream.sh
# Generate Java SDK from CRD definitions (requires JDK 8+)
.PHONY: generate-java
generate-java:
@hack/generate_java_sdk.sh
@hack/patch_sdk_types.sh --java
# Generate Python SDK from CRD definitions (requires yq + datamodel-codegen)
.PHONY: generate-python
generate-python:
@hack/generate_python_sdk.sh
@hack/patch_sdk_types.sh --python
# Patch generated SDK types (AnyType → concrete K8s types)
# Usage:
# make patch-sdk-types # patch both Java and Python
# make patch-sdk-types LANG=java # patch Java only
# make patch-sdk-types LANG=python # patch Python only
.PHONY: patch-sdk-types
patch-sdk-types:
ifeq ($(LANG),java)
@hack/patch_sdk_types.sh --java
else ifeq ($(LANG),python)
@hack/patch_sdk_types.sh --python
else
@hack/patch_sdk_types.sh
endif
# Generate all SDKs (Go + Java + Python) and apply type patches
# Usage:
# make generate-all # update upstream + generate all + patch types
# make generate-all SKIP_UPDATE=true # skip upstream update, generate + patch only
.PHONY: generate-all
ifeq ($(SKIP_UPDATE),true)
generate-all:
@hack/generate_client.sh --skip-update
@hack/generate_java_sdk.sh --skip-update
@hack/generate_python_sdk.sh --skip-update
@hack/patch_sdk_types.sh
else
generate-all: update-upstream
@hack/generate_client.sh --skip-update
@hack/generate_java_sdk.sh --skip-update
@hack/generate_python_sdk.sh --skip-update
@hack/patch_sdk_types.sh
endif
# ==================== E2E Testing ====================
KIND ?= kind
KIND_CLUSTER_NAME ?= ci-testing
KIND_IMAGE ?= kindest/node:v1.32.0
KIND_VERSION ?= v0.22.0
# Setup Kind cluster for e2e tests
.PHONY: setup-test-e2e
setup-test-e2e:
@echo "Creating Kind cluster..."
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_IMAGE) --config test/kind-conf.yaml || true
@echo "Installing CRDs..."
kubectl apply -f agents/crds/
# Run all SDK e2e tests
.PHONY: test-e2e
test-e2e: setup-test-e2e
bash hack/run-k8s-sdk-e2e-test.sh --sdk all
# Run Go SDK e2e test
.PHONY: test-e2e-go
test-e2e-go: setup-test-e2e
bash hack/run-k8s-sdk-e2e-test.sh --sdk go
# Run Java SDK e2e test
.PHONY: test-e2e-java
test-e2e-java: setup-test-e2e
bash hack/run-k8s-sdk-e2e-test.sh --sdk java
# Run Python SDK e2e test
.PHONY: test-e2e-python
test-e2e-python: setup-test-e2e
bash hack/run-k8s-sdk-e2e-test.sh --sdk python
# Cleanup Kind cluster
.PHONY: cleanup-test-e2e
cleanup-test-e2e:
@$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
# ==================== Python E2B Patch Tests ====================
# Pin either variable to test a specific SDK combination, for example:
# make test-e2b-patch E2B_VERSION=2.35.0 CODE_INTERPRETER_VERSION=2.9.0
# Unpinned runs resolve the newest versions allowed by the dev extra. Keep the
# pin ranges in sync with e2b/python/kruise_agents/patch_traffic_token.py
# (_check_compatibility); CI exercises the full matrix in
# .github/workflows/test-e2b-python.yaml.
.PHONY: test-e2b-patch
test-e2b-patch:
cd e2b/python && pip install -e ".[dev]" $(if $(E2B_VERSION),e2b==$(E2B_VERSION)) $(if $(CODE_INTERPRETER_VERSION),e2b-code-interpreter==$(CODE_INTERPRETER_VERSION)) && pytest tests/ -v
# ==================== Schema Generation ====================
.PHONY: gen-schema-only
gen-schema-only:
go run cmd/gen-schema/main.go
.PHONY: gen-openapi-schema
gen-openapi-schema: gen-all-openapi
go run cmd/gen-schema/main.go
.PHONY: gen-all-openapi
@hack/generate_openapi.sh