# Prepare environment
env pip_dev:
	uv sync --all-extras

# Test
test test_unit: env
	uv run pytest tests/unit

test_integration: env
	uv run pytest tests/integration

test_coverage:
	uv run pytest tests \
		--cov \
		--cov-report xml:build/coverage.xml \
		--cov-report term \
		--junitxml=build/pyunit.xml

# Lint and format
lint:
	uv run ruff check
	uv run ruff format --check
	uv run mypy .

fmt format:
	uv run ruff format

# Run lint and unit tests in Docker
ci_unit_lint:
	docker compose up \
		--build \
		--exit-code-from lint-and-test \
		--remove-orphans \
		lint-and-test

ci_unit_lint_clean:
	rm -rf build

ci_test_integration:
	docker compose up \
		--build \
		--exit-code-from integration-test \
		--abort-on-container-exit \
		--remove-orphans \
		integration-test

# Bring up dev container
up:
	docker compose up \
		--build \
		--detach \
		--remove-orphans \
		function

# Bring it down
down:
	docker compose down
