-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
215 lines (185 loc) · 8.42 KB
/
Makefile
File metadata and controls
215 lines (185 loc) · 8.42 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
.PHONY: help lint format lint-python lint-js lint-css format-python format-js format-css test test-unit test-integration test-e2e test-routers test-coverage test-quick test-playwright test-perf test-perf-api test-perf-ocr test-perf-ocr-accuracy test-perf-load install install-hooks run clean ci-lint screenshots screenshot-library
PYTHON_FILES := $(shell find . -name '*.py' -not -path './.venv/*' -not -path './node_modules/*' -not -path './.node_modules/*')
JS_FILES := static/js/*.js
CSS_FILES := static/css/*.css
help:
@echo "Curator - Build Commands"
@echo ""
@echo "Setup:"
@echo " make install Install all dependencies"
@echo " make install-hooks Install Git pre-push hooks"
@echo ""
@echo "Development:"
@echo " make run Start the application"
@echo " make format Format all code (Python, JS, CSS)"
@echo " make lint Run all linters"
@echo " make ci-lint Run CI linters"
@echo " make screenshots Capture all UI screenshots (requires running app)"
@echo " make screenshot-library Capture library tab screenshot only"
@echo ""
@echo "Linting:"
@echo " make lint-python Lint Python files (pylint + flake8)"
@echo " make lint-js Lint JavaScript files"
@echo " make lint-css Lint CSS files"
@echo ""
@echo "Formatting:"
@echo " make format-python Format Python with Black"
@echo " make format-js Format JavaScript with Prettier"
@echo " make format-css Format CSS with Prettier"
@echo ""
@echo "Testing:"
@echo " make test Run all tests with pytest"
@echo " make test-unit Run unit tests only (fast)"
@echo " make test-integration Run integration tests only"
@echo " make test-e2e Run end-to-end tests only"
@echo " make test-routers Run router/API tests only"
@echo " make test-coverage Run tests with coverage report"
@echo " make test-quick Quick syntax check of test files"
@echo " make test-playwright Run Playwright browser tests (requires running app)"
@echo ""
@echo "Performance Testing:"
@echo " make test-perf Run all performance tests (API + OCR)"
@echo " make test-perf-api Benchmark API endpoints"
@echo " make test-perf-ocr Benchmark OCR (DPI vs speed vs accuracy)"
@echo " make test-perf-ocr-accuracy Run OCR accuracy-only tests with output"
@echo " make test-perf-load Run Locust load tests"
@echo ""
@echo "Cleanup:"
@echo " make clean Remove cache, build, and temp files"
# Installation
install:
@echo "📦 Installing dependencies..."
pip install -r requirements.txt > /dev/null 2>&1
npm install > /dev/null 2>&1
@echo "✓ Dependencies installed"
install-hooks:
@./setup-hooks.sh
# Running the app
run:
@echo "🚀 Starting application..."
.venv/bin/python ./main.py
# Linting
lint: lint-python lint-js lint-css
@echo "✅ Linting complete!"
lint-python:
@echo "📝 Linting Python files..."
@.venv/bin/python -m pylint --fail-under=7.0 $(PYTHON_FILES) > /dev/null 2>&1 && echo " ✓ pylint passed" || echo " ⚠ Some Python issues found"
@.venv/bin/python -m flake8 $(PYTHON_FILES) > /dev/null 2>&1 && echo " ✓ flake8 passed" || echo " ⚠ Some style issues found"
lint-js:
@echo "📜 Linting JavaScript files..."
@npx eslint $(JS_FILES) 2>/dev/null || echo " ⚠ Some JavaScript issues found"
lint-css:
@echo "🎨 Linting CSS files..."
@npx stylelint $(CSS_FILES) 2>/dev/null || echo " ⚠ Some CSS issues found"
# CI Linting (matches GitHub Actions exactly)
ci-lint:
@echo "🔍 Running CI linters..."
@echo ""
@echo "📝 Running pylint..."
@.venv/bin/python -m pylint --fail-under=7.0 --recursive=y . --ignore=.venv,node_modules || true
@echo ""
@echo "📝 Running flake8..."
@find . -name '*.py' -not -path './.venv/*' -not -path './node_modules/*' -print0 | xargs -0 .venv/bin/python -m flake8
@echo ""
@echo "🐍 Checking Black formatting..."
@find . -name '*.py' -not -path './.venv/*' -not -path './node_modules/*' -print0 | xargs -0 .venv/bin/python -m black --check --line-length=120
@echo ""
@echo "📜 Running eslint..."
@npx --no-install eslint $(JS_FILES)
@echo ""
@echo "🎨 Running stylelint..."
@npx --no-install stylelint $(CSS_FILES)
@echo ""
@echo "✅ All CI linters passed!"
# Formatting
format: format-python format-js format-css
@echo "✅ Formatting complete!"
format-python:
@echo "🐍 Formatting Python files..."
@black --line-length=120 $(PYTHON_FILES) 2>&1 | grep -E "reformatted|unchanged" || true
format-js:
@echo "📝 Formatting JavaScript files..."
@npx prettier --write $(JS_FILES) 2>&1 | grep -E "ms|error" || true
format-css:
@echo "🎨 Formatting CSS files..."
@npx prettier --write $(CSS_FILES) 2>&1 | grep -E "ms|error" || true
# Testing
test:
@echo "🧪 Running all tests (excluding performance tests)..."
@.venv/bin/python -m pytest tests/ -v --tb=short -m "not slow" 2>&1 | tail -50 || echo "⚠ Some tests failed"
@echo "✅ Test run completed!"
test-unit:
@echo "🧪 Running unit tests (fast)..."
@.venv/bin/python -m pytest tests/unit/ -v --tb=short
@echo "✅ Unit tests completed!"
test-integration:
@echo "🧪 Running integration tests..."
@.venv/bin/python -m pytest tests/integration/ -v --tb=short
@echo "✅ Integration tests completed!"
test-e2e:
@echo "🧪 Running end-to-end tests..."
@.venv/bin/python -m pytest tests/e2e/ -v --tb=short
@echo "✅ E2E tests completed!"
test-routers:
@echo "🧪 Running router tests..."
@.venv/bin/python -m pytest tests/unit/web/routers/ -v --tb=short
@echo "✅ Router tests completed!"
test-playwright:
@echo "🎭 Running Playwright browser tests (app must be running)..."
CURATOR_TEST_USER=$${CURATOR_TEST_USER:-admin} CURATOR_TEST_PASSWORD=$${CURATOR_TEST_PASSWORD:-adminadmin} npx playwright test
@echo "✅ Playwright tests completed!"
test-coverage:
@echo "🧪 Running tests with coverage (excluding performance tests)..."
@.venv/bin/python -m pytest tests/ --cov=. --cov-report=term-missing --cov-report=html -m "not slow"
@echo "✅ Coverage report generated in htmlcov/"
test-quick:
@echo "🧪 Quick test (syntax check only)..."
@find tests/ -name "test_*.py" -exec .venv/bin/python -m py_compile {} + && echo "✅ All test files compile"
# Performance testing
test-perf: test-perf-api test-perf-ocr
@echo "✅ Performance testing complete!"
test-perf-api:
@echo "🚀 Running API performance benchmarks..."
@.venv/bin/python -m pytest tests/performance/test_api_benchmarks.py --benchmark-only -v \
--benchmark-columns=min,max,mean,stddev,ops \
--benchmark-sort=mean
@echo "✅ API benchmarks completed!"
test-perf-ocr:
@echo "🔬 Running OCR performance benchmarks (DPI vs speed vs accuracy)..."
@.venv/bin/python -m pytest tests/performance/test_ocr_benchmarks.py --benchmark-only -v \
--benchmark-columns=min,max,mean,stddev,ops \
--benchmark-sort=mean \
--benchmark-min-rounds=3
@echo "✅ OCR benchmarks completed!"
test-perf-ocr-accuracy:
@echo "🎯 Running OCR accuracy tests..."
@.venv/bin/python -m pytest tests/performance/test_ocr_benchmarks.py -k accuracy -v -s
@echo "✅ OCR accuracy tests completed!"
test-perf-load:
@echo "🔥 Running Locust load tests..."
@echo "⚠️ Make sure the app is running on http://localhost:8000"
@echo "Starting 20 concurrent users, 2/sec spawn rate, 60 second duration..."
@locust -f tests/performance/locustfile.py --headless -u 20 -r 2 -t 60s --host http://localhost:8000
@echo "✅ Load tests completed!"
test-perf-load-ui:
@echo "🔥 Starting Locust web UI..."
@echo "Open http://localhost:8089 in your browser"
@locust -f tests/performance/locustfile.py --host http://localhost:8000
# Screenshots
screenshots:
@echo "📸 Capturing all UI screenshots (app must be running on http://localhost:8000)..."
@node tools/screenshots/screenshot_capture.js
@echo "✅ Screenshots saved to docs/screenshots/"
screenshot-library:
@echo "📸 Capturing library screenshot (app must be running on http://localhost:8000)..."
@node tools/screenshots/screenshot.js
@echo "✅ Screenshot saved to docs/screenshots/desktop_library.jpg"
# Cleanup
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 d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
rm -rf build/ dist/ *.egg-info 2>/dev/null || true
@echo "✓ Cleanup complete"