.PHONY: clean dev_env lint test

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

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

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

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

test: dev_env
	env/bin/python -m pytest tests \
		--cov qa_testing_utils \
		--cov-report term-missing

download_user_data:
	./scripts/download_user_data.sh

refresh_graphQl_mocks:
	env/bin/python qa_testing_utils/graphQlQueryGenerator/refresh_app_mocks.py $(app) $(source_app)

upload_graphQl_responses_to_s3:
	./scripts/upload_responses.sh $(app)

ci_check_and_refresh:
	./scripts/refresh_handler.sh $(app) $(source_app) $(force_refresh)

save_last_commit:
	./scripts/save_latest_commit.sh
