.PHONY: pip_dev test_unit lint fmt docker_unit_lint clean

clean:  ## Clean environment
	rm -rf env .cache .pytest_cache .mypy_cache .ruff_cache pyunit.xml .coverage coverage.xml
	find . | grep -E '__pycache__|\.pyc|\.pyo$\' | xargs rm -rf

env pip_dev:  ## Prepare environment
	poetry install

dev: ## Run local for development
	poetry run python src/dev.py

test_unit: pip_dev ## Run unit tests
	poetry run pytest

docker_unit_lint:  # Run lint and unit tests in Docker
	docker compose up \
		--build \
		--exit-code-from unit-lint \
		--abort-on-container-exit \
		--remove-orphans \
		unit-lint

lint: pip_dev ## Run code linters
	poetry run ruff check .
	poetry run ruff format . --diff

fmt: pip_dev ## Run code formatters
	poetry run ruff check . --fix
	poetry run ruff format .
