clean:
	if [ -f report.html ]; then rm -r report.html; fi
	rm -rf env  .coverage .pytest_cache .cache coverage.xml pyunit.xml
	find . | grep -E '__pycache__|\.pyc|\.pyo$\' | xargs rm -rf

env:
	python3.11 -m venv env
	env/bin/python -m pip install -q -U pip setuptools wheel
	env/bin/python -m pip install -q -I -r reqs.pip
	env/bin/python setup.py develop

dev_env: env
	if [ ! -f env/bin/py.test ]; then env/bin/python -m pip install -q -I -r reqs-test.pip; fi

lint:
	env/bin/python -m flake8 processing_accounting/ tests/

test:
	env/bin/python -m pytest tests/ --cov processing_accounting --cov-report term-missing

ci_unit_lint: ci_unit_lint_clean docker_unit_lint_up

ci_unit_lint_clean: docker_unit_lint_down

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

docker_unit_lint_down:
	docker compose down unit-lint --volumes --remove-orphans

docker_login:
	aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 437795906767.dkr.ecr.us-east-1.amazonaws.com
	aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 086679231553.dkr.ecr.us-east-1.amazonaws.com
