-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
214 lines (180 loc) · 6.2 KB
/
Makefile
File metadata and controls
214 lines (180 loc) · 6.2 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
.PHONY: clean install test dev frontend-install frontend-dev frontend-build stop wheel lint lint-fix format
# Python configuration
PYTHON = python3.12
VENV = .venv
VENV_BIN = $(VENV)/bin
SRC_DIR = src/
TEST_DIR = tests/
FRONTEND_DIR = frontend/
# Clean up Python cache files, build artifacts, and Node modules
clean:
@echo "Cleaning up..."
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
find . -type f -name "*.pyo" -delete 2>/dev/null || true
find . -type f -name "*.log" -delete 2>/dev/null || true
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
rm -rf $(VENV)
rm -rf .ruff_cache
rm -rf .pytest_cache
rm -rf htmlcov
rm -rf .coverage
rm -rf $(FRONTEND_DIR)/node_modules
rm -rf $(FRONTEND_DIR)/dist
rm -rf $(FRONTEND_DIR)/.vite
rm -rf coverage
rm -rf data
rm -rf exports
rm -f package-lock.json
rm -f $(FRONTEND_DIR)/package-lock.json
rm -rf dist
rm -rf projects
@echo "Clean complete!"
# Install frontend dependencies
frontend-install:
@echo "Installing frontend dependencies..."
cd $(FRONTEND_DIR) && npm install
@echo "Frontend installation complete!"
# Build frontend for production
frontend-build: frontend-install
@echo "Building frontend..."
cd $(FRONTEND_DIR) && npm run build
@echo "Frontend build complete!"
# Install dependencies (Python) - requires frontend to be built first
install: frontend-build
@echo "Installing dependencies..."
@if [ -d "$(VENV)" ]; then \
echo "Deleting existing virtual environment..."; \
rm -rf $(VENV); \
echo "Existing virtual environment deleted."; \
fi
@echo "Creating new virtual environment..."
@$(PYTHON) -m venv $(VENV)
@echo "New virtual environment created."
@echo "Installing package in editable mode with dev dependencies..."
@$(VENV_BIN)/pip install -e ".[dev]"
@echo "Installation complete!"
# Install all dependencies (backend + frontend) - alias for install
install-all: install
# Run frontend development server
frontend-dev:
@echo "Starting frontend dev server..."
cd $(FRONTEND_DIR) && npm run dev
# Run backend development server
backend-dev:
@echo "Starting backend dev server..."
$(VENV_BIN)/uvicorn src.main:app --reload --host 127.0.0.1 --port 8000
# Run both frontend and backend (use in separate terminals or with tmux)
dev:
@echo "To run the full application:"
@echo " Terminal 1: make backend-dev"
@echo " Terminal 2: make frontend-dev"
@echo "Then open http://localhost:5173"
# Run the full application (backend + frontend concurrently)
run:
@echo "Starting application..."
@echo "Backend: http://localhost:8000"
@echo "Frontend: http://localhost:5173"
@echo "Press Ctrl+C to stop"
$(VENV_BIN)/uvicorn src.main:app --host 127.0.0.1 --port 8000 & \
(cd $(FRONTEND_DIR) && npm run dev) & \
(sleep 2 && open http://localhost:5173) & \
trap 'kill %1 %2 %3 2>/dev/null' INT TERM; wait
# Stop all running servers (backend + frontend)
stop:
@echo "Stopping all servers..."
@-pkill -f "uvicorn src.main:app" 2>/dev/null || true
@-pkill -f "vite" 2>/dev/null || true
@-lsof -ti:8000 | xargs kill -9 2>/dev/null || true
@-lsof -ti:5173 | xargs kill -9 2>/dev/null || true
@echo "All servers stopped!"
# Type check Python code in src folder using pyright
type-check:
@echo "Running type check with pyright..."
$(VENV_BIN)/pyright $(SRC_DIR)
# Lint Python code using ruff
lint-python:
@echo "Running ruff check..."
$(VENV_BIN)/ruff check $(SRC_DIR) $(TEST_DIR)
# Lint all code (Python + frontend)
lint: lint-python frontend-lint type-check
@echo "All linting complete!"
# Fix Python code in src folder using ruff
fix-python:
@echo "Running ruff fix..."
$(VENV_BIN)/ruff check --fix $(SRC_DIR) $(TEST_DIR)
# Fix Python lint issues (alias for fix-python + frontend-lint-fix)
lint-fix: fix-python frontend-lint-fix
@echo "All lint fixes complete!"
# Fix all code (Python + frontend)
fix: fix-python frontend-lint-fix
@echo "All fixes complete!"
# Format Python code using ruff
format-python:
@echo "Running ruff format..."
$(VENV_BIN)/ruff format $(SRC_DIR) $(TEST_DIR)
# Format all code (Python + frontend)
format: format-python frontend-format
@echo "All formatting complete!"
# Run Python tests with pytest
test-python:
@echo "Running Python tests with pytest..."
$(VENV_BIN)/pytest $(TEST_DIR) -v
# Run all tests (Python + frontend)
test: test-python frontend-test-run
@echo "All tests complete!"
# Run tests with coverage report
test-cov:
@echo "Running tests with coverage..."
$(VENV_BIN)/pytest $(TEST_DIR) --cov=$(SRC_DIR) --cov-report=html --cov-report=term -v
@echo "Coverage report generated in coverage/"
# Frontend linting and type checking
frontend-lint:
@echo "Running frontend linting..."
cd $(FRONTEND_DIR) && npm run lint
frontend-lint-fix:
@echo "Fixing frontend lint issues..."
cd $(FRONTEND_DIR) && npm run lint:fix
frontend-type-check:
@echo "Running frontend type check..."
cd $(FRONTEND_DIR) && npm run type-check
frontend-format:
@echo "Formatting frontend code..."
cd $(FRONTEND_DIR) && npm run format
# Frontend testing
frontend-test:
@echo "Running frontend tests..."
cd $(FRONTEND_DIR) && npm run test
frontend-test-run:
@echo "Running frontend tests (single run)..."
cd $(FRONTEND_DIR) && npm run test:run
frontend-test-cov:
@echo "Running frontend tests with coverage..."
cd $(FRONTEND_DIR) && npm run test:coverage
# Run all checks
check-all: type-check fix format test frontend-type-check frontend-lint frontend-test-run
@echo "All checks complete!"
# Build package for distribution
build:
@echo "Building package..."
$(VENV_BIN)/pip install build
$(VENV_BIN)/python -m build
@echo "Package built in dist/"
# Build wheel for distribution (matches publish.yml workflow)
wheel: frontend-build
@echo "Building wheel..."
$(VENV_BIN)/pip install build
$(VENV_BIN)/python -m build --wheel
@echo "Wheel built in dist/"
# Publish to PyPI (requires twine and PyPI credentials)
#publish:
# @echo "Publishing to PyPI..."
# $(VENV_BIN)/pip install twine
# $(VENV_BIN)/twine upload dist/*
# @echo "Published to PyPI!"
# Publish to TestPyPI (for testing)
#publish-test:
# @echo "Publishing to TestPyPI..."
# $(VENV_BIN)/pip install twine
# $(VENV_BIN)/twine upload --repository testpypi dist/*
# @echo "Published to TestPyPI!"