@@ -9,19 +9,36 @@ KUBECTL?=kubectl
99IMAGE_REGISTRY ?= quay.io/open-cluster-management
1010IMAGE_TAG ?= latest
1111IMAGE_NAME ?= $(IMAGE_REGISTRY ) /kueue-addon:$(IMAGE_TAG )
12+ export KUBECONFIG? =./.kubeconfig
13+ # Parse Kueue version from go.mod
14+ KUEUE_VERSION := $(shell grep 'sigs.k8s.io/kueue' go.mod | awk '{print $$2}')
15+
16+ # update
17+ update : update-manifests
18+ .PHONY : update
19+
20+ # update cluster-permission.yaml with latest rules from Kueue repository
21+ update-manifests :
22+ @echo " Updating cluster-permission.yaml with latest rules from Kueue repository..."
23+ @python3 scripts/update-cluster-permission.py
24+ .PHONY : update-manifests
1225
1326# verify
1427verify-gocilint :
28+ @echo " Running golangci-lint..."
1529 go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.6
1630 golangci-lint run --timeout=5m --modules-download-mode vendor ./...
1731
1832install-golang-gci :
33+ @echo " Installing golang-gci..."
1934 go install github.com/daixiang0/gci@v0.13.6
2035
2136fmt-imports : install-golang-gci
37+ @echo " Formatting imports..."
2238 gci write --skip-generated -s standard -s default -s " prefix(open-cluster-management.io)" -s " prefix(open-cluster-management.io/ocm)" cmd pkg
2339
2440verify-fmt-imports : install-golang-gci
41+ @echo " Verifying import formatting..."
2542 @output=$$(gci diff --skip-generated -s standard -s default -s "prefix(open-cluster-management.io ) " -s " prefix(open-cluster-management.io/ocm)" cmd pkg); \
2643 if [ -n " $$ output" ]; then \
2744 echo " Diff output is not empty: $$ output" ; \
@@ -31,23 +48,51 @@ verify-fmt-imports: install-golang-gci
3148 echo " Diff output is empty" ; \
3249 fi
3350
34- verify : vendor verify-fmt-imports verify-gocilint
51+ verify-manifests : update
52+ @echo " Verifying cluster-permission.yaml is up to date..."
53+ @if git status --porcelain manifests/cluster-permission/cluster-permission.yaml | grep -q manifests/cluster-permission/cluster-permission.yaml; then \
54+ echo " ✗ cluster-permission.yaml has uncommitted changes. Please commit or stash them." ; \
55+ git status manifests/cluster-permission/cluster-permission.yaml; \
56+ exit 1; \
57+ else \
58+ echo " ✓ cluster-permission.yaml is up to date" ; \
59+ fi
60+ .PHONY : verify-manifests
61+
62+ verify-chart :
63+ @echo " Verifying chart appVersion matches Kueue version in go.mod..."
64+ @CHART_VERSION=$$(grep 'appVersion:' charts/kueue-addon/Chart.yaml | awk '{print $$2}' | tr -d '"' ) ; \
65+ if [ v" $$ CHART_VERSION" = " $( KUEUE_VERSION) " ]; then \
66+ echo " ✓ Chart appVersion ($$ CHART_VERSION) matches Kueue version in go.mod ($( KUEUE_VERSION) )" ; \
67+ else \
68+ echo " ✗ Chart appVersion ($$ CHART_VERSION) does not match Kueue version in go.mod ($( KUEUE_VERSION) )" ; \
69+ echo " Please update the appVersion in charts/kueue-addon/Chart.yaml to match the Kueue version in go.mod" ; \
70+ exit 1; \
71+ fi
72+ .PHONY : verify-chart
73+
74+ verify : vendor verify-fmt-imports verify-gocilint verify-manifests verify-chart
75+ .PHONY : verify
3576
3677# build
3778vendor :
79+ @echo " Updating vendor dependencies..."
3880 go mod tidy
3981 go mod vendor
4082.PHONY : vendor
4183
4284build : vendor
85+ @echo " Building kueue-addon-controller..."
4386 CGO_ENABLED=0 go build -ldflags=" -s -w" -o kueue-addon-controller cmd/kueue/main.go
4487.PHONY : build
4588
4689image :
90+ @echo " Building Docker image..."
4791 docker build -f Dockerfile -t $(IMAGE_NAME ) .
4892.PHONY : image
4993
5094image-push :
95+ @echo " Pushing Docker image..."
5196 docker push $(IMAGE_NAME )
5297.PHONY : image-push
5398
@@ -63,6 +108,7 @@ image-manifest:
63108
64109# deploy
65110deploy : kustomize
111+ @echo " Deploying kueue-addon..."
66112 cp deploy/kustomization.yaml deploy/kustomization.yaml.tmp
67113 cd deploy && $(KUSTOMIZE ) edit set image kueue-addon-image=$(IMAGE_NAME )
68114 $(KUSTOMIZE ) build deploy | $(KUBECTL ) apply -f -
@@ -75,6 +121,7 @@ KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/k
75121
76122kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
77123$(KUSTOMIZE ) :
124+ @echo " Installing kustomize..."
78125 mkdir -p $(LOCALBIN )
79126 curl $(KUSTOMIZE_INSTALL_SCRIPT ) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION ) ) $(LOCALBIN )
80127
@@ -93,16 +140,17 @@ GO_TEST_FLAGS := -race -coverprofile=coverage.out
93140# download the kubebuilder-tools to get kube-apiserver binaries from it
94141ensure-kubebuilder-tools :
95142ifeq "" "$(wildcard $(KUBEBUILDER_ASSETS ) ) "
96- $(info Downloading kube-apiserver into '$(KUBEBUILDER_ASSETS)')
143+ @echo " Downloading kube-apiserver into '$(KUBEBUILDER_ASSETS)'"
97144 mkdir -p '$(KUBEBUILDER_ASSETS)'
98145 curl -s -f -L https://storage.googleapis.com/kubebuilder-tools/$(KB_TOOLS_ARCHIVE_NAME) -o '$(KB_TOOLS_ARCHIVE_PATH)'
99146 tar -C '$(KUBEBUILDER_ASSETS)' --strip-components=2 -zvxf '$(KB_TOOLS_ARCHIVE_PATH)'
100147else
101- $(info Using existing kube-apiserver from " $(KUBEBUILDER_ASSETS)")
148+ @echo " Using existing kube-apiserver from ' $(KUBEBUILDER_ASSETS)'"
102149endif
103150.PHONY : ensure-kubebuilder-tools
104151
105152clean-integration-test :
153+ @echo " Cleaning integration test artifacts..."
106154 $(RM ) ' $(KB_TOOLS_ARCHIVE_PATH)'
107155 rm -rf $(TEST_TMP ) /kubebuilder
108156 $(RM ) ./* integration.test
@@ -111,19 +159,29 @@ clean-integration-test:
111159clean : clean-integration-test
112160
113161test-unit :
162+ @echo " Running unit tests..."
114163 go test $(GO_TEST_FLAGS ) $(GO_TEST_PACKAGES )
115164.PHONY : test-unit
116165
117166test-integration : ensure-kubebuilder-tools
167+ @echo " Running integration tests..."
118168 go test -c ./test/integration -o ./kueue-integration.test -tags=integration
119169 ./kueue-integration.test -ginkgo.slow-spec-threshold=15s -ginkgo.v -ginkgo.fail-fast ${ARGS}
120170.PHONY : test-integration
121171
122- test-e2e :
123- echo " TODO: Implement e2e tests"
172+ test-e2e-setup :
173+ @echo " Setting up e2e test environment..."
174+ IMAGE_TAG=e2e make image
175+ @build/setup-env.sh --e2e --clean --kueue-version $(KUEUE_VERSION )
176+ .PHONY : test-e2e-setup
177+
178+ test-e2e : test-e2e-setup
179+ @echo " Running e2e tests..."
180+ go test -c ./test/e2e -o kueue-addon-e2e.test
181+ ./kueue-addon-e2e.test -test.v -ginkgo.v --ginkgo.timeout=2h
124182.PHONY : test-e2e
125183
126184test-chart :
127- echo " TODO: Implement test-chart"
128- echo " image.repository=$( IMAGE_NAME) image.tag=$( IMAGE_TAG) "
129- .PHONY : test-chart
185+ @ echo " TODO: Implement test-chart"
186+ @ echo " image.repository=$( IMAGE_NAME) image.tag=$( IMAGE_TAG) "
187+ .PHONY : test-chart
0 commit comments