-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile_run
More file actions
195 lines (163 loc) · 8.69 KB
/
Makefile_run
File metadata and controls
195 lines (163 loc) · 8.69 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
# ANSI color codes
GREEN=\033[0;32m
YELLOW=\033[0;33m
RED=\033[0;31m
BLUE=\033[0;34m
RESET=\033[0m
PROJECT_ROOT=.
#########################################################
# Run the hackbot in isolation
#########################################################
hackbot_async: update_python_dep ## Test hackbot in async mode
@echo -e "$(GREEN)♨️Running Hackbot test target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests make async
@echo -e "$(GREEN)✅Hackbot test target completed.$(RESET)"
hackbot_debug: update_python_dep ## Run hackbot debug tests
@echo -e "$(GREEN)♨️Running Hackbot debug target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests make debug
@echo -e "$(GREEN)✅Hackbot debug target completed.$(RESET)"
hackbot_deterministic_test: update_python_dep ## Run deterministic tests for hackbot
@echo -e "$(GREEN)♨️Running Hackbot deterministic test target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests PYTHONPATH=.. HACKBOT_TEST_MODE=deterministic rye run pytest -m "not slow_and_nondeterministic and not nondeterministic and not slow and not gpu_forge"
@echo -e "$(GREEN)✅Hackbot deterministic test target completed.$(RESET)"
hackbot_deterministic_test_nightly: update_python_dep
@echo -e "$(GREEN)♨️Running Hackbot deterministic nightly test target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests PYTHONPATH=.. HACKBOT_TEST_MODE=slow rye run pytest -m "not slow_and_nondeterministic and not nondeterministic"
@echo -e "$(GREEN)✅Hackbot deterministic nightly test target completed.$(RESET)"
hackbot_nondeterministic_test: update_python_dep ## Run nondeterministic tests for hackbot
@echo -e "$(GREEN)♨️Running Hackbot nondeterministic test target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests PYTHONPATH=.. HACKBOT_TEST_MODE=nondeterministic rye run pytest -m "not slow"
@echo -e "$(GREEN)✅Hackbot nondeterministic test target completed.$(RESET)"
hackbot_all_tests: update_python_dep ## Run all tests for hackbot
@echo -e "$(GREEN)♨️Running Hackbot all tests target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests PYTHONPATH=.. HACKBOT_TEST_MODE=all rye run pytest
@echo -e "$(GREEN)✅Hackbot all tests target completed.$(RESET)"
hackbot_eval: update_python_dep ## Run static eval for hackbot
@echo -e "$(GREEN)♨️Running Hackbot eval target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=eval make test-static-eval-tiny
@echo -e "$(GREEN)✅Hackbot eval target completed.$(RESET)"
hackbot_gpu_forge_test: update_python_dep ## Run gpu-forge specific tests for hackbot
@echo -e "$(GREEN)♨️Running Hackbot gpu-forge test target...$(RESET)"
cd hackbot && HACKBOT_RUN_MODE=tests PYTHONPATH=.. HACKBOT_TEST_MODE=gpu_forge rye run pytest -m "gpu_forge"
@echo -e "$(GREEN)✅Hackbot gpu-forge test target completed.$(RESET)"
#########################################################
# Run the hackbot api in isolation
#########################################################
hackbot_api: update_python_dep ## Run the hackbot api
@echo -e "$(GREEN)♨️Running Hackbot API...$(RESET)"
+HACKBOT_RUN_MODE=api_server $(MAKE) -C api run
@echo -e "$(GREEN)✅Hackbot API done.$(RESET)"
hackbot_api_test: update_python_dep
@echo -e "$(GREEN)♨️Running Hackbot API test...$(RESET)"
@PYTHONPATH=. HACKBOT_RUN_MODE=api_server_test rye run pytest api/tests/
@echo -e "$(GREEN)✅Hackbot API test done.$(RESET)"
#########################################################
# Run the full project
#########################################################
# Without needing to refresh deps
run: ## Run the full project
@echo -e "$(GREEN)✅Full project launch...$(RESET)"
+make hackbot_api
@echo -e "$(GREEN)✅Full project launch completed.$(RESET)"
full_run: install_deps | run ## Run the full project with deps update
@echo -e "$(GREEN)✅Full dep update and project launch completed.$(RESET)"
########################################################
# Run the e2e tests locally / quickly
########################################################
local_run_e2e_test_script:
@echo -e "$(GREEN)♨️Running local E2E test script...$(RESET)"
# Copy over .env to the devops .build_vars.env
@cp .env devops/.build_vars.env
@# Run the e2e test script
@HACKBOT_LOCAL_MODE=true ./e2e_tests/run_e2e_tests.sh
@echo -e "$(GREEN)✅Local E2E test script completed.$(RESET)"
local_e2e_tests: ## Run the e2e tests
@echo -e "$(GREEN)♨️Running local E2E tests...$(RESET)"
@echo -e "$(YELLOW)Starting API server in background...$(RESET)"
@cd api && HACKBOT_RUN_MODE=api_server ./run_hackbot_api.sh &
@API_PID=$$!
@echo -e "$(YELLOW)Waiting for API server to be ready...$(RESET)"
@until curl -f http://localhost:5000/ping >/dev/null 2>&1; do \
echo "Waiting for API server to be ready..."; \
sleep 2; \
done
@echo -e "$(GREEN)API server is ready!$(RESET)"
@make local_run_e2e_test_script
@echo -e "$(YELLOW)Stopping API server...$(RESET)"
@kill $$API_PID || true
@wait $$API_PID 2>/dev/null || true
@echo -e "$(GREEN)✅Local E2E tests completed.$(RESET)"
@exit 0
.PHONY: check_db
check_db:
@echo "🔍 Running checks for api/server_async.py (database schema verification)..."
@PYTHONPATH=. rye run python api/server_async.py --check
@if [ $$? -eq 0 ]; then \
echo "✅ Precheck passed: Database schema is consistent!"; \
else \
echo "❌ Precheck failed: Database schema is inconsistent!"; \
exit 1; \
fi
#########################################################
# Alembic / Database migration functions
#########################################################
alembic_upgrade_dev: update_python_dep ## Apply alembic migration upgrade in development mode
@echo -e "$(GREEN)♨️Running Alembic upgrade (development mode)...$(RESET)"
@HACKBOT_MODE=development rye run alembic upgrade head
@if [ $$? -eq 0 ]; then \
echo -e "$(GREEN)✅Alembic upgrade (development) completed successfully.$(RESET)"; \
else \
echo -e "$(RED)❌Alembic upgrade (development) failed!$(RESET)"; \
exit 1; \
fi
alembic_upgrade_prod: update_python_dep ## Apply alembic migration upgrade in production mode
@echo -e "$(GREEN)♨️Running Alembic upgrade (production mode)...$(RESET)"
@HACKBOT_MODE=production rye run alembic upgrade head
@if [ $$? -eq 0 ]; then \
echo -e "$(GREEN)✅Alembic upgrade (production) completed successfully.$(RESET)"; \
else \
echo -e "$(RED)❌Alembic upgrade (production) failed!$(RESET)"; \
exit 1; \
fi
alembic_downgrade_dev: update_python_dep ## Apply alembic migration downgrade in development mode
@echo -e "$(YELLOW)⚠️Running Alembic downgrade (development mode)...$(RESET)"
@echo -e "$(YELLOW)This will revert the last migration.$(RESET)"
@read -p "Are you sure you want to continue? (y/N): " confirm && [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ] || (echo "Cancelled." && exit 1)
@HACKBOT_MODE=development rye run alembic downgrade -1
@if [ $$? -eq 0 ]; then \
echo -e "$(GREEN)✅Alembic downgrade (development) completed successfully.$(RESET)"; \
else \
echo -e "$(RED)❌Alembic downgrade (development) failed!$(RESET)"; \
exit 1; \
fi
alembic_downgrade_prod: update_python_dep ## Apply alembic migration downgrade in production mode
@echo -e "$(YELLOW)⚠️Running Alembic downgrade (production mode)...$(RESET)"
@echo -e "$(RED)⚠️ WARNING: This will revert the last migration in PRODUCTION!$(RESET)"
@echo -e "$(RED)This action cannot be undone easily.$(RESET)"
@read -p "Type 'YES' to confirm production downgrade: " confirm && [ "$$confirm" = "YES" ] || (echo "Cancelled. Must type exactly 'YES' to confirm." && exit 1)
@HACKBOT_MODE=production rye run alembic downgrade -1
@if [ $$? -eq 0 ]; then \
echo -e "$(GREEN)✅Alembic downgrade (production) completed successfully.$(RESET)"; \
else \
echo -e "$(RED)❌Alembic downgrade (production) failed!$(RESET)"; \
exit 1; \
fi
alembic_history: ## Show alembic migration history
@echo -e "$(BLUE)📋Showing Alembic migration history...$(RESET)"
@rye run alembic history --verbose
alembic_current: ## Show current alembic migration version
@echo -e "$(BLUE)📍Showing current Alembic migration version...$(RESET)"
@rye run alembic current --verbose
alembic_generate: update_python_dep ## Generate a new alembic migration (requires message via MIGRATION_MESSAGE)
@if [ -z "$(MIGRATION_MESSAGE)" ]; then \
echo -e "$(RED)❌Error: MIGRATION_MESSAGE is required. Use: make alembic_generate MIGRATION_MESSAGE='your message'$(RESET)"; \
exit 1; \
fi
@echo -e "$(GREEN)♨️Generating new Alembic migration: $(MIGRATION_MESSAGE)$(RESET)"
@HACKBOT_MODE=development rye run alembic revision --autogenerate -m "$(MIGRATION_MESSAGE)"
@if [ $$? -eq 0 ]; then \
echo -e "$(GREEN)✅Alembic migration generated successfully.$(RESET)"; \
else \
echo -e "$(RED)❌Alembic migration generation failed!$(RESET)"; \
exit 1; \
fi