-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (134 loc) · 6.75 KB
/
Copy pathMakefile
File metadata and controls
174 lines (134 loc) · 6.75 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
# =============================================================================
# DishGraph - Developer Makefile
# =============================================================================
COMPOSE := docker compose --env-file .env.dev -f docker-compose.dev.yml
BACKEND_TEST_ENV := DISHGRAPH_PUBLIC_PAGE_CACHE_TTL_SECONDS=0 DISHGRAPH_SEARCH_BACKEND=database DISHGRAPH_MEILI_SYNC_DURING_TESTS=False DISHGRAPH_TYPESENSE_SYNC_DURING_TESTS=False DISHGRAPH_AI_PROVIDER=fake DISHGRAPH_AI_RUN_FAKE_SYNCHRONOUSLY=True CELERY_TASK_ALWAYS_EAGER=True
BACKEND_TEST_FLAGS ?= --keepdb --parallel 1 --failfast
.DEFAULT_GOAL := help
.PHONY: help setup up down restart rebuild logs logs-backend logs-worker logs-search logs-typesense ps \
shell-backend bash-backend shell-db migrate makemigrations seed seed-agentic-initial \
reset-db wait-backend test test-backend-focused test-backend-light test-backend-full admin worker typesense-rollback reindex-search clean \
frontend-install frontend-dev frontend-typecheck frontend-lint frontend-test frontend-test-light frontend-build
help: ## Show this help
@echo "DishGraph dev environment"
@echo ""
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
setup: ## First-time setup: copy env, build, start, migrate, seed
@test -f .env.dev || (echo "Missing .env.dev. Run: cp .env.dev.example .env.dev" && exit 1)
$(COMPOSE) build
$(COMPOSE) up -d db redis meilisearch backend
@"$(MAKE)" --no-print-directory wait-backend
@"$(MAKE)" --no-print-directory seed
up: ## Start backend infrastructure
$(COMPOSE) up -d db redis meilisearch backend
@$(COMPOSE) ps
down: ## Stop services, preserving volumes
$(COMPOSE) down
restart: ## Restart services
$(COMPOSE) restart
rebuild: ## Rebuild dev images from scratch
$(COMPOSE) build --no-cache
logs: ## Tail all logs
$(COMPOSE) logs -f --tail=100
logs-backend: ## Tail backend logs
$(COMPOSE) logs -f --tail=100 backend
logs-worker: ## Tail worker logs
$(COMPOSE) logs -f --tail=100 worker
logs-search: ## Tail Meilisearch logs
$(COMPOSE) logs -f --tail=100 meilisearch
logs-typesense: ## Tail Typesense rollback logs
$(COMPOSE) --profile typesense-rollback logs -f --tail=100 typesense
ps: ## Show service status
$(COMPOSE) ps
shell-backend: ## Django shell inside backend container
$(COMPOSE) exec backend python manage.py shell
bash-backend: ## Bash shell inside backend container
$(COMPOSE) exec backend bash
shell-db: ## psql into the dev database
$(COMPOSE) exec db psql -U dishgraph -d dishgraph
migrate: ## Apply Django migrations
$(COMPOSE) exec backend python manage.py migrate
makemigrations: ## Generate Django migrations
$(COMPOSE) exec backend python manage.py makemigrations
seed: ## Reset and seed realistic local dev content
$(COMPOSE) --profile seed run --rm backend-init
seed-agentic-initial: ## Reset and seed agentic baseline users and registries
$(COMPOSE) exec backend python manage.py seed_realistic --seed-package agentic_initial
reset-db: ## DESTRUCTIVE: drop db volume and restart backend
$(COMPOSE) down -v
$(COMPOSE) up -d db redis meilisearch backend
@"$(MAKE)" --no-print-directory wait-backend
wait-backend: ## Wait until backend healthcheck is healthy
@echo "Waiting for backend healthcheck..."
@cid=$$($(COMPOSE) ps -q backend); \
if [ -z "$$cid" ]; then \
echo "backend container is not running."; \
exit 1; \
fi; \
i=1; \
while [ $$i -le 120 ]; do \
status=$$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' $$cid 2>/dev/null || true); \
if [ "$$status" = "healthy" ]; then \
echo "backend is healthy."; \
exit 0; \
fi; \
if [ "$$status" = "exited" ] || [ "$$status" = "dead" ]; then \
$(COMPOSE) logs --tail=100 backend; \
exit 1; \
fi; \
sleep 2; \
i=$$((i + 1)); \
done; \
$(COMPOSE) logs --tail=100 backend; \
exit 1
test: test-backend-focused ## Run one focused backend test label; set TEST=app.tests.module.Class.test_method
test-backend-focused: ## Run one focused backend test with serial DB-backed search; set TEST=...
@test -n "$(TEST)" || (echo "Usage: make test TEST=app.tests.module.Class.test_method" && exit 2)
@if [ "$(ALLOW_SEARCH_TESTS)" != "1" ]; then \
case " $(TEST) " in *search.tests*|*" search "*) echo "Search tests are disabled here. Set ALLOW_SEARCH_TESTS=1 only when intentionally running them."; exit 2;; esac; \
fi
$(COMPOSE) exec -T backend env $(BACKEND_TEST_ENV) python manage.py test $(TEST) $(BACKEND_TEST_FLAGS)
test-backend-light: ## Run explicit backend labels through throttled settings; set TEST_LABELS="accounts.tests..."
@test -n "$(TEST_LABELS)" || (echo "Usage: make test-backend-light TEST_LABELS=\"accounts.tests.test_module.TestCase.test_method\"" && exit 2)
@if [ "$(ALLOW_SEARCH_TESTS)" != "1" ]; then \
case " $(TEST_LABELS) " in *search.tests*|*" search "*) echo "Search tests are disabled here. Set ALLOW_SEARCH_TESTS=1 only when intentionally running them."; exit 2;; esac; \
fi
$(COMPOSE) exec -T backend env $(BACKEND_TEST_ENV) python manage.py test $(TEST_LABELS) $(BACKEND_TEST_FLAGS)
test-backend-full: ## Guarded full backend suite; requires ALLOW_FULL_TESTS=1 ALLOW_SEARCH_TESTS=1
@if [ "$(ALLOW_FULL_TESTS)" != "1" ]; then \
echo "Full backend tests are guarded to avoid freezing Docker. Use focused labels, or set ALLOW_FULL_TESTS=1 ALLOW_SEARCH_TESTS=1 intentionally."; \
exit 2; \
fi
@if [ "$(ALLOW_SEARCH_TESTS)" != "1" ]; then \
echo "Full backend tests include search tests. Set ALLOW_SEARCH_TESTS=1 only when intentionally running them."; \
exit 2; \
fi
$(COMPOSE) exec -T backend env $(BACKEND_TEST_ENV) python manage.py test $(BACKEND_TEST_FLAGS)
admin: ## Create Django superuser
$(COMPOSE) exec backend python manage.py createsuperuser
worker: ## Start Celery worker
$(COMPOSE) up -d worker
typesense-rollback: ## Start Typesense rollback service
$(COMPOSE) --profile typesense-rollback up -d typesense
reindex-search: ## Rebuild public search index
$(COMPOSE) exec backend python manage.py rebuild_search_index
frontend-install: ## Install frontend workspace dependencies
pnpm --dir frontend install
frontend-dev: ## Start frontend dev server
pnpm --dir frontend dev
frontend-typecheck: ## Run frontend TypeScript checks
pnpm --dir frontend typecheck
frontend-lint: ## Run frontend lint checks
pnpm --dir frontend lint
frontend-test: ## Run frontend unit/component tests
pnpm --dir frontend test
frontend-test-light: ## Run frontend tests with serial Vitest workers
pnpm --dir frontend test:light
frontend-build: ## Build frontend app
pnpm --dir frontend build
clean: ## DESTRUCTIVE: remove containers, volumes, and dangling images
$(COMPOSE) down -v --remove-orphans
docker image prune -f