# Add any tasks that are not dependent on files to the .PHONY list.
.PHONY: docker_unit_lint down_unit_lint ci_unit_lint ci_unit_lint_clean

docker_unit_lint:
	docker rm -f ows-territories-unit-lint
	docker compose run \
		--build \
		--name ows-territories-unit-lint \
		lint-and-test

pyunit.xml:
	docker cp ows-territories-unit-lint:/var/app/pyunit.xml ./pyunit.xml || true

coverage.xml:
	docker cp ows-territories-unit-lint:/var/app/coverage.xml ./coverage.xml || true
# set the coverage report path to the local machine directory so jenkins can find the sources
	sed -i.bak "s?<source>/var/app/territories</source>?<source>$$(pwd)/territories</source>?g" coverage.xml
	rm -f coverage.xml.bak

down_unit_lint:
	docker rm -f ows-territories-unit-lint
	docker compose down --remove-orphans

ci_unit_lint: ci_unit_lint_clean docker_unit_lint

ci_unit_lint_clean: down_unit_lint
