-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
99 lines (79 loc) · 4.53 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
.DEFAULT_GOAL := help
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: clean, coverage, diff_cover, docs, help, dev_requirements, test, test_quality, test_requirements, upgrade,\
compile-requirements check_keywords
help: ## Display this help message
@echo "Please use \`make <target>' where <target> is one of"
@awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
clean: ## Remove generated byte code, coverage reports, and build artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
coverage erase
rm -fr build/
rm -fr dist/
rm -fr *.egg-info
docs-html: ## generate Sphinx HTML documentation
make -C docs html
dev_requirements: ## Install Dev Requirements
pip install -qr requirements/pip.txt
pip install -r requirements/dev.txt
test_requirements: ## Install Test Requirements
pip install -r requirements/test.txt
piptools:
pip install -q -r requirements/pip-tools.txt
define COMMON_CONSTRAINTS_TEMP_COMMENT
# This is a temporary solution to override the real common_constraints.txt\n# In edx-lint, until the pyjwt constraint in edx-lint has been removed.\n# See BOM-2721 for more details.\n# Below is the copied and edited version of common_constraints\n
endef
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 "$(@)"
echo "$(COMMON_CONSTRAINTS_TEMP_COMMENT)" | cat - $(@) > temp && mv temp $(@)
compile-requirements: export CUSTOM_COMPILE_COMMAND = make upgrade
compile-requirements: piptools $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# Make sure to compile files after any other files they include!
pip-compile ${COMPILE_OPTS} --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/base.txt requirements/base.in
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/docs.txt requirements/docs.in
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/test.txt requirements/test.in
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/dev.txt requirements/dev.in
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/tox.txt requirements/tox.in
pip-compile ${COMPILE_OPTS} --verbose --rebuild -o requirements/ci.txt requirements/ci.in
# Let tox control the Django and DRF versions for tests
sed -i.tmp '/^django==/d' requirements/test.txt
sed -i.tmp '/^djangorestframework==/d' requirements/test.txt
rm requirements/test.txt.tmp
upgrade: ## update the pip requirements files to use the latest releases satisfying our constraints
$(MAKE) compile-requirements COMPILE_OPTS="--upgrade"
test: clean ## Run tests in the current virtualenv
pytest
coverage: clean ## Generate and view HTML coverage report
py.test --cov-report html
$(BROWSER) htmlcov/index.html
diff_cover: test ## Generate diff coverage report
diff-cover coverage.xml
test_quality: ## Run Quality checks
pylint submissions
isort --check-only submissions manage.py setup.py settings.py --skip migrations
pycodestyle . --config=pycodestyle
check_keywords: ## Scan the Django models in all installed apps in this project for restricted field names
python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml
##################
#Devstack commands
##################
install-local-submissions: ## installs your local submissions code into the LMS and Studio python virtualenvs
docker exec -t edx.devstack.lms bash -c '. /edx/app/edxapp/venvs/edxapp/bin/activate && cd /edx/app/edxapp/edx-platform && pip uninstall -y edx-submissions && pip install -e /edx/src/edx-submissions && pip freeze | grep edx-submissions'
docker exec -t edx.devstack.studio bash -c '. /edx/app/edxapp/venvs/edxapp/bin/activate && cd /edx/app/edxapp/edx-platform && pip uninstall -y edx-submissions && pip install -e /edx/src/edx-submissions && pip freeze | grep edx-submissions'