-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
271 lines (227 loc) · 10.4 KB
/
Makefile
File metadata and controls
271 lines (227 loc) · 10.4 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# ChromaDB Java Client Makefile
# This Makefile provides convenient commands for common development tasks
# Variables
MAVEN := mvn
JAVA := java
CHROMA_MATRIX_VERSIONS := 1.0.0 1.3.7 1.5.5
# Color output
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[0;33m
BLUE := \033[0;34m
NC := \033[0m # No Color
# Default target
.DEFAULT_GOAL := help
# Check for required tools
.PHONY: check-tools
check-tools:
@command -v $(JAVA) >/dev/null 2>&1 || { echo "$(RED)Error: Java is not installed$(NC)"; exit 1; }
@command -v $(MAVEN) >/dev/null 2>&1 || { echo "$(RED)Error: Maven is not installed$(NC)"; exit 1; }
@echo "$(GREEN)✓ All required tools are installed$(NC)"
##@ Core Build Targets
.PHONY: build
build: check-tools ## Clean and compile the project
@echo "$(BLUE)Building project...$(NC)"
$(MAVEN) clean compile
.PHONY: test
test: check-tools ## Run all tests
@echo "$(BLUE)Running tests...$(NC)"
$(MAVEN) test
.PHONY: package
package: check-tools ## Create JAR package
@echo "$(BLUE)Creating JAR package...$(NC)"
$(MAVEN) clean package
.PHONY: install
install: check-tools ## Install to local Maven repository
@echo "$(BLUE)Installing to local Maven repository...$(NC)"
$(MAVEN) clean install
.PHONY: clean
clean: check-tools ## Clean build artifacts
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
$(MAVEN) clean
##@ Testing Targets
.PHONY: test-unit
test-unit: check-tools ## Run unit tests only
@echo "$(BLUE)Running unit tests...$(NC)"
$(MAVEN) test -Dtest="!*Integration*"
.PHONY: test-integration
test-integration: check-tools ## Run integration tests only
@echo "$(BLUE)Running integration tests...$(NC)"
$(MAVEN) -Pintegration test
.PHONY: test-matrix
test-matrix: check-tools ## Run full unit + integration test matrix across all pinned Chroma versions
@echo "$(BLUE)Running unit tests...$(NC)"
$(MAVEN) --batch-mode test
@echo "$(BLUE)Running integration tests across Chroma versions: $(CHROMA_MATRIX_VERSIONS)$(NC)"
@set -e; for v in $(CHROMA_MATRIX_VERSIONS); do \
echo "$(BLUE) Testing with Chroma $$v...$(NC)"; \
CHROMA_VERSION=$$v $(MAVEN) --batch-mode -Pintegration test || exit $$?; \
done
@echo "$(GREEN)test-matrix complete$(NC)"
# NOTE: test-matrix is the canonical version-matrix target. test-phase-02-parity is kept for backward compatibility.
.PHONY: test-phase-02-parity
test-phase-02-parity: check-tools ## Run Phase 2 parity matrix for locked Chroma versions
mvn -q -Dtest=ChromaClientImplTest,ChromaHttpCollectionTest,ChromaDtosContractTest test
CHROMA_VERSION=1.5.5 mvn -q -Pintegration -Dtest=TenantDatabaseIntegrationTest,CollectionLifecycleIntegrationTest,RecordOperationsIntegrationTest,SchemaAndQueryTextsIntegrationTest test
CHROMA_VERSION=1.3.7 mvn -q -Pintegration -Dtest=TenantDatabaseIntegrationTest,CollectionLifecycleIntegrationTest,RecordOperationsIntegrationTest,SchemaAndQueryTextsIntegrationTest test
.PHONY: test-phase-02-cloud-parity
test-phase-02-cloud-parity: check-tools ## Run optional live Chroma Cloud parity tests (requires CHROMA_* credentials)
mvn -q -Pintegration -Dtest=CloudAuthIntegrationTest,CloudParityIntegrationTest test
.PHONY: test-phase-02-approval
test-phase-02-approval: check-tools ## Run approval gate: local 1.5.5 parity baseline + cloud parity tests
CHROMA_VERSION=1.5.5 mvn -q -Pintegration -Dtest=TenantDatabaseIntegrationTest,CollectionLifecycleIntegrationTest,RecordOperationsIntegrationTest,SchemaAndQueryTextsIntegrationTest test
mvn -q -Pintegration -Dtest=CloudAuthIntegrationTest,CloudParityIntegrationTest test
.PHONY: test-version
test-version: check-tools ## Test with specific ChromaDB version (use CHROMA_VERSION=x.x.x)
ifndef CHROMA_VERSION
@echo "$(RED)Error: CHROMA_VERSION not specified$(NC)"
@echo "Usage: make test-version CHROMA_VERSION=1.5.2"
@exit 1
endif
@echo "$(BLUE)Testing with ChromaDB version $(CHROMA_VERSION)...$(NC)"
CHROMA_VERSION=$(CHROMA_VERSION) $(MAVEN) test
.PHONY: test-class
test-class: check-tools ## Run specific test class (use TEST=ClassName)
ifndef TEST
@echo "$(RED)Error: TEST not specified$(NC)"
@echo "Usage: make test-class TEST=YourTestClass"
@exit 1
endif
@echo "$(BLUE)Running test class $(TEST)...$(NC)"
$(MAVEN) test -Dtest=$(TEST)
.PHONY: test-method
test-method: check-tools ## Run specific test method (use TEST=ClassName#methodName)
ifndef TEST
@echo "$(RED)Error: TEST not specified$(NC)"
@echo "Usage: make test-method TEST=YourTestClass#yourTestMethod"
@exit 1
endif
@echo "$(BLUE)Running test method $(TEST)...$(NC)"
$(MAVEN) test -Dtest=$(TEST)
##@ Development Utilities
.PHONY: deps
deps: check-tools ## Download/update dependencies
@echo "$(BLUE)Resolving dependencies...$(NC)"
$(MAVEN) dependency:resolve
.PHONY: deps-tree
deps-tree: check-tools ## Display dependency tree
@echo "$(BLUE)Displaying dependency tree...$(NC)"
$(MAVEN) dependency:tree
.PHONY: deps-analyze
deps-analyze: check-tools ## Analyze dependencies for conflicts
@echo "$(BLUE)Analyzing dependencies...$(NC)"
$(MAVEN) dependency:analyze
.PHONY: versions
versions: check-tools ## Check for dependency updates
@echo "$(BLUE)Checking for dependency updates...$(NC)"
$(MAVEN) versions:display-dependency-updates
.PHONY: compile
compile: check-tools ## Compile source code without cleaning
@echo "$(BLUE)Compiling source code...$(NC)"
$(MAVEN) compile
.PHONY: test-compile
test-compile: check-tools ## Compile test source code
@echo "$(BLUE)Compiling test source code...$(NC)"
$(MAVEN) test-compile
##@ Release Targets
.PHONY: release-prepare
release-prepare: check-tools ## Prepare for release (update versions)
@echo "$(YELLOW)Preparing for release...$(NC)"
@echo "Current version: $$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout)"
@read -p "Enter new version: " VERSION && \
$(MAVEN) versions:set -DnewVersion=$$VERSION && \
echo "$(GREEN)✓ Version updated to $$VERSION$(NC)"
.PHONY: release-rollback
release-rollback: check-tools ## Rollback version changes
@echo "$(YELLOW)Rolling back version changes...$(NC)"
$(MAVEN) versions:revert
.PHONY: snapshot
snapshot: check-tools ## Deploy snapshot version
@echo "$(BLUE)Deploying snapshot...$(NC)"
$(MAVEN) clean deploy
.PHONY: release
release: check-tools ## Full release (CI only - requires GPG signing)
@echo "$(YELLOW)⚠️ This target is intended for CI use only$(NC)"
@echo "$(BLUE)Performing full release...$(NC)"
$(MAVEN) clean deploy -P release
.PHONY: release-check
release-check: check-tools ## Validate release readiness (version, docs, artifacts if built)
@echo "$(BLUE)Running release checks...$(NC)"
@VERSION=$$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout) && \
echo " Version: $$VERSION" && \
echo "$$VERSION" | grep -qv "SNAPSHOT" || { echo "$(RED)FAIL: Version $$VERSION contains -SNAPSHOT$(NC)"; exit 1; } && \
echo " $(GREEN)Version format OK$(NC)"
@VERSION=$$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout) && \
grep -q "\[$$VERSION\]" CHANGELOG.md || { echo "$(RED)FAIL: No CHANGELOG.md entry for $$VERSION$(NC)"; exit 1; } && \
echo " $(GREEN)CHANGELOG.md entry OK$(NC)"
@VERSION=$$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout) && \
grep -q "$$VERSION" README.md || { echo "$(RED)FAIL: README.md does not reference version $$VERSION$(NC)"; exit 1; } && \
echo " $(GREEN)README.md version reference OK$(NC)"
@grep -q "^## TODO" README.md && { echo "$(RED)FAIL: README.md contains stale TODO section$(NC)"; exit 1; } || \
echo " $(GREEN)No stale TODO section OK$(NC)"
@ARTIFACT_ID=$$($(MAVEN) help:evaluate -Dexpression=project.artifactId -q -DforceStdout) && \
VERSION=$$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout) && \
if [ -d target ]; then \
for f in \
"$${ARTIFACT_ID}-$${VERSION}.jar" \
"$${ARTIFACT_ID}-$${VERSION}-sources.jar" \
"$${ARTIFACT_ID}-$${VERSION}-javadoc.jar" \
"$${ARTIFACT_ID}-$${VERSION}.jar.md5" \
"$${ARTIFACT_ID}-$${VERSION}.jar.sha512"; do \
test -s "target/$$f" || { echo "$(RED)FAIL: target/$$f missing or empty$(NC)"; exit 1; }; \
done && \
echo " $(GREEN)Artifacts OK$(NC)"; \
else \
echo " $(YELLOW)SKIP: target/ not found (run release-dry-run for full validation)$(NC)"; \
fi
@echo "$(GREEN)release-check passed$(NC)"
.PHONY: release-dry-run
release-dry-run: check-tools ## Build release artifacts locally without signing or deploying
@echo "$(BLUE)Running release dry-run (no GPG, no deploy)...$(NC)"
$(MAVEN) --batch-mode clean verify -Dgpg.skip=true
@$(MAKE) release-check
@echo "$(GREEN)release-dry-run complete$(NC)"
##@ Docker Targets
.PHONY: docker-test
docker-test: ## Run tests in Docker environment
@echo "$(BLUE)Running tests in Docker...$(NC)"
docker run --rm -v $(PWD):/workspace -w /workspace maven:3-openjdk-8 mvn test
.PHONY: docker-build
docker-build: ## Build project in Docker environment
@echo "$(BLUE)Building in Docker...$(NC)"
docker run --rm -v $(PWD):/workspace -w /workspace maven:3-openjdk-8 mvn clean package
##@ Utility Targets
.PHONY: info
info: check-tools ## Display project information
@echo "$(BLUE)Project Information:$(NC)"
@echo " Name: $$($(MAVEN) help:evaluate -Dexpression=project.name -q -DforceStdout)"
@echo " Group ID: $$($(MAVEN) help:evaluate -Dexpression=project.groupId -q -DforceStdout)"
@echo " Artifact ID: $$($(MAVEN) help:evaluate -Dexpression=project.artifactId -q -DforceStdout)"
@echo " Version: $$($(MAVEN) help:evaluate -Dexpression=project.version -q -DforceStdout)"
@echo " Java Version: $$($(JAVA) -version 2>&1 | head -1)"
@echo " Maven Version: $$($(MAVEN) -version | head -1)"
.PHONY: help
help: ## Display this help message
@echo "ChromaDB Java Client - Development Tasks"
@echo ""
@echo "Usage: make [target]"
@echo ""
@awk 'BEGIN {FS = ":.*##"; printf "$(YELLOW)Available targets:$(NC)\n"} \
/^[a-zA-Z_-]+:.*?##/ { printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2 } \
/^##@/ { printf "\n$(BLUE)%s$(NC)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@echo ""
@echo "$(YELLOW)Examples:$(NC)"
@echo " make build # Build the project"
@echo " make test # Run all tests"
@echo " make test-version CHROMA_VERSION=1.5.2 # Test with specific version"
@echo " make test-class TEST=YourTestClass # Run specific test class"
@echo " make help # Show this help"
# Quick shortcuts
.PHONY: b
b: build ## Shortcut for build
.PHONY: t
t: test ## Shortcut for test
.PHONY: c
c: clean ## Shortcut for clean
.PHONY: i
i: install ## Shortcut for install