# Add any tasks that are not dependent on files to the .PHONY list.
.PHONY: clean dev pip_dev lint test test_unit test_integration ci_unit_lint ci_test_integration

clean:
	rm -rf env tests/integration/env .coverage .pytest_cache .cache coverage.xml pyunit*.xml
	find . | grep -E '__pycache__|\.pyc|\.pyo$\' | xargs rm -rf

dev:
	venv/bin/python3.13 dev.py

env:
	python3.13 -m venv venv

pip_dev: env
	venv/bin/pip install --upgrade pip
	venv/bin/pip install -r requirements.txt
	venv/bin/pip install -r requirements-dev.txt

fmt: pip_dev
	venv/bin/ruff check --fix backend/ tests/

lint: pip_dev
	venv/bin/ruff check backend/ tests/

test_unit: pip_dev
	venv/bin/py.test \
		--cov product tests/ \
		--cov-report xml \
		--junitxml=pyunit.xml \
		--ignore tests/integration

test_integration: pip_dev
	venv/bin/py.test tests/integration --junitxml=pyunit.xml

up_dev:
	docker compose up \
		--build \
		--detach \
		--remove-orphans \
		track-dev

down_dev:
	docker compose down \
		track-dev

up_deploy:
	docker compose up \
		--build \
		--detach \
		--remove-orphans \
		deploy

down:
	docker compose down

docker_unit_lint:
	docker compose up \
		--build \
		--exit-code-from unit-lint \
		--abort-on-container-exit \
		--remove-orphans \
		unit-lint

docker_unit_lint_clean:
	docker compose down \
		--remove-orphans \
		unit-lint 

docker_test_integration:
	docker compose up \
		--build \
		--exit-code-from integration-test \
		--abort-on-container-exit \
		--remove-orphans \
		integration-test
