.PHONY: run
run:
	@uv run fastapi dev core_framework/asgi.py

.PHONY: alembic
alembic:
	@uv run cf-alembic

.PHONY: ruff
ruff:
	@uv run ruff check --fix .
	@uv run ruff format .
	@uv run tach check

.PHONY: ty
ty:
	@uv run ty check

# Integration tests need Docker's Linux engine for the Testcontainers Postgres
# and Redis. That engine is unavailable on the Windows host this repo is
# developed on (WSL2 needs the Virtual Machine Platform feature plus firmware
# virtualization), so Windows runs unit tests only and non-Windows runs both.
# `make test-unit` forces unit-only anywhere.
ifeq ($(OS),Windows_NT)
TEST_PATHS := tests/unit
TEST_WORKERS :=
else
TEST_PATHS := tests/unit tests/integration
TEST_WORKERS := -n 2
endif

# The core_framework.testing plugin starts the Firebase Auth emulator, waits for
# Identity Toolkit readiness, sets FIREBASE_AUTH_EMULATOR_HOST, and stops it at
# teardown (tests/conftest.py sets firebase_project_id="test"). Recipes stay to a
# single command so they run on Windows, where make uses cmd.exe instead of sh.
.PHONY: test
test:
	@uv run pytest $(TEST_PATHS) $(TEST_WORKERS)

# No Docker, no Firebase: tests/conftest.py returns None for unit-only runs.
.PHONY: test-unit
test-unit:
	@uv run pytest tests/unit

.PHONY: test-e2e
test-e2e:
	@uv run pytest tests/e2e

.PHONY: coverage
coverage:
	@uv run pytest tests/unit tests/integration -n 2 --cov=core_framework --cov-branch --cov-report=term-missing:skip-covered --cov-report=html:htmlcov
	@echo HTML report: htmlcov/index.html
