forked from open-craft/cohort-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (56 loc) · 2.66 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
.PHONY: clean coverage diff_cover help js js-watch quality selfcheck test validate
.DEFAULT_GOAL := help
# PROJECT_ROOT is usually '/edx/src/cohort-manager/' on an Open edX devstack
PROJECT_ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
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"
NODE_BIN_PATH := "./node_modules/.bin/"
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}'
clean: ## remove generated byte code, coverage reports, and build artifacts
find $(PROJECT_ROOT) -name '__pycache__' -exec rm -rf {} +
find $(PROJECT_ROOT) -name '*.pyc' -exec rm -f {} +
find $(PROJECT_ROOT) -name '*.pyo' -exec rm -f {} +
find $(PROJECT_ROOT) -name '*~' -exec rm -f {} +
cd $(PROJECT_ROOT) && coverage erase
rm -fr $(PROJECT_ROOT)build/
rm -fr $(PROJECT_ROOT)dist/
# Do not delete the .egg-info because it will uninstall the entry point
# and thus unregister the plugin.
# rm -fr $(PROJECT_ROOT)*.egg-info
coverage: clean ## generate and view HTML coverage report
pytest --cov-report html
$(BROWSER) htmlcov/index.html
js: ## Compile javascript
./node_modules/.bin/tsc --noEmit
quality: ## check coding style with pycodestyle and pylint
pylint cohort_manager $(PROJECT_ROOT)setup.py
pylint --py3k cohort_manager $(PROJECT_ROOT)setup.py
pycodestyle $(PROJECT_ROOT)cohort_manager $(PROJECT_ROOT)setup.py
isort --check-only --diff --recursive $(PROJECT_ROOT)cohort_manager $(PROJECT_ROOT)setup.py
# test target:
# Meant to be run in LMS's virtualenv
# We don't use tox because we need to test with the real installation of
# Open edX and whatever dependencies it uses.
# We use no-cov and nomigrations because they _really_ speed up the test run.
test: clean ## Run tests; run this from the lms-shell
python -m pytest --ds=lms.envs.test --no-cov --nomigrations $(PROJECT_ROOT)cohort_manager/tests/
diff_cover: test ## find diff lines that need test coverage
diff-cover coverage.xml
validate: quality js test ## run tests and quality checks
selfcheck: ## check that the Makefile is well-formed
@echo "The Makefile is well-formed."
format: ## format javascript source files
./node_modules/.bin/prettier --write "*.js"
./node_modules/.bin/prettier --write "cohort_manager/js-src/*.{ts,tsx}"
bundle: js ## bundle javascript
$(NODE_BIN_PATH)/rollup -c