Commit 1b2ca86f by Renzo Lucioni

Clean up Makefile

Move target descriptions inline and add targets for running Travis builds to a separate, included Makefile.
parent 3bbc4bf5
...@@ -14,10 +14,10 @@ cache: ...@@ -14,10 +14,10 @@ cache:
- course_discovery/static/bower_components - course_discovery/static/bower_components
before_install: before_install:
- docker-compose -f .travis/docker-compose-travis.yml up -d - make travis_up
script: script:
- docker exec course-discovery /edx/app/discovery/discovery/.travis/run_tests.sh - make travis_test
after_success: after_success:
- pip install -U codecov - pip install -U codecov
......
.PHONY: travis_down travis_start travis_stop travis_test travis_up
travis_up: ## Create containers used to run tests on Travis CI
docker-compose -f .travis/docker-compose-travis.yml up -d
travis_start: ## Start containers stopped by `travis_stop`
docker-compose -f .travis/docker-compose-travis.yml start
travis_test: ## Run tests on Docker containers, as on Travis CI
docker exec -it course-discovery env TERM=$(TERM) /edx/app/discovery/discovery/.travis/run_tests.sh
travis_stop: ## Stop running containers created by `travis_up` without removing them
docker-compose -f .travis/docker-compose-travis.yml stop
travis_down: ## Stop and remove containers and other resources created by `travis_up`
docker-compose -f .travis/docker-compose-travis.yml down
.DEFAULT_GOAL := test .DEFAULT_GOAL := test
NODE_BIN=./node_modules/.bin NODE_BIN=./node_modules/.bin
.PHONY: accept clean compile_translations dummy_translations extract_translations fake_translations help html_coverage \ .PHONY: accept clean clean_static compile_translations detect_changed_source_translations dummy_translations extract_translations \
migrate pull_translations push_translations quality requirements production-requirements test \ fake_translations help html_coverage migrate open-devstack production-requirements pull_translations quality requirements.js \
update_translations validate stop-devstack static requirements start-devstack static stop-devstack test validate validate_translations
help: include .travis/docker.mk
@echo "Please use \`make <target>' where <target> is one of"
@echo " help display this help message" # Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
@echo " make accept run acceptance tests" help: ## Display this help message
@echo " clean delete generated byte code and coverage reports" @echo "Please use \`make <target>\` where <target> is one of"
@echo " compile_translations compile translation files, outputting .po files for each supported language" @perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
@echo " dummy_translations generate dummy translation (.po) files"
@echo " extract_translations extract strings to be translated, outputting .mo files" static: ## Gather all static assets for production
@echo " fake_translations generate and compile dummy translation files"
@echo " html_coverage generate and view HTML coverage report"
@echo " migrate apply database migrations"
@echo " pull_translations pull translations from Transifex"
@echo " push_translations push source translation files (.po) from Transifex"
@echo " quality run PEP8 and Pylint"
@echo " production-requirements install requirements for production"
@echo " requirements install requirements for local development"
@echo " requirements.js install JS requirements for local development and production"
@echo " test run tests and generate coverage report"
@echo " validate run tests and quality checks"
@echo " static gather all static assets for production"
@echo " clean_static remove all generated static files"
@echo " start-devstack run a local development copy of the server"
@echo " stop-devstack shutdown the local development server"
@echo " open-devstack open a shell on the server started by start-devstack"
@echo " detect_changed_source_translations check if translation files are up-to-date"
@echo " validate_translations install fake translations and check if translation files are up-to-date"
@echo ""
static:
$(NODE_BIN)/r.js -o build.js $(NODE_BIN)/r.js -o build.js
python manage.py collectstatic --noinput python manage.py collectstatic --noinput
python manage.py compress -v3 --force python manage.py compress -v3 --force
clean_static: clean_static: ## Remove all generated static files
rm -rf course_discovery/assets/ course_discovery/static/build/ rm -rf course_discovery/assets/ course_discovery/static/build/
clean: clean: ## Delete generated byte code and coverage reports
find . -name '*.pyc' -delete find . -name '*.pyc' -delete
coverage erase coverage erase
requirements.js: requirements.js: ## Install JS requirements for local development and production
npm install npm install
$(NODE_BIN)/bower install $(NODE_BIN)/bower install
requirements: requirements: ## Install Python requirements for local development
pip install -r requirements/local.txt --exists-action w pip install -r requirements/local.txt --exists-action w
production-requirements: production-requirements: ## Install Python requirements for production
pip install -r requirements.txt --exists-action w pip install -r requirements.txt --exists-action w
test: clean test: clean ## Run tests and generate coverage report
coverage run ./manage.py test course_discovery --settings=course_discovery.settings.test coverage run ./manage.py test course_discovery --settings=course_discovery.settings.test
coverage combine coverage combine
coverage report coverage report
quality: quality: ## Run pep8 and Pylint
pep8 --config=.pep8 acceptance_tests course_discovery *.py pep8 --config=.pep8 acceptance_tests course_discovery *.py
pylint --rcfile=pylintrc acceptance_tests course_discovery *.py pylint --rcfile=pylintrc acceptance_tests course_discovery *.py
validate: quality test validate: quality test ## Run tests and quality checks
migrate: migrate: ## Apply database migrations
python manage.py migrate --noinput python manage.py migrate --noinput
python manage.py install_es_indexes python manage.py install_es_indexes
html_coverage: html_coverage: ## Generate and view HTML coverage report
coverage html && open htmlcov/index.html coverage html && open htmlcov/index.html
extract_translations: extract_translations: ## Extract strings to be translated, outputting .mo files
# NOTE: We need PYTHONPATH defined to avoid ImportError(s) on Travis CI. # NOTE: We need PYTHONPATH defined to avoid ImportError(s) on Travis CI.
cd course_discovery && PYTHONPATH="..:${PYTHONPATH}" i18n_tool extract --verbose cd course_discovery && PYTHONPATH="..:${PYTHONPATH}" i18n_tool extract --verbose
cd course_discovery && PYTHONPATH="..:${PYTHONPATH}" i18n_tool generate --verbose cd course_discovery && PYTHONPATH="..:${PYTHONPATH}" i18n_tool generate --verbose
dummy_translations: dummy_translations: ## Generate dummy translation (.po) files
cd course_discovery && i18n_tool dummy cd course_discovery && i18n_tool dummy
compile_translations: compile_translations: ## Compile translation files, outputting .po files for each supported language
python manage.py compilemessages python manage.py compilemessages
fake_translations: extract_translations dummy_translations compile_translations fake_translations: extract_translations dummy_translations compile_translations ## Generate and compile dummy translation files
pull_translations: pull_translations: ## Pull translations from Transifex
tx pull -af tx pull -af
push_translations: start-devstack: ## Run a local development copy of the server
tx push -s
start-devstack:
docker-compose up docker-compose up
stop-devstack: stop-devstack: ## Shutdown the local development server
docker-compose down docker-compose down
open-devstack: open-devstack: ## Open a shell on the server started by start-devstack
docker-compose up -d docker-compose up -d
docker exec -it course-discovery env TERM=$(TERM) /edx/app/discovery/devstack.sh open docker exec -it course-discovery env TERM=$(TERM) /edx/app/discovery/devstack.sh open
accept: accept: ## Run acceptance tests
nosetests --with-ignore-docstrings -v acceptance_tests nosetests --with-ignore-docstrings -v acceptance_tests
make dev.test: detect_changed_source_translations: ## Check if translation files are up-to-date
coverage run ./manage.py test course_discovery --settings=course_discovery.settings.devstack_test --keepdb
coverage report
detect_changed_source_translations:
cd course_discovery && i18n_tool changed cd course_discovery && i18n_tool changed
validate_translations: fake_translations detect_changed_source_translations validate_translations: fake_translations detect_changed_source_translations ## Install fake translations and check if translation files are up-to-date
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment