.PHONY:test
test:
	py.test --html=report.html --self-contained-html --alluredir=app/src/allure_report app/src/tests/ --reruns 2

.PHONY:report
report:
	allure serve app/src/allure_report/

.PHONY:clean-up
clean-up:
	rm -rf .pytest_cache allure_report automation.log report.html

.PHONY:checkstyle
checkstyle:
	set -e

	isort -rc -w 120 --check-only --quiet app/src/
	flake8 app/src/ --max-line-length=120

.PHONY:dependencies-check
dependencies-check:
	safety check

.PHONY:owasp
owasp:
	bandit -r app/src --skip B101,B311

.PHONY:security
security: dependencies-check owasp

.PHONY:prettify
prettify:
	black app/src --exclude='/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|venv|_build|buck-out|build|dist|migrations|.pytest_cache)/' --line-length=120 --target-version=py37
	isort -rc -w 120 app/src

.PHONY:pre-commit
pre-commit: prettify checkstyle security

.PHONY:docker/build
docker/build:
	@docker build -t apollo-go-tests .

.PHONY:docker/build
docker/test:
	docker run \
		-e USER_EMAIL \
		-e USER_PASSWORD \
		-e AUTH0_CLIENT_ID \
		-e AUTH0_CLIENT_SECRET \
		-e AUTH0_AUDIENCE \
		-e AUTH0_GRANT_TYPE \
		-e AUTH0_REALM \
		-e MYSQL_DB_NAME \
		-e MYSQL_DB_USER \
		-e MYSQL_DB_PASS \
		-e MYSQL_DB_HOST \
		-e BROWSER_NAME \
		-e ENV_BASE_URL \
		-e SELENIUM_TIMEOUT \
		-e SELENIUM_ENV \
		-e PYTEST_XDIST_WORKER \
		-e SELENIUM_HEADLESS \
		-e CHROMEDRIVER_PATH \
		-i \
		--rm \
		-v $(dir $(abspath $(lastword $(MAKEFILE_LIST))))output/:/usr/src/output/ \
		apollo-go-tests:latest
