APP_LIST ?= core grady util
DB_NAME = postgres
VENV_PATH = .venv

.PHONY: run install migrations-check isort isort-check test

.venv:
	@python3.6 -m venv $(VENV_PATH) || exit 1
	@echo To enter: source .venv/bin/activate

run:
	python manage.py runserver 0.0.0.0:8000

migrations-check:
	python manage.py makemigrations --check --dry-run

isort:
	isort -rc $(APP_LIST)

isort-check:
	isort -c -rc $(APP_LIST)

migrate:
	python manage.py migrate

install:
	pip install -Ur requirements.txt
	pip install -Ur requirements.dev.txt

test:
	DJANGO_SETTINGS_MODULE=grady.settings pytest

coverage:
	DJANGO_SETTINGS_MODULE=grady.settings pytest --cov
	coverage html

db:
	docker run -d --name $(DB_NAME) -p 5432:5432 postgres:9.5