.PHONY: help clean test test_cov fmt lint pip_dev
.DEFAULT_GOAL := help

help:
	@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

clean:  ## Clean environment
	rm -rf .venv .eggs build fansifter_common.egg-info .cache .pytest_cache .mypy_cache .coverage coverage.xml dist
	find . | grep -E '__pycache__|\.pyc|\.pyo$\' | xargs rm -rf

env:  ## Prepare environment
	uv sync

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

test:  ## Run tests
	uv run pytest -v tests/ \
		--cov fansifter_common \
		--cov-report xml \
		--cov-report term \
		--junitxml=pyunit.xml

test_cov:  ## Run tests with coverage
	uv run pytest -v tests/ \
		--cov fansifter_common \
		--cov-report term-missing

lint:  ## Run code linters
	uv run ty check fansifter_common tests
	uv run ruff check fansifter_common tests
	uv run ruff format fansifter_common tests --check --diff

fmt:  ## Run code formatters
	uv run ruff check fansifter_common tests --fix
	uv run ruff format fansifter_common tests

pip-compile:  ## Update requirements
	uv pip compile --all-extras --no-strip-extras --emit-index-url --output-file=requirements-dev.txt pyproject.toml --extra-index-url https://pypi.theorchard.io/pypi/
