.PHONY: dev pip_dev pip_prod lint test_unit test_without_coverage clean

clean:
	rm -rf env

pip_prod: clean
	python3 -m venv env
	env/bin/pip3 install --upgrade pip
	env/bin/pip3 install -r requirements.txt

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

dev: env
	env/bin/python3 dev.py

lint:
	env/bin/flake8  labelaudit/ tests/
	
test_unit: env
	env/bin/py.test tests

down_unit_lint:
		docker compose down lint-and-test --remove-orphans

docker_unit_lint:
		docker compose run \
				--name ows-label-audit-lint-test \
				--build \
				lint-and-test
		docker cp ows-label-audit-lint-test:/var/app/build/pyunit.xml ./pyunit.xml
		docker cp ows-label-audit-lint-test:/var/app/build/coverage.xml ./coverage.xml
# set the coverage report path to the local machine directory so jenkins can find the sources
		sed -i.bak "s?<source>/var/app/ows_label_audit</source>?<source>$$(pwd)/ows_label_audit</source>?g" coverage.xml
		docker rm -f ows-label-audit-lint-test

ci_unit_lint: ci_unit_lint_clean
		mkdir -p build
		chmod a+w build
		make docker_unit_lint

ci_unit_lint_clean: down_unit_lint
	rm -rf build

ci_test_integraion:
	echo 'no op'