.PHONY: install test test-integration test-all lint format up down clean build

install:
	uv sync --dev

test:
	uv run pytest tests/unit -q

# Requires a real broker: run `make up` first.
# Keep this a separate pytest invocation from `test`. Celery's worker
# startup resets global logging and breaks caplog for tests run after it
# in the same process.
test-integration:
	uv run pytest tests/integration -q -m integration

test-all: test test-integration

lint:
	uv run ruff check src/ tests/
	uv run ruff format --check src/ tests/
	uv run mypy

format:
	uv run ruff check --fix src/ tests/
	uv run ruff format src/ tests/

up:
	docker compose up -d
	@echo "Waiting for ministack..."
	@until curl -s http://localhost:14566 > /dev/null; do sleep 0.5; done
	@echo "ministack on http://localhost:14566, stackport GUI on http://localhost:9090"

down:
	docker compose down

build:
	uv build

clean:
	rm -rf dist/ build/ *.egg-info
	find . -type d -name __pycache__ -not -path './.venv/*' -exec rm -rf {} +
