.PHONY: clean dev_env \
	lint test \
	test_unit env_integration  test_integration \
	unit_lint_job integration_job

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

env:
	python3.6 -m venv env
	env/bin/pip install -U pip setuptools
	env/bin/pip install -r requirements.txt

dev_env: env
	if [ ! -f env/bin/py.test ]; then env/bin/pip install -q -I -r requirements-dev.txt; fi

env_integration:
	python3.6 -m venv tests/integration/env
	tests/integration/env/bin/python setup.py install
	tests/integration/env/bin/pip install -q pytest

lint: dev_env
	env/bin/python -m flake8 iso_standards/ tests/ setup.py

test_unit: dev_env
	env/bin/py.test tests/unit/ \
		--cov iso_standards \
		--cov-report xml \
		--junitxml=pyunit.xml

test_integration: clean env_integration
	cd tests/integration && env/bin/python -m pytest

unit_lint_job: clean lint test_unit

integration_job: clean test_integration
