.PHONY: help
.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}'

install: ## Install dev requirements
	poetry install

lint: ## Run code linters
	isort --check service tests
	black --check service tests
	flake8 service tests --count
	mypy service tests

fmt format: ## Run code formatters
	isort service tests
	black service tests

test: ## Run unit test with coverage
	python -m pytest tests/unit -vv --cov=service/

test-integration: ## Run legacy integration tests
	@docker-compose -f docker-compose-test.yml up -d --build
	@docker-compose -f docker-compose-test.yml exec data-processor-test python3 -m pytest tests/integration --durations=0 --cov=service/tasks -rP --disable-warnings

up: ## Compose docker app
	@docker-compose up -d --build --remove-orphans

down: ## Shutdown docker app
	@docker-compose down

shell sh: ## Spawn shell inside docker
	@docker-compose exec data-processor /bin/sh

ps: ## List all processes
	@docker-compose ps

logs: ## View logs
	@docker-compose logs -f
