11ROOT = $(shell echo "$$PWD")
22COVERAGE_DIR = $(ROOT ) /build/coverage
3- PACKAGES = analyticsdataserver analytics_data_api
43DATABASES = default analytics
5- PYTHON_ENV =py38
6- DJANGO_VERSION =django32
74.DEFAULT_GOAL := help
85
6+ TOX =''
7+
8+ ifdef TOXENV
9+ TOX := tox -- # to isolate each tox environment if TOXENV is defined
10+ endif
11+
912help : # # display this help message
1013 @echo " Please use \` make <target>' where <target> is one of"
1114 @perl -nle' print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
@@ -28,7 +31,7 @@ test.requirements: requirements ## install base and test requirements
2831 pip3 install -q -r requirements/test.txt
2932
3033tox.requirements : # # install tox requirements
31- pip3 install -q -r requirements/tox.txt
34+ pip3 install -q -r requirements/tox.txt
3235
3336develop : test.requirements # # install test and dev requirements
3437 pip3 install -q -r requirements/dev.txt
@@ -58,16 +61,21 @@ upgrade:
5861 mv requirements/test.tmp requirements/test.txt
5962
6063
61- clean : tox.requirements # # install tox requirements and run tox clean. Delete *.pyc files
62- tox -e $( PYTHON_ENV ) - $( DJANGO_VERSION ) -clean
64+ clean :
65+ $( TOX ) coverage erase
6366 find . -name ' *.pyc' -delete
6467
65- main.test : tox.requirements clean
66- tox -e $(PYTHON_ENV ) -$(DJANGO_VERSION ) -tests
68+ main.test : clean
6769 export COVERAGE_DIR=$(COVERAGE_DIR ) && \
68- tox -e $( PYTHON_ENV ) - $( DJANGO_VERSION ) -coverage
70+ $( TOX ) pytest --cov-report html --cov-report xml
6971
72+ test :
73+
74+ ifeq ($(DJANGO_SETTINGS_MODULE ) ,analyticsdataserver.settings.devstack)
75+ test : main.test
76+ else
7077test : test.run_elasticsearch main.test test.stop_elasticsearch
78+ endif
7179
7280diff.report : test.requirements # # Show the diff in quality and coverage
7381 diff-cover $(COVERAGE_DIR ) /coverage.xml --html-report $(COVERAGE_DIR ) /diff_cover.html
@@ -79,19 +87,19 @@ view.diff.report: ## Show the diff in quality and coverage using xdg
7987 xdg-open file:///$(COVERAGE_DIR ) /diff_quality_pycodestyle.html
8088 xdg-open file:///$(COVERAGE_DIR ) /diff_quality_pylint.html
8189
82- run_check_isort : tox.requirements # # Run tox check_isort. (Installs tox requirements.)
83- tox -e $( PYTHON_ENV ) - $( DJANGO_VERSION ) -check_isort
90+ run_check_isort :
91+ $( TOX ) isort --check-only --recursive --diff analytics_data_api/ analyticsdataserver/
8492
85- run_pycodestyle : tox.requirements # # Run tox pycodestyle. (Installs tox requirements.)
86- tox -e $( PYTHON_ENV ) - $( DJANGO_VERSION ) - pycodestyle
93+ run_pycodestyle :
94+ $( TOX ) pycodestyle --config=. pycodestyle analytics_data_api analyticsdataserver
8795
88- run_pylint : tox.requirements # # Run tox pylint. (Installs tox requirements.)
89- tox -e $( PYTHON_ENV ) - $( DJANGO_VERSION ) -pylint
96+ run_pylint :
97+ $( TOX ) pylint -j 0 --rcfile=pylintrc analytics_data_api analyticsdataserver
9098
91- run_isort : tox.requirements # # Run tox isort. (Installs tox requirements.)
92- tox -e $( PYTHON_ENV ) - $( DJANGO_VERSION ) -isort
99+ run_isort :
100+ $( TOX ) isort --recursive analytics_data_api/ analyticsdataserver/
93101
94- quality : tox.requirements run_pylint run_check_isort run_pycodestyle # # run_pylint, run_check_isort, run_pycodestyle (Installs tox requirements.)
102+ quality : run_pylint run_check_isort run_pycodestyle # # run_pylint, run_check_isort, run_pycodestyle (Installs tox requirements.)
95103
96104validate : test.requirements test quality # # Runs make test and make quality. (Installs test requirements.)
97105
@@ -108,6 +116,9 @@ loaddata: migrate ## Runs migrations and generates fake data
108116 python manage.py loaddata problem_response_answer_distribution --database=analytics
109117 python manage.py generate_fake_course_data
110118
119+ create_indices : # # Create ElasticSearch indices
120+ python manage.py create_elasticsearch_learners_indices
121+
111122demo : clean requirements loaddata # # Runs make clean, requirements, and loaddata, sets api key to edx
112123 python manage.py set_api_key edx edx
113124
@@ -134,6 +145,5 @@ travis_docker_push: travis_docker_tag travis_docker_auth ## push to docker hub
134145 docker push ' openedx/analytics-data-api:latest-newrelic'
135146 docker push " openedx/analytics-data-api:$$ TRAVIS_COMMIT-newrelic"
136147
137- docs :
138- pip install -r requirements/tox.txt
148+ docs : tox.requirements
139149 tox -e docs
0 commit comments