-
Notifications
You must be signed in to change notification settings - Fork 196
/
Makefile
166 lines (130 loc) · 7.49 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
.PHONY: help install-python install-js install-test install \
update-npm-requirements static \
extract_translations compile_translations generate_dummy_translations validate_translations \
detect_changed_source_translations pull_translations push_translations check_translations_up_to_date \
quality test-python render-templates test-js test-js-debug test test-acceptance test-a11y test-sandbox \
compile-requirements install-osx-requirements
.DEFAULT_GOAL := help
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 openassessment/ -name '__pycache__' -exec rm -rf {} +
find openassessment/ -name '*.pyc' -exec rm -f {} +
find openassessment/ -name '*.pyo' -exec rm -f {} +
find openassessment/ -name '*~' -exec rm -f {} +
coverage erase
rm -fr build/
rm -fr dist/
rm -fr *.egg-info
##################
# Install commands
##################
install-python: ## Install python dependencies
pip install -r requirements/base.txt --only-binary=lxml
install-js: ## install JavaScript dependencies
npm install
install-test: ## install requirements for tests
pip install -r requirements/test.txt
python setup.py develop --quiet # XBlock plugin (openassessment) has to be installed via entry_points.
install: install-python install-js install-test static ## install all dependencies
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: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# global common_constraints has this pin.
sed 's/django-simple-history==3.0.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
pip-compile ${COMPILE_OPTS} --allow-unsafe -o requirements/pip.txt requirements/pip.in
pip-compile ${COMPILE_OPTS} -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} --allow-unsafe -o requirements/base.txt requirements/base.in
pip-compile ${COMPILE_OPTS} -o requirements/test.txt requirements/test.in
pip-compile ${COMPILE_OPTS} --allow-unsafe -o requirements/quality.txt requirements/quality.in
pip-compile ${COMPILE_OPTS} -o requirements/test-acceptance.txt requirements/test-acceptance.in
pip-compile ${COMPILE_OPTS} -o requirements/tox.txt requirements/tox.in
pip-compile ${COMPILE_OPTS} --allow-unsafe -o requirements/ci.txt requirements/ci.in
pip-compile ${COMPILE_OPTS} -o requirements/docs.txt requirements/docs.in
# Delete django pin from test requirements to avoid tox version collision
sed -i.tmp '/^[d|D]jango==/d' requirements/test.txt
sed -i.tmp '/^djangorestframework==/d' requirements/test.txt
# Delete extra metadata that causes build to fail
sed -i.tmp '/^--index-url/d' requirements/*.txt
sed -i.tmp '/^--extra-index-url/d' requirements/*.txt
sed -i.tmp '/^--trusted-host/d' requirements/*.txt
# Delete temporary files
rm requirements/*.txt.tmp
upgrade: ## update the pip requirements files to use the latest releases satisfying our constraints
$(MAKE) compile-requirements COMPILE_OPTS="--upgrade"
##############################
# Generate js/css output files
##############################
STATIC_JS = openassessment/xblock/static/js
STATIC_CSS = openassessment/xblock/static/css
update-npm-requirements: ## update NPM requrements
npm update --silent
cp ./node_modules/backgrid/lib/backgrid*.js $(STATIC_JS)/lib/backgrid/
cp ./node_modules/backgrid/lib/backgrid*.css $(STATIC_CSS)/lib/backgrid/
static: ## Webpack JavaScript and SASS source files
npm run build
#######################
# Translations Handling
#######################
extract_translations: ## creates the django-partial.po & django-partial.mo files
cd ./openassessment && django-admin makemessages -l en -v1 -d django
cd ./openassessment && django-admin makemessages -l en -v1 -d djangojs
compile_translations: ## compiles the *.po & *.mo files
cd ./openassessment/ && i18n_tool generate -v && cd ..
generate_dummy_translations: ## generate dummy translations
i18n_tool dummy
validate_translations: ## Test translation files
cd ./openassessment/ && i18n_tool validate -v
detect_changed_source_translations: ## check if translation files are up-to-date
i18n_tool changed
pull_translations: ## pull translations from Transifex
tx pull -a -f -t --mode reviewed --minimum-perc=1
push_translations: ## push source translation files (.po) to Transifex
tx push -s
check_translations_up_to_date: extract_translations compile_translations generate_dummy_translations detect_changed_source_translations ## extract, compile, and check if translation files are up-to-date
##################
# Tests and checks
##################
quality: ## Run linting and code quality checks
npm run lint
./scripts/run-pycodestyle.sh
./scripts/run-pylint.sh
test-python: ## Run Python tests
pytest
render-templates: ## Render HTML templates
./scripts/render-templates.sh
test-js: render-templates ## Run JavaScript frontend tests
./scripts/test-js.sh
test-js-debug: render-templates ## Debug JavaScript tests using Karma
./scripts/js-debugger.sh
test: quality test-python test-js ## Run quality checks and tests for Python and JavaScript
test-sandbox: test-acceptance test-a11y ## Run acceptance and accessibility tests
install-osx-requirements: ## Install OSX specific requirements using Homebrew
brew install gettext
brew link gettext --force
###################
# Devstack commands
###################
install-local-ora: ## installs your local ORA2 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 ora2 && pip install -e /edx/src/edx-ora2 && pip freeze | grep ora2'
docker exec -t edx.devstack.cms bash -c '. /edx/app/edxapp/venvs/edxapp/bin/activate && cd /edx/app/edxapp/edx-platform && pip uninstall -y ora2 && pip install -e /edx/src/edx-ora2 && pip freeze | grep ora2'
docker exec -t edx.devstack.lms bash -c 'kill $$(ps aux | egrep "manage.py ?\w* runserver" | egrep -v "while|grep" | awk "{print \$$2}")'
docker exec -t edx.devstack.cms bash -c 'kill $$(ps aux | egrep "manage.py ?\w* runserver" | egrep -v "while|grep" | awk "{print \$$2}")'
install_transifex_client: ## Install the Transifex client
# Instaling client will skip CHANGELOG and LICENSE files from git changes
# so remind the user to commit the change first before installing client.
git diff -s --exit-code HEAD || { echo "Please commit changes first."; exit 1; }
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
# Load the PATH changes to make transifex client accessible from any directory i.e. openassessment for pull translations
export PATH="$(PATH):$(pwd)"
git checkout -- LICENSE ## overwritten by Transifex installer
rm README.md ## pulled by Transifex installer