@@ -17,6 +17,15 @@ INTEGRATION_COVERAGE_FILE := coverage.integration.out
1717OVERALL_COVERAGE_FILE := coverage.overall.out
1818COVERAGE_SUMMARY_FILE := coverage.out
1919INTEGRATION_TEST_BIN := ./test/integration/integration-test
20+ ALLOCATOR_TEST_BIN := ./test/allocator/allocator
21+
22+ PYTHON_BIN ?= python3.14
23+ PYTHON_REQUIREMENTS_FILE := requirements.txt
24+ PYTHON_VENV_DIR ?= .venv
25+ PYTHON_VENV_BIN := $(PYTHON_VENV_DIR ) /bin
26+ PYTHON_VENV_PYTHON := $(PYTHON_VENV_BIN ) /python
27+ PYTHON_ANALYZE_DIR := ./test/allocator/analyze
28+ PYTHON_ANALYZE_SCRIPT := $(PYTHON_ANALYZE_DIR ) /compare.py
2029
2130.PHONY : help
2231help :
@@ -30,22 +39,50 @@ install-lint:
3039 @mkdir -p "$(LOCAL_BIN)"
3140 @sh -s -- "$(LOCAL_BIN)" "$(GOLANGCI_LINT_VERSION)" "$(GOLANGCI_LINT_INSTALL_METHOD)" < scripts/install_golangci_lint.sh
3241
42+ .PHONY : python-venv
43+ python-venv :
44+ # # Create venv with PYTHON_BIN and update pip.
45+ $(PYTHON_BIN) -m venv $(PYTHON_VENV_DIR)
46+ $(PYTHON_VENV_PYTHON) -m pip install --upgrade pip
47+
48+ .PHONY : python-deps
49+ python-deps : python-venv
50+ # # Install Python dependencies from requirements file.
51+ $(PYTHON_VENV_PYTHON) -m pip install -r $(PYTHON_REQUIREMENTS_FILE)
52+
53+ .PHONY : python-check
54+ python-check : python-deps
55+ # # Validate Python dependency graph and script syntax.
56+ $(PYTHON_VENV_PYTHON) -m pip check
57+ $(PYTHON_VENV_PYTHON) -m py_compile $(PYTHON_ANALYZE_DIR)/*.py
58+
59+ .PHONY : docker-check
60+ docker-check :
61+ # # Ensure Docker daemon is reachable.
62+ @docker info >/dev/null 2>&1 || { \
63+ echo "error: Docker is required. Install Docker and make sure the daemon is running, then retry."; \
64+ exit 1; \
65+ }
66+
3367.PHONY : generate
3468generate :
3569# # Regenerate protobuf stubs for allocator schema.
3670# # Requires protoc to be installed: https://grpc.io/docs/protoc-installation/
3771 @command -v protoc >/dev/null || { \
38- echo "error: protoc is required; install it first: https://grpc.io/docs/protoc-installation/"; \
72+ echo "error: protoc is required. Install it first: https://grpc.io/docs/protoc-installation/"; \
3973 exit 1; \
4074 }
4175 cd test/allocator/schema && ./generate.sh
4276
77+ .PHONY : allocator-build
78+ allocator-build :
79+ # # Build allocator binary.
80+ go build -o $(ALLOCATOR_TEST_BIN) ./test/allocator
81+
4382.PHONY : build
44- build :
83+ build : allocator-build
4584# # Build all Go packages.
46- # # Also build allocator demo binary.
4785 go build ./...
48- go build ./test/allocator
4986
5087.PHONY : unit-test
5188unit-test :
@@ -69,24 +106,32 @@ test: unit-test integration-test
69106 "$(OVERALL_COVERAGE_FILE)" \
70107 "$(COVERAGE_SUMMARY_FILE)"
71108
109+ .PHONY : lint-prepare
110+ lint-prepare : install-lint
111+ # # Verify linter configuration.
112+ $(GOLANGCI_LINT) config verify
113+
72114.PHONY : lint
73- lint : install- lint
115+ lint : lint-prepare
74116# # Analyze code locally.
75117# # Use project-local golangci-lint from ./bin.
76- # # Verify linter config before checks.
77- $(GOLANGCI_LINT) config verify
78118 $(GOLANGCI_LINT) run ./...
79119
80120.PHONY : fix
81- fix : install- lint
121+ fix : lint-prepare
82122# # Apply automatic source fixes.
83123# # Run go mod tidy, and golangci-lint --fix.
84124 go mod tidy
85- $(GOLANGCI_LINT) config verify
86125 $(GOLANGCI_LINT) run --fix ./...
87126
127+ .PHONY : allocator-analyze
128+ allocator-analyze : allocator-build docker-check python-check
129+ # # Run allocator docker benchmark and render plots.
130+ # # Requires Docker daemon and test allocator binary.
131+ $(PYTHON_VENV_PYTHON) $(PYTHON_ANALYZE_SCRIPT)
132+
88133.PHONY : clean
89134clean :
90- # # Remove generated test and coverage artifacts.
91- # # Keep workspace clean between test runs.
92- rm -f $(UNIT_COVERAGE_FILE) $(INTEGRATION_COVERAGE_FILE) $(OVERALL_COVERAGE_FILE) $(COVERAGE_SUMMARY_FILE) $(INTEGRATION_TEST_BIN)
135+ # # Remove generated build, test, and Python cache artifacts.
136+ rm -f $(UNIT_COVERAGE_FILE) $(INTEGRATION_COVERAGE_FILE) $(OVERALL_COVERAGE_FILE) $(COVERAGE_SUMMARY_FILE) $(INTEGRATION_TEST_BIN) $(ALLOCATOR_TEST_BIN)
137+ rm -rf "$(PYTHON_ANALYZE_DIR)/__pycache__"
0 commit comments