.PHONY: help lint fmt test down ci_lint_and_test ci_lint_and_test_clean
.DEFAULT_GOAL := help

# define root project dir
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

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

lint: ## Run code linters
	uv run ruff check
	uv run ruff format --check

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

test: ## Run unit tests
	uv run pytest tests/unit/

down: ## Shutdown docker app
	docker compose down --remove-orphans -v

ci_lint_and_test:  ## Run linters and unit tests inside docker
	mkdir -p build
	chmod 777 build
	docker compose up \
		--build \
		--exit-code-from lint-and-test \
		--abort-on-container-exit \
		--remove-orphans \
		lint-and-test

ci_lint_and_test_clean: down
	rm -rf build
