# Prepare environment
env pip_dev:
	poetry install

# Test
test test_unit: pip_dev
	poetry run pytest tests/unit

test_integration: pip_dev
	poetry run pytest tests/integration

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

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

fmt format:
	poetry 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
