.PHONY: clean dev list test pip_lock_versions
.PHONY: ci_unit_lint ci_unit_lint_clean

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

env:
	python3.13 -m venv env
	env/bin/python -m pip install -q -U pip setuptools wheel

env/bin/flake8 env/bin/py.test pip_dev: env
	env/bin/python -m pip install -q -r requirements-dev.txt

dev: | env/bin/py.test
	env/bin/python dev.py

lint: | env/bin/flake8
	env/bin/python -m flake8 *.py src tests

test: | env/bin/py.test
	env/bin/python -m pytest tests \
	--cov src \
	--cov-report term-missing

pip_lock_versions: clean env
	env/bin/python -m pip install -q -I -r requirements-to-freeze.txt
	echo "-i https://pypi.theorchard.io/pypi/" > requirements.txt
	env/bin/python -m pip freeze >> requirements.txt

ci_unit_lint:
	docker compose run --rm --build lint-and-test

ci_unit_lint_clean: clean ci_unit_lint
	docker compose down --remove-orphans
