.DEFAULT_GOAL := help
.PHONY: help sync format format-check static-analysis type-check lint test check build publish clean

bold := $(shell tput bold)
normal := $(shell tput sgr0)
blue := $(shell tput setaf 4)

define print_target
	@echo ""
	@echo "$(blue)$(bold)$@:$(normal)"
endef

# `make help` groups targets by `##@ section` banners and lists each `target: ## description`.
help:
	@awk 'BEGIN{FS=":.*## "} /^##@ /{printf "\n%s:\n",substr($$0,5)} /^[a-z][a-zA-Z0-9_-]*:.*## /{printf "  %-20s %s\n",$$1,$$2}' $(MAKEFILE_LIST)

##@ dev

sync: ## sync the dev env (uv sync)
	$(call print_target)
	uv sync

##@ checks

format: ## ruff format + autofix
	$(call print_target)
	uv run ruff format .
	uv run ruff check --fix .

format-check: ## ruff format --check
	$(call print_target)
	uv run ruff format --check .

static-analysis: ## ruff check
	$(call print_target)
	uv run ruff check .

type-check: ## mypy
	$(call print_target)
	uv run mypy onedata_lambda_sdk

lint: format-check static-analysis type-check ## format-check + static-analysis + type-check
	@:

test: ## pytest (+ coverage, junit for CI)
	$(call print_target)
	uv run pytest --cov=onedata_lambda_sdk --cov-report=term-missing --junitxml=onedata-lambda-sdk-tests-results.xml

check: lint test ## lint + test
	@:

##@ build & release

build: ## uv build (sdist + wheel)
	uv build

publish: ## uv publish
	uv publish

clean: ## remove build artifacts
	rm -rf build dist *.egg-info
