forked from openedx-unsupported/edx-analytics-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
198 lines (149 loc) · 7.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
ROOT = $(shell echo "$$PWD")
COVERAGE_DIR = $(ROOT)/build/coverage
DJANGO_SETTINGS_MODULE ?= "analytics_dashboard.settings.local"
TOX=''
ifdef TOXENV
TOX := tox -- #to isolate each tox environment if TOXENV is defined
endif
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
.PHONY: requirements coverage clean docs install_transifex_client
# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
help: ## display this help message
@echo "Please use \`make <target>\` where <target> is one of"
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
requirements: requirements.py requirements.js
requirements.py: piptools
pip-sync -q requirements/base.txt
requirements.js:
npm ci --unsafe-perm
test.requirements: piptools
pip-sync -q requirements/test.txt
develop: piptools requirements.js
pip-sync -q requirements/local.txt
migrate: ## apply database migrations
$(TOX)python manage.py migrate --run-syncdb
run-local: ## Run local (non-devstack) development server on port 8000
python manage.py runserver 0.0.0.0:8110 --settings=analytics_dashboard.settings.local
dbshell-local: ## Run local (non-devstack) database shell
python manage.py dbshell --settings=analytics_dashboard.settings.local
shell: ## Run Python shell
python manage.py shell
clean: ## delete generated byte code and coverage reports
find . -name '*.pyc' -delete
find . -name '__pycache__' -type d -exec rm -rf {} ';' || true
coverage erase
rm -rf assets
rm -rf pii_report
coverage: clean
export COVERAGE_DIR=$(COVERAGE_DIR) && \
$(TOX)pytest common analytics_dashboard --cov common --cov analytics_dashboard --cov-report html --cov-report xml
coverage_html: coverage ## run and view HTML coverage report
$(BROWSER) build/coverage/html/index.html
test_python: clean ## run pyton tests and generate coverage report
$(TOX)pytest common analytics_dashboard --cov common --cov analytics_dashboard
requirements.a11y:
./.github/a11y_reqs.sh
runserver_a11y:
$(TOX)python manage.py runserver 0.0.0.0:9000 --noreload --traceback > dashboard.log 2>&1 &
accept: runserver_a11y
ifeq ("${ENABLE_COURSE_LIST_FILTERS}", "True")
$(TOX)python manage.py waffle_switch enable_course_filters on --create
endif
ifeq ("${ENABLE_COURSE_LIST_PASSING}", "True")
$(TOX)python ./manage.py waffle_switch enable_course_passing on --create
endif
$(TOX)python manage.py create_acceptance_test_soapbox_messages
$(TOX)pytest -v acceptance_tests
$(TOX)python manage.py delete_acceptance_test_soapbox_messages
# local acceptance tests are typically run with by passing in environment variables on the commandline
# e.g. API_SERVER_URL="http://localhost:9001/api/v0" API_AUTH_TOKEN="edx" make accept_local
accept_local:
./manage.py create_acceptance_test_soapbox_messages
pytest -v acceptance_tests
./manage.py delete_acceptance_test_soapbox_messages
accept_devstack:
# TODO: implement this
a11y:
cat dashboard.log
$(TOX)pytest -v a11y_tests -k 'not NUM_PROCESSES==1'
isort_check: ## check that isort has been run
$(TOX)isort --check-only --recursive --diff acceptance_tests/ analytics_dashboard/ common/
isort: ## run isort to sort imports in all Python files
$(TOX)isort --recursive --diff acceptance_tests/ analytics_dashboard/ common/
pycodestyle: # run pycodestyle
$(TOX)pycodestyle acceptance_tests analytics_dashboard common
pylint: # run pylint
$(TOX)pylint -j 0 --rcfile=pylintrc acceptance_tests analytics_dashboard common
# TODO: fix imports so this can run isort_check
quality: pycodestyle pylint ## run all code quality checks
validate_python: test_python quality
#FIXME validate_js: requirements.js
validate_js:
npm run test
npm run lint -s
validate: validate_python validate_js
demo:
python manage.py waffle_switch show_engagement_forum_activity off --create
python manage.py waffle_switch enable_course_api off --create
python manage.py waffle_switch display_course_name_in_nav off --create
compile_translations: # compiles djangojs and django .po and .mo files
$(TOX)python manage.py compilemessages
extract_translations: ## extract strings to be translated, outputting .mo files
$(TOX)python manage.py makemessages -l en -v1 --ignore="docs/*" --ignore="src/*" --ignore="i18n/*" --ignore="assets/*" --ignore="static/bundles/*" --ignore="node_modules/*" -d django
$(TOX)python manage.py makemessages -l en -v1 --ignore="docs/*" --ignore="src/*" --ignore="i18n/*" --ignore="assets/*" --ignore="static/bundles/*" --ignore="node_modules/*" -d djangojs
dummy_translations: ## generate dummy translation (.po) files
cd analytics_dashboard && i18n_tool dummy
generate_fake_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files
update_translations: generate_fake_translations
detect_changed_source_translations: ## check if translation files are up-to-date
cd analytics_dashboard && i18n_tool changed
# extract, compile, and check if translation files are up-to-date
validate_translations: extract_translations compile_translations detect_changed_source_translations
cd analytics_dashboard && i18n_tool validate -
static: ## generate static files
npm run build
$(TOX)python manage.py collectstatic --noinput
pii_check: ## check for PII annotations on all Django models
## Not yet implemented
piptools:
pip3 install -q -r requirements/pip_tools.txt
export CUSTOM_COMPILE_COMMAND = make upgrade
COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
$(COMMON_CONSTRAINTS_TXT):
wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)"
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: $(COMMON_CONSTRAINTS_TXT)
sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
pip install -qr requirements/pip_tools.txt ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip-compile --allow-unsafe --rebuild --upgrade -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip_tools.txt requirements/pip_tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip_tools.txt
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/doc.txt requirements/doc.in
pip-compile --upgrade -o requirements/test.txt requirements/test.in
pip-compile --upgrade -o requirements/tox.txt requirements/tox.in
pip-compile --upgrade -o requirements/local.txt requirements/local.in
pip-compile --upgrade -o requirements/optional.txt requirements/optional.in
pip-compile --upgrade -o requirements/production.txt requirements/production.in
pip-compile --upgrade -o requirements/github.txt requirements/github.in
# Let tox control the Django version for tests
grep -e "^django==" requirements/base.txt > requirements/django.txt
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt
docs:
tox -e docs
install_transifex_client: ## Install the Transifex client
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
git checkout -- LICENSE README.md