-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
177 lines (132 loc) · 7.15 KB
/
Copy pathMakefile
File metadata and controls
177 lines (132 loc) · 7.15 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
.PHONY: help install dev-setup test lint format typecheck clean docker-up docker-down run \
test-integration test-adapter test-backends-up test-backends-down \
test-es test-opensearch test-solr test-meili test-wikipedia
# Default target
help: ## Show this help message
@echo "OpenSift — AI-Powered Search Augmentation Layer"
@echo ""
@echo "Usage: make [target]"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ─── Setup ───────────────────────────────────────────────
install: ## Install production dependencies
poetry install --without=dev,docs
dev-setup: ## Set up development environment (all dependencies + pre-commit)
poetry install --with=dev,docs
poetry run pre-commit install || true
@echo ""
@echo "Development environment ready!"
@echo " Run tests: make test"
@echo " Run server: make run"
# ─── Development ─────────────────────────────────────────
run: ## Run the development server with auto-reload
poetry run opensift --reload --log-level debug
run-prod: ## Run the production server
poetry run opensift --workers 4 --log-level info
# ─── Quality ─────────────────────────────────────────────
test: ## Run all tests (excludes adapter integration tests that require Docker)
poetry run pytest tests/ -v -m "not (elasticsearch or opensearch or solr or meilisearch)"
test-unit: ## Run unit tests only
poetry run pytest tests/unit/ -v -m "not integration"
test-integration: ## Run all integration tests (requires Docker backends)
poetry run pytest tests/integration/ -v -m integration
# ─── Per-adapter targets ─────────────────────────────────
# Usage: make test-es — start Elasticsearch + run its tests
# make test-opensearch — start OpenSearch + run its tests
# make test-solr — start Solr + run its tests
# make test-meili — start MeiliSearch + run its tests
# make test-wikipedia — run Wikipedia tests (no Docker needed)
#
# Generic: make test-adapter ADAPTER=elasticsearch
COMPOSE_FILE := deployments/docker/docker-compose.test.yml
test-adapter: ## Run one adapter's tests: make test-adapter ADAPTER=elasticsearch
ifndef ADAPTER
$(error ADAPTER is required. Use: elasticsearch, opensearch, solr, meilisearch, wikipedia)
endif
ifeq ($(ADAPTER),wikipedia)
poetry run pytest tests/integration/test_wikipedia.py -v -m wikipedia
else
@echo "Starting $(ADAPTER)..."
docker compose -f $(COMPOSE_FILE) up -d $(ADAPTER)
@echo "Waiting for $(ADAPTER) to become healthy..."
@until docker compose -f $(COMPOSE_FILE) ps $(ADAPTER) --format '{{.Status}}' | grep -q healthy; do sleep 2; done
@echo "$(ADAPTER) is ready. Running tests..."
poetry run pytest tests/integration/test_$(ADAPTER).py -v -m $(ADAPTER)
endif
test-es: ## Start Elasticsearch + run its tests
@$(MAKE) test-adapter ADAPTER=elasticsearch
test-opensearch: ## Start OpenSearch + run its tests
@$(MAKE) test-adapter ADAPTER=opensearch
test-solr: ## Start Solr + run its tests
@$(MAKE) test-adapter ADAPTER=solr
test-meili: ## Start MeiliSearch + run its tests
@$(MAKE) test-adapter ADAPTER=meilisearch
test-wikipedia: ## Run Wikipedia tests (no Docker needed)
poetry run pytest tests/integration/test_wikipedia.py -v -m wikipedia
test-backends-up: ## Start all search backends for integration tests
docker compose -f $(COMPOSE_FILE) up -d
@echo "Waiting for all backends to be ready..."
@until docker compose -f $(COMPOSE_FILE) ps --format '{{.Status}}' | grep -v healthy | grep -qv STATUS || true; do sleep 2; done
@echo " Elasticsearch: http://localhost:9200"
@echo " OpenSearch: http://localhost:9201"
@echo " Solr: http://localhost:8983"
@echo " MeiliSearch: http://localhost:7700"
test-backends-down: ## Stop search backends and remove volumes
docker compose -f $(COMPOSE_FILE) down -v
test-cov: ## Run tests with coverage report
poetry run pytest tests/ --cov=opensift --cov-report=html --cov-report=term-missing
lint: ## Run linter (ruff)
poetry run ruff check src/ tests/
lint-fix: ## Run linter with auto-fix
poetry run ruff check --fix src/ tests/
format: ## Format code (ruff)
poetry run ruff format src/ tests/
format-check: ## Check code formatting without changes
poetry run ruff format --check src/ tests/
typecheck: ## Run type checker (mypy)
poetry run mypy src/opensift/
check: lint format-check typecheck test ## Run all checks (CI pipeline)
# ─── Docker ──────────────────────────────────────────────
docker-build: ## Build Docker image
docker build -f deployments/docker/Dockerfile -t opensift/core:latest .
docker-up: ## Start development stack (Docker Compose)
docker-compose -f deployments/docker/docker-compose.dev.yml up -d
docker-down: ## Stop development stack
docker-compose -f deployments/docker/docker-compose.dev.yml down
docker-logs: ## Tail Docker Compose logs
docker-compose -f deployments/docker/docker-compose.dev.yml logs -f
# ─── Documentation ───────────────────────────────────────
docs-serve: ## Serve documentation locally
poetry run mkdocs serve
docs-build: ## Build documentation
poetry run mkdocs build
# ─── SDK ─────────────────────────────────────────────
openapi-export: ## Export OpenAPI spec to sdks/openapi.json
poetry run python -c "\
from opensift.api.app import create_app; \
import json; \
app = create_app(); \
spec = app.openapi(); \
print(json.dumps(spec, indent=2))" > sdks/openapi.json
@echo "Exported OpenAPI spec to sdks/openapi.json"
# ─── Build & Publish ─────────────────────────────────
build: clean ## Build sdist and wheel
poetry build
@echo "Built packages:"
@ls -lh dist/
publish-check: build ## Build and verify package metadata
poetry run twine check dist/*
publish-test: publish-check ## Publish to TestPyPI
poetry run twine upload --repository testpypi dist/*
publish: publish-check ## Publish to PyPI (use with caution)
@echo "Publishing opensift $$(poetry version -s) to PyPI..."
@read -p "Are you sure? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1
poetry run twine upload dist/*
# ─── Cleanup ─────────────────────────────────────────────
clean: ## Remove build artifacts and caches
rm -rf dist/ build/ *.egg-info/
rm -rf .pytest_cache/ .mypy_cache/ .ruff_cache/
rm -rf htmlcov/ .coverage
rm -rf site/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
@echo "Cleaned up build artifacts and caches."