forked from open-craft/xblock-poll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (99 loc) · 5.34 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
.PHONY: dummy_translations extract_translations help pull_translations push_translations
.DEFAULT_GOAL := help
FIREFOX_VERSION := "67.0"
FIREFOX_LINUX_ARCH := $(shell uname -m)
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 . -name '__pycache__' -exec rm -rf {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find poll/translations -name djangojs.mo -exec rm -f {} +
find poll/translations -name djangojs.po -exec rm -f {} +
find poll/translations -name textjs.mo -exec rm -f {} +
coverage erase
rm -fr build/
rm -fr dist/
rm -fr *.egg-info
# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS)
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -qr requirements/pip-tools.txt
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
sed -i '/^[dD]jango==/d' requirements/test.txt
quality: ## check coding style with pycodestyle and pylint
tox -e quality
node_requirements: ## Install requirements for handlebar templates i18n extraction
npm install
piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip.txt
pip install -r requirements/pip-tools.txt
python_requirements: install_linux_dev_firefox piptools ## install development environment requirements
pip-sync requirements/dev.txt requirements/private.*
requirements: node_requirements python_requirements ## install development environment requirements
@echo "Finished installing requirements."
install_linux_dev_firefox: ## Downloads custom version of firefox for Selenium in Linux
@echo "This works only on Linux. For MacOS please check the README file"
rm -rf .firefox .geckodriver
mkdir .firefox .geckodriver
curl http://ftp.mozilla.org/pub/firefox/releases/$(FIREFOX_VERSION)/linux-$(FIREFOX_LINUX_ARCH)/en-US/firefox-$(FIREFOX_VERSION).tar.bz2 \
--output .firefox/firefox.tar.bz2
cd .firefox && tar -xvjf firefox.tar.bz2
cd .geckodriver && wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
cd .geckodriver && tar -xzf geckodriver-v0.26.0-linux64.tar.gz
linux_dev_test: ## Run tests in development environment to use custom firefox
mkdir -p var
PATH=.firefox/firefox/:.geckodriver/:$(PATH) xvfb-run python run_tests.py
test: ## run tests in the current virtualenv
mkdir -p var
DJANGO_SETTINGS_MODULE=workbench.settings pytest
selfcheck: ## check that the Makefile is well-formed
@echo "The Makefile is well-formed."
## Localization targets
extract_translations: ## extract strings to be translated, outputting .po files
rm -rf docs/_build
# Extract Python and Django template strings
mkdir -p locale/en/LC_MESSAGES/
rm -f locale/en/LC_MESSAGES/{django,text}.po
python manage.py makemessages -l en -v1 -d django
mv locale/en/LC_MESSAGES/django.po locale/en/LC_MESSAGES/text.po
@# Note: Intentionally ignoring JS translations in favor of Handlebars
@# Keep the line below commented, there is one JavaScript file that has only one
@# i18n string is js/poll_edit.js:259 which is (`Saving`)
@# already available by other edX platform resources.
@# django-admin makemessages -l en -v1 -d djangojs -e js
# Extract Handlebars i18n strings
> locale/en/LC_MESSAGES/textjs.po # Ensure it's empty
# The sort to avoid bash arbitrary file order
ls poll/public/handlebars/*.handlebars \
| xargs node node_modules/.bin/xgettext-template --from-code utf8 \
--language Handlebars \
--force-po \
--output locale/en/LC_MESSAGES/textjs.po
compile_translations: ## compile translation files, outputting .mo files for each supported language
i18n_tool generate
python manage.py compilejsi18n
make clean
detect_changed_source_translations: ## Determines if the source translation files are up-to-date, otherwise exit with a non-zero code.
i18n_tool changed
pull_translations: ## pull translations from Transifex
i18n_tool transifex pull
make compile_translations
push_translations: extract_translations ## push source translation files (.po) to Transifex
tx push -s
dummy_translations: ## generate dummy translation (.po) files
i18n_tool dummy
build_dummy_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files
validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations