forked from josephsenior/Grinta-Coding-Agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
260 lines (219 loc) · 8.87 KB
/
Copy pathMakefile
File metadata and controls
260 lines (219 loc) · 8.87 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
PYTHON ?= uv run python
BOOTSTRAP := python scripts/bootstrap_env.py
.DEFAULT_GOAL := help
.PHONY: pretest
pretest:
@$(PYTHON) scripts/dev/clean_pycache.py
.PHONY: test-unit
test-unit: pretest
@uv run pytest -q backend/tests/unit
# Integration/e2e/stress are excluded by default in pytest.ini (-m "not integration").
# Run them explicitly with -m integration or by path with marker override.
.PHONY: test-integration
test-integration: pretest
@uv run pytest backend/tests/integration -m integration -v
.PHONY: test-e2e
test-e2e: pretest
@uv run pytest backend/tests/e2e -m integration -v
.PHONY: test-stress
test-stress: pretest
@uv run pytest backend/tests/stress -v
.PHONY: reliability-gate
reliability-gate: pretest
@uv run python backend/scripts/verify/reliability_gate.py --phase full
.PHONY: reliability-gate-integration
reliability-gate-integration: pretest
@uv run python backend/scripts/verify/reliability_gate.py --phase full --include-integration --include-stress
.PHONY: ga-onboarding-gate
ga-onboarding-gate:
@uv run python backend/scripts/verify/ga_onboarding_gate.py --update-status
.PHONY: docker-up
docker-up:
@if [ -f "docker-compose.yml" ] || [ -f "compose.yml" ]; then \
docker compose up --build; \
else \
echo "No docker-compose file found. Docker path is community/experimental in this repo."; \
echo 'Use: docker run -it --rm -v "$$PWD:/work" -w /work -e LLM_API_KEY=$${LLM_API_KEY} ghcr.io/josephsenior/grinta:latest'; \
exit 1; \
fi
.PHONY: docker-up-detached
docker-up-detached:
@if [ -f "docker-compose.yml" ] || [ -f "compose.yml" ]; then \
docker compose up --build -d; \
else \
echo "No docker-compose file found. Docker path is community/experimental in this repo."; \
exit 1; \
fi
.PHONY: docker-up-no-db
docker-up-no-db:
@if [ -f "docker-compose.yml" ] || [ -f "compose.yml" ]; then \
docker compose up --build; \
else \
echo "No docker-compose file found. Docker path is community/experimental in this repo."; \
exit 1; \
fi
# Makefile for the current Grinta CLI/TUI contributor workflow
SHELL=/usr/bin/env bash
# Variables
BACKEND_HOST ?= "127.0.0.1"
BACKEND_PORT ?= 3000
PRE_COMMIT_CONFIG_PATH = "./.pre-commit-config.yaml"
PYTHON_VERSION = 3.12
# ANSI color codes
GREEN=$(shell tput -Txterm setaf 2)
YELLOW=$(shell tput -Txterm setaf 3)
RED=$(shell tput -Txterm setaf 1)
BLUE=$(shell tput -Txterm setaf 6)
RESET=$(shell tput -Txterm sgr0)
# Build
build:
@echo "$(GREEN)Building project...$(RESET)"
@$(MAKE) -s check-dependencies
@$(MAKE) -s install-python-dependencies
@$(MAKE) -s install-pre-commit-hooks
@echo "$(GREEN)Build completed successfully.$(RESET)"
check-dependencies:
@echo "$(YELLOW)Checking dependencies...$(RESET)"
@$(MAKE) -s check-system
@$(MAKE) -s check-python
@$(MAKE) -s check-uv
@$(MAKE) -s check-tmux
@echo "$(GREEN)Dependencies checked successfully.$(RESET)"
check-system:
@echo "$(YELLOW)Checking system...$(RESET)"
@if [ "$(shell uname)" = "Darwin" ]; then \
echo "$(BLUE)macOS detected.$(RESET)"; \
elif [ "$(shell uname)" = "Linux" ]; then \
if [ -f "/etc/manjaro-release" ]; then \
echo "$(BLUE)Manjaro Linux detected.$(RESET)"; \
else \
echo "$(BLUE)Linux detected.$(RESET)"; \
fi; \
elif [ "$$(uname -r | grep -i microsoft)" ]; then \
echo "$(BLUE)Windows Subsystem for Linux detected.$(RESET)"; \
else \
echo "$(RED)Unsupported system detected. Please use macOS, Linux, or Windows Subsystem for Linux (WSL).$(RESET)"; \
exit 1; \
fi
check-python:
@echo "$(YELLOW)Checking Python installation...$(RESET)"
@if command -v python$(PYTHON_VERSION) > /dev/null; then \
echo "$(BLUE)$(shell python$(PYTHON_VERSION) --version) is already installed.$(RESET)"; \
elif command -v uv > /dev/null; then \
echo "$(BLUE)uv will manage the python version.$(RESET)"; \
else \
echo "$(RED)Python $(PYTHON_VERSION) is not installed. Please install Python $(PYTHON_VERSION) or uv to continue.$(RESET)"; \
exit 1; \
fi
check-uv:
@echo "$(YELLOW)Checking uv installation...$(RESET)"
@if command -v uv > /dev/null; then \
echo "$(BLUE)$(shell uv --version) is already installed.$(RESET)"; \
else \
echo "$(RED)uv is not installed. You can install it by running:$(RESET)"; \
echo "$(RED)curl -LsSf https://astral.sh/uv/install.sh | sh$(RESET)"; \
exit 1; \
fi
check-tmux:
@echo "$(YELLOW)Ensuring tmux is installed (Linux/WSL)...$(RESET)"
@uv run python -c "from backend.utils.linux_host_tools import ensure_linux_host_tools; ensure_linux_host_tools()" 2>/dev/null || true
@if command -v tmux > /dev/null; then \
echo "$(BLUE)$(shell tmux -V) is ready.$(RESET)"; \
else \
echo "$(YELLOW)tmux is not available yet; Grinta will retry on launch.$(RESET)"; \
fi
.PHONY: bootstrap-base
bootstrap-base:
@$(BOOTSTRAP) base
.PHONY: bootstrap-browser
bootstrap-browser:
@$(BOOTSTRAP) browser
.PHONY: bootstrap-dev
bootstrap-dev:
@$(BOOTSTRAP) dev
.PHONY: bootstrap-dev-test
bootstrap-dev-test:
@$(BOOTSTRAP) dev-test
.PHONY: bootstrap-dev-test-browser
bootstrap-dev-test-browser:
@$(BOOTSTRAP) dev-test-browser
install-python-dependencies:
@echo "$(GREEN)Syncing Python dependencies...$(RESET)"
@if [ -z "${TZ}" ]; then \
echo "Defaulting TZ (timezone) to UTC"; \
export TZ="UTC"; \
fi
@if [ "$(shell uname)" = "Darwin" ]; then \
echo "$(BLUE)Installing chroma-hnswlib for macOS...$(RESET)"; \
export HNSWLIB_NO_NATIVE=1; \
uv pip install chroma-hnswlib; \
fi
@$(MAKE) -s bootstrap-base
@echo "$(GREEN)Python dependencies synced successfully.$(RESET)"
install-pre-commit-hooks: check-python check-uv install-python-dependencies
@echo "$(YELLOW)Installing pre-commit hooks...$(RESET)"
@git config --unset-all core.hooksPath || true
@uv run pre-commit install --config $(PRE_COMMIT_CONFIG_PATH)
@echo "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"
lint: install-pre-commit-hooks
@echo "$(YELLOW)Running linters...$(RESET)"
@uv run pre-commit run --all-files --show-diff-on-failure --config $(PRE_COMMIT_CONFIG_PATH)
# Proto compilation
.PHONY: compile-protos
compile-protos:
@echo "$(GREEN)Compiling Protocol Buffer definitions...$(RESET)"
@uv run python backend/scripts/build/compile_protos.py
@echo "$(GREEN)Proto compilation completed.$(RESET)"
.PHONY: update-openapi
update-openapi:
@echo "$(GREEN)Regenerating OpenAPI schema...$(RESET)"
@uv run python backend/scripts/build/update_openapi.py
@echo "$(GREEN)OpenAPI schema updated at openapi.json.$(RESET)"
# Start backend
start-backend:
@echo "$(YELLOW)Starting backend...$(RESET)"
@uv run uvicorn backend.execution.action_execution_server:app --host $(BACKEND_HOST) --port $(BACKEND_PORT) --reload --reload-exclude "./workspace"
.PHONY: init-cli
init-cli:
@echo "$(YELLOW)Launching interactive CLI setup...$(RESET)"
@uv run python -m backend.cli.entry init
.PHONY: run-cli
run-cli:
@echo "$(YELLOW)Launching Grinta from the source checkout...$(RESET)"
@uv run python -m backend.cli.entry
.PHONY: smoke-onboarding
smoke-onboarding:
@echo "$(YELLOW)Running onboarding smoke checks (wheel + source)...$(RESET)"
@uv build --wheel
@WHEEL_DIR=./dist ./scripts/smoke/smoke_install.sh
@./scripts/smoke/smoke_source_onboarding.sh
@echo "$(GREEN)Onboarding smoke checks completed.$(RESET)"
.PHONY: run
run: run-cli
.PHONY: setup-config
setup-config: init-cli
# Clean up all caches
clean:
@echo "$(YELLOW)Cleaning up caches...$(RESET)"
@rm -rf backend/.cache
@echo "$(GREEN)Caches cleaned up successfully.$(RESET)"
# Help
help:
@echo "$(BLUE)Usage: make [target]$(RESET)"
@echo "Targets:"
@echo " $(GREEN)bootstrap-dev-test$(RESET) - Sync the source-checkout dev + test dependency profile."
@echo " $(GREEN)init-cli$(RESET) - Run the interactive 'grinta init' flow from source."
@echo " $(GREEN)run-cli$(RESET) - Launch the Grinta CLI/TUI from source."
@echo " $(GREEN)test-unit$(RESET) - Run the unit test suite."
@echo " $(GREEN)reliability-gate$(RESET) - Run the full local reliability verification gate."
@echo " $(GREEN)smoke-onboarding$(RESET) - Build a wheel and run wheel + source onboarding smokes."
@echo " $(GREEN)lint$(RESET) - Run pre-commit across the repository."
@echo " $(GREEN)build$(RESET) - Bootstrap dependencies and install pre-commit hooks."
@echo " $(GREEN)run$(RESET) - Compatibility alias for run-cli."
@echo " $(GREEN)setup-config$(RESET) - Compatibility alias for init-cli."
@echo " $(GREEN)start-backend$(RESET) - Legacy maintenance target for the action execution server."
@echo " $(GREEN)compile-protos$(RESET) - Rebuild protobuf-generated files."
@echo " $(GREEN)update-openapi$(RESET) - Refresh the generated OpenAPI schema."
@echo " $(GREEN)help$(RESET) - Show this target summary."
# Phony targets
.PHONY: build check-dependencies check-system check-python check-uv install-python-dependencies install-pre-commit-hooks lint start-backend init-cli run-cli smoke-onboarding run setup-config clean help