# Команды разработки tabular-parser. Backend — api/.venv; запуск из корня репозитория.
VENV := api/.venv
BIN := $(CURDIR)/$(VENV)/bin
COMPOSE_FILE ?= ../docs/dev/docker-compose.yml

.PHONY: venv lint test test-integration check docker-build check-full up

# Python 3.11 (версия платформы); внутренние пакеты raisa_* вне банка недоступны — пропускаем их
venv:
	cd api && uv venv --python 3.11 --allow-existing .venv
	cd api && grep -v '^raisa_' requirements.txt | uv pip install --python .venv/bin/python -r -
	cd api && grep -v '^-r' requirements-dev.txt | uv pip install --python .venv/bin/python -r -

lint:
	cd api && $(BIN)/ruff check .
	cd api && $(BIN)/ruff format --check .
	cd api && $(BIN)/mypy src

test:
	cd api && $(BIN)/pytest -m "not integration"

test-integration:
	cd api && $(BIN)/pytest -m integration

check: lint test

# Сборка образа из корня репозитория
docker-build:
	docker build -t tabular-parser .

# Полная проверка перед PR: быстрые проверки, затем NATS/MinIO из compose (make up), затем образ
check-full: check test-integration docker-build

# Только инфраструктура, нужная сервису (без arm-core): NATS и MinIO; postgres — для общей среды compose
up:
	docker compose -f $(COMPOSE_FILE) up -d --wait postgres nats minio
