-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
193 lines (153 loc) · 7.14 KB
/
Makefile
File metadata and controls
193 lines (153 loc) · 7.14 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
.PHONY: be-migrate be-test lint format-check format-fix type-check type-check-strict test-contracts test-all coverage ci-local pre-commit-install pre-commit-run sim-contract-check sim-matrix-dry-run
# Use Poetry to run all Python tooling by default
# Detect Poetry command (Windows-friendly)
# Use the CLI entrypoint instead of `py -m poetry` because Poetry has no __main__.
# Use the most robust way to invoke Poetry on Windows/Anaconda.
ifeq ($(OS),Windows_NT)
NULLDEV := NUL
else
NULLDEV := /dev/null
endif
POETRY := $(shell python -m poetry --version >$(NULLDEV) 2>&1 && echo python -m poetry || echo poetry)
COV_FAIL_UNDER ?= 15
# -----------------------------------------------------------------------------
# Backend commands (legacy shims)
# -----------------------------------------------------------------------------
be-migrate:
$(POETRY) run dotenv run alembic upgrade head
be-test:
$(POETRY) run pytest -q
# -----------------------------------------------------------------------------
# Quality gates (mirror CI)
# -----------------------------------------------------------------------------
lint:
$(POETRY) run ruff check --ignore E501,E402,F811,F401,F841,F821,E722,E741,E721,E712 src tests
format-check:
$(POETRY) run black --check src tests
format-fix:
$(POETRY) run black src tests
type-check:
@echo "Running mypy (non-blocking). Use 'make type-check-strict' to enforce."
-$(POETRY) run mypy --namespace-packages src tests
type-check-strict:
$(POETRY) run mypy --config-file mypy_strict.ini
# -----------------------------------------------------------------------------
# Tests
# -----------------------------------------------------------------------------
test-unit:
$(POETRY) run pytest -q \
tests/unit/api/test_dependencies_managers.py \
tests/unit/test_eventbus_logging.py \
tests/unit/test_learning.py
test-integration:
$(POETRY) run pytest -m integration -v --cov=src --cov-report=xml --cov-report=term-missing
test-contracts:
$(POETRY) run pytest -q tests/contracts
test-validation:
$(POETRY) run pytest -m validation --cov=src --cov-report=xml --cov-report=term-missing
test-performance:
$(POETRY) run pytest -m performance --cov=src --cov-report=xml --cov-report=term-missing
test-all:
$(POETRY) run pytest -m "not slow" --cov=src --cov-report=term-missing --cov-report=html:htmlcov --cov-report=xml --cov-fail-under=$(COV_FAIL_UNDER) --ignore=integration_tests --ignore=scripts --ignore=tests/integration/test_tier2_golden_master.py --ignore=tests/unit/test_infrastructure_complete.py
# Flaky in mixed-suite runs due shared async/global state; keep runnable separately.
test-infrastructure:
$(POETRY) run pytest -q tests/unit/test_infrastructure_complete.py
# Timeboxed full test run to avoid local hangs; respects pytest-timeout settings from pyproject
test-all-timeboxed:
$(POETRY) run pytest -m "not slow and not performance" --cov=src --cov-report=xml --maxfail=1 -vv -s --ignore=integration_tests --ignore=scripts
# Run all including slow and performance tests (use with caution)
test-complete:
$(POETRY) run pytest --cov=src --cov-report=term-missing --cov-report=html:htmlcov --cov-report=xml --cov-fail-under=$(COV_FAIL_UNDER) --ignore=integration_tests --ignore=scripts
coverage: test-all
# -----------------------------------------------------------------------------
# Verification helpers
# -----------------------------------------------------------------------------
verify-golden:
$(POETRY) run python scripts/verify_golden_masters.py
verify-coverage:
$(POETRY) run python scripts/verify_coverage_thresholds.py
sim-contract-check:
$(POETRY) run python scripts/verify_sim_benchmark_contract.py --latest
sim-matrix-dry-run:
$(POETRY) run python scripts/run_sim_benchmark_matrix.py --days 14 --seeds 42,43,44 --print-only
# -----------------------------------------------------------------------------
# Website and Documentation
# -----------------------------------------------------------------------------
build-docs:
$(POETRY) run python generate_github_pages.py
# -----------------------------------------------------------------------------
# CI parity aggregate
# -----------------------------------------------------------------------------
ci-local:
py -m pip install -q poetry
$(POETRY) install --no-interaction --no-ansi
$(MAKE) lint
$(MAKE) format-check
$(MAKE) type-check
$(MAKE) test-unit
$(MAKE) test-contracts
$(MAKE) verify-golden
$(MAKE) build-docs
# -----------------------------------------------------------------------------
# Pre-commit helpers
# -----------------------------------------------------------------------------
pre-commit-install:
$(POETRY) run pre-commit install --install-hooks
pre-commit-run:
$(POETRY) run pre-commit run --all-files --show-diff-on-failure
# -----------------------------------------------------------------------------
# Database migrations
# -----------------------------------------------------------------------------
db-migrate:
$(POETRY) run alembic upgrade head
# -----------------------------------------------------------------------------
# Build targets
# -----------------------------------------------------------------------------
build:
docker-compose build
frontend-build:
cd frontend && npm ci && npm run build
cp -r frontend/dist ./static
# -----------------------------------------------------------------------------
# Deployment
# -----------------------------------------------------------------------------
deploy:
docker-compose -f docker-compose.prod.yml up -d
deploy-down:
docker-compose -f docker-compose.prod.yml down
# -----------------------------------------------------------------------------
# Load Testing
# -----------------------------------------------------------------------------
load-test:
poetry run locust -f locustfile.py --headless -u 10 -r 2 --run-time 30s --host=http://localhost:8000
# -----------------------------------------------------------------------------
# CI enhancements
# -----------------------------------------------------------------------------
ci-docker:
$(MAKE) build
docker-compose run api make ci-local
# ci-local target consolidated above
# -----------------------------------------------------------------------------
# Deployment targets
# -----------------------------------------------------------------------------
VERSION ?= 1.0.0
IMAGE_NAME ?= fba-bench-app
REGISTRY ?= docker.io/$(USER)
deploy-prod:
docker-compose -f docker-compose.prod.yml up -d --build
rollback:
docker-compose -f docker-compose.prod.yml down
@echo "Rollback complete. To restore previous version, pull specific image tag or use git revert."
release: deploy-prod
git tag -a v$(VERSION) -m "Release v$(VERSION)"
git push origin v$(VERSION)
docker build -t $(REGISTRY)/$(IMAGE_NAME):$(VERSION) -f Dockerfile.prod .
docker push $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
docker tag $(REGISTRY)/$(IMAGE_NAME):$(VERSION) $(REGISTRY)/$(IMAGE_NAME):latest
docker push $(REGISTRY)/$(IMAGE_NAME):latest
@echo "Release v$(VERSION) tagged, pushed, and deployed."
# -----------------------------------------------------------------------------
# Development Startup
# -----------------------------------------------------------------------------
start:
scripts\\fba-start.bat