help:
	@echo '                                                                                             '
	@echo 'Makefile for edx-ecommerce                                                                   '
	@echo '                                                                                             '
	@echo 'Usage:                                                                                       '
	@echo '    make dev_requirements                     install requirements for local development     '
	@echo '    make test_requirements                    install test requirements                      '
	@echo '    make migrate                              apply migrations                               '
	@echo '    make serve                                start the dev server at localhost:8002         '
	@echo '    make clean                                delete generated byte code and coverage reports'
	@echo '    make test_python                          run unit tests with migrations disabled        '
	@echo '    make html_coverage                        generate and view HTML coverage report         '
	@echo '    make quality                              run pep8 and pylint                            '
	@echo '    make validate                             run unit tests, followed by quality checks     '
	@echo '                                                                                             '

dev_requirements:
	pip install -qr requirements/local.txt --exists-action w

test_requirements:
	pip install -qr requirements/test.txt --exists-action w

migrate:
	python manage.py migrate

serve:
	python manage.py runserver 8002

clean:
	find . -name '*.pyc' -delete
	coverage erase

# Define a target-specific variable to be exported into the environment of
# processes invoked by this target.
test_python: export DISABLE_MIGRATIONS=True
test_python: clean
	python manage.py test ecommerce --settings=ecommerce.settings.test --with-coverage --cover-package=ecommerce

html_coverage:
	coverage html && open htmlcov/index.html

quality:
	pep8 --config=.pep8 ecommerce
	pylint --rcfile=pylintrc ecommerce

validate: test_python quality

# Targets in a Makefile which do not produce an output file with the same name as the target name
.PHONY: help requirements test_requirements super migrate serve clean test_python html_coverage \
	quality validate
