-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
212 lines (171 loc) · 8.84 KB
/
Copy pathMakefile
File metadata and controls
212 lines (171 loc) · 8.84 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
SHELL=/bin/bash -o pipefail
# ─── Formatting ──────────────────────────────────────────────────────────────────
BUILD_PRINT = \e[1;34m
END_PRINT = \e[0m
ICON_DONE = $(BUILD_PRINT)$(END_PRINT) [✔]
ICON_ERROR = $(BUILD_PRINT)$(END_PRINT) [✗]
ICON_PROGRESS = $(BUILD_PRINT)$(END_PRINT) [-]
define log_progress
@printf "$(ICON_PROGRESS) $(BUILD_PRINT)$(1)$(END_PRINT)\n"
endef
define log_done
@printf "$(ICON_DONE) $(BUILD_PRINT)$(1)$(END_PRINT)\n"
endef
# ─── Variables ───────────────────────────────────────────────────────────────────
IMAGE_NAME = ere-prototype
IMAGE_TAG = latest
COMPOSE = docker compose
COMPOSE_REDIS = $(COMPOSE) -f docker-compose.yml -f docker-compose.redis.yml
# ─── Help ────────────────────────────────────────────────────────────────────────
.PHONY: help
help: ## Show available targets
@echo ""
@echo "ERE Prototype Template — Make Targets"
@echo ""
@echo " Development:"
@awk 'BEGIN {FS = ":.*##"} \
/^[a-zA-Z0-9_-]+:.*## / { \
printf " \033[1;34m%-24s\033[0m %s\n", $$1, $$2 \
}' $(MAKEFILE_LIST)
@echo ""
# ─── Setup ───────────────────────────────────────────────────────────────────────
.PHONY: install
install: ## Install all dependencies via Poetry (including storage drivers)
$(call log_progress,Installing dependencies...)
@poetry install --extras all-storage
$(call log_done,Dependencies installed.)
# ─── Quality ─────────────────────────────────────────────────────────────────────
.PHONY: lint
lint: ## Run ruff linter
$(call log_progress,Running ruff checks...)
@poetry run ruff check ere/ tests/
$(call log_done,Lint passed.)
.PHONY: format
format: ## Auto-format code with ruff
$(call log_progress,Formatting code...)
@poetry run ruff format ere/ tests/
$(call log_done,Code formatted.)
.PHONY: lint-fix
lint-fix: ## Auto-fix linting issues with ruff
$(call log_progress,Auto-fixing lint issues...)
@poetry run ruff check --fix ere/ tests/
$(call log_done,Lint issues fixed.)
# ─── Testing ─────────────────────────────────────────────────────────────────────
.PHONY: test
test: ## Run all tests
$(call log_progress,Running all tests...)
@poetry run pytest -v
$(call log_done,All tests passed.)
.PHONY: test-bdd
test-bdd: ## Run BDD feature tests only
$(call log_progress,Running BDD tests...)
@poetry run pytest -v -m "bdd"
$(call log_done,BDD tests passed.)
.PHONY: test-unit
test-unit: ## Run unit tests only
$(call log_progress,Running unit tests...)
@poetry run pytest -v -m unit
$(call log_done,Unit tests passed.)
.PHONY: coverage
coverage: ## Run tests with coverage report
$(call log_progress,Running tests with coverage...)
@poetry run coverage run -m pytest
@poetry run coverage report --show-missing
@poetry run coverage html
$(call log_done,Coverage report generated in htmlcov/.)
# ─── Run (local) ─────────────────────────────────────────────────────────────────
.PHONY: run
run: ## Start the ERE service locally (in-memory backends)
$(call log_progress,Starting ERE service locally...)
@poetry run python -m ere.main
.PHONY: run-redis
run-redis: ## Start the ERE service locally (connecting to local Redis)
$(call log_progress,Starting ERE service with Redis backend...)
@poetry run python -m ere.main --config config/ere_config_docker.yaml
# ─── Docker ──────────────────────────────────────────────────────────────────────
.PHONY: docker-build
docker-build: ## Build the ERE Docker image
$(call log_progress,Building Docker image $(IMAGE_NAME):$(IMAGE_TAG)...)
@docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
$(call log_done,Docker image built.)
.PHONY: docker-up
docker-up: ## Start ERE only (in-memory backends, no Redis)
$(call log_progress,Starting ERE container...)
@$(COMPOSE) up -d --build ere
$(call log_done,ERE container started.)
.PHONY: docker-up-redis
docker-up-redis: ## Start ERE + Redis (messaging via Redis)
$(call log_progress,Starting ERE + Redis...)
@REDIS_PORT=6380 ERE_CONFIG=/app/config/ere_config_docker.yaml $(COMPOSE) --profile redis up -d --build
$(call log_done,ERE + Redis started.)
@echo " Redis: localhost:$${REDIS_PORT:-6380}"
.PHONY: docker-up-mongodb
docker-up-mongodb: ## Start ERE + MongoDB + Mongo Express
$(call log_progress,Starting ERE + MongoDB + Mongo Express...)
@REDIS_PORT=6380 ERE_CONFIG=/app/config/ere_config_docker.yaml $(COMPOSE) --profile mongodb up -d --build
$(call log_done,ERE + MongoDB + Mongo Express started.)
@echo " MongoDB: localhost:$${MONGODB_PORT:-27017}"
@echo " Mongo Express: http://localhost:$${MONGO_EXPRESS_PORT:-8081}"
.PHONY: docker-up-postgres
docker-up-postgres: ## Start ERE + PostgreSQL (pgvector) + pgAdmin
$(call log_progress,Starting ERE + PostgreSQL + pgAdmin...)
@$(COMPOSE) --profile postgres up -d --build
$(call log_done,ERE + PostgreSQL + pgAdmin started.)
@echo " PostgreSQL: localhost:$${POSTGRES_PORT:-5432}"
@echo " pgAdmin: http://localhost:$${PGADMIN_PORT:-5050}"
.PHONY: docker-up-full
docker-up-full: ## Start all services (ERE + Redis + MongoDB + PostgreSQL + GUIs)
$(call log_progress,Starting full stack...)
@REDIS_PORT=6380 ERE_CONFIG=/app/config/ere_config_docker.yaml $(COMPOSE) --profile full up -d --build
$(call log_done,Full stack started.)
@echo " Redis: localhost:$${REDIS_PORT:-6380}"
@echo " Redis Insight: http://localhost:$${REDISINSIGHT_PORT:-5540}"
@echo " MongoDB: localhost:$${MONGODB_PORT:-27017}"
@echo " Mongo Express: http://localhost:$${MONGO_EXPRESS_PORT:-8081}"
@echo " PostgreSQL: localhost:$${POSTGRES_PORT:-5432}"
@echo " pgAdmin: http://localhost:$${PGADMIN_PORT:-5050}"
.PHONY: docker-up-override
docker-up-override: ## Start all services using the redis override file
$(call log_progress,Starting with docker-compose.redis.yml override...)
@$(COMPOSE_REDIS) up -d
$(call log_done,All services started via override.)
@echo " Redis: localhost:$${REDIS_PORT:-6379}"
@echo " Redis Insight: http://localhost:$${REDISINSIGHT_PORT:-5540}"
.PHONY: docker-down
docker-down: ## Stop and remove all containers
$(call log_progress,Stopping all containers...)
@$(COMPOSE) --profile full down
$(call log_done,All containers stopped.)
.PHONY: docker-down-volumes
docker-down-volumes: ## Stop containers and remove volumes (clean state)
$(call log_progress,Stopping containers and removing volumes...)
@$(COMPOSE) --profile full down -v
$(call log_done,Containers stopped and volumes removed.)
.PHONY: docker-logs
docker-logs: ## Tail logs from all running containers
@$(COMPOSE) --profile full logs -f
.PHONY: docker-logs-ere
docker-logs-ere: ## Tail logs from the ERE container only
@$(COMPOSE) logs -f ere
.PHONY: docker-ps
docker-ps: ## Show status of all containers
@$(COMPOSE) --profile full ps
.PHONY: docker-restart
docker-restart: docker-down docker-up-full ## Restart the full stack
# ─── Clean ───────────────────────────────────────────────────────────────────────
.PHONY: clean
clean: ## Remove generated/cached files
$(call log_progress,Cleaning...)
@rm -rf .pytest_cache htmlcov .coverage __pycache__ .ruff_cache
@find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
$(call log_done,Clean complete.)
.PHONY: clean-docker
clean-docker: ## Remove Docker images and volumes for this project
$(call log_progress,Cleaning Docker resources...)
@$(COMPOSE) --profile full down -v --rmi local 2>/dev/null || true
@docker rmi $(IMAGE_NAME):$(IMAGE_TAG) 2>/dev/null || true
$(call log_done,Docker resources cleaned.)
.PHONY: clean-all
clean-all: clean clean-docker ## Remove all generated files and Docker resources
$(call log_done,Full clean complete.)