.PHONY: help clean env pip_dev test_unit test_cov fmt lint

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 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

test_unit: pip_dev  ## Run unit tests
	poetry run pytest tests/unit/ \
		--cov skill_eval_runner \
		--cov-report xml \
		--cov-report term \
		--junitxml=pyunit.xml

test_cov: pip_dev  ## Run unit and integration tests with coverage
	poetry run pytest tests/ \
		--cov skill_eval_runner \
		--cov-report term-missing

lint: pip_dev  ## Run code linters
	poetry run mypy skill_eval_runner tests
	poetry run ruff check skill_eval_runner tests
	poetry run ruff format skill_eval_runner tests --check --diff

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