forked from openedx/staff_graded-xblock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (77 loc) · 4.1 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
.DEFAULT_GOAL := help
.PHONY: clean dev.clean dev.build dev.run test quality requirements \
quality-python test-js test-python install_transifex_client
REPO_NAME := staff_graded-xblock
PACKAGE_NAME := staff_graded
EXTRACT_DIR := $(PACKAGE_NAME)/locale/en/LC_MESSAGES
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_TEXT := $(EXTRACT_DIR)/text.po
JS_TARGET := public/js/translations
TRANSLATIONS_DIR := $(PACKAGE_NAME)/translations
help:
@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: ## delete generated byte code and coverage reports
find . -name '*.pyc' -delete
find . -name '__pycache__' -type d -exec rm -rf {} ';' || true
rm -rf assets
rm -rf pii_report
dev.clean:
-docker rm $(REPO_NAME)-dev
-docker rmi $(REPO_NAME)-dev
dev.build:
docker build -t $(REPO_NAME)-dev $(CURDIR)
dev.run: dev.clean dev.build ## Clean, build and run test image
docker run -p 8000:8000 -v $(CURDIR):/usr/local/src/$(REPO_NAME) --name $(REPO_NAME)-dev $(REPO_NAME)-dev
## Localization targets
extract_translations: symlink_translations ## extract strings to be translated, outputting .po files
cd $(PACKAGE_NAME) && i18n_tool extract
mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT)
if [ -f "$(EXTRACTED_DJANGOJS)" ]; then cat $(EXTRACTED_DJANGOJS) >> $(EXTRACTED_TEXT); rm $(EXTRACTED_DJANGOJS); fi
compile_translations: symlink_translations ## compile translation files, outputting .mo files for each supported language
cd $(PACKAGE_NAME) && i18n_tool generate
python manage.py compilejsi18n --namespace $(PACKAGE_NAME)i18n --output $(JS_TARGET)
detect_changed_source_translations:
cd $(PACKAGE_NAME) && i18n_tool changed
dummy_translations: ## generate dummy translation (.po) files
cd $(PACKAGE_NAME) && i18n_tool dummy
build_dummy_translations: dummy_translations compile_translations ## generate and compile dummy translation files
validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations
pull_translations: ## pull translations from transifex
cd $(PACKAGE_NAME) && i18n_tool transifex pull
push_translations: extract_translations ## push translations to transifex
cd $(PACKAGE_NAME) && i18n_tool transifex push
symlink_translations:
if [ ! -d "$(TRANSLATIONS_DIR)" ]; then ln -s locale/ $(TRANSLATIONS_DIR); fi
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) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -q -r requirements/pip_tools.txt
pip-compile --upgrade --allow-unsafe -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/test.txt requirements/test.in
pip-compile --upgrade -o requirements/tox.txt requirements/tox.in
pip-compile --upgrade -o requirements/ci.txt requirements/ci.in
pip-compile --upgrade -o requirements/dev.txt requirements/dev.in
requirements: ## install development environment requirements
pip install -q -r requirements/pip.txt
pip install -q -r requirements/dev.txt
quality-python: ## Run python linters
pylint --rcfile=pylintrc staff_graded setup.py
quality: quality-python ## Run linters
test-python: clean ## run tests using pytest and generate coverage report
-pytest
install-js: ## install JavaScript dependencies
npm install
test-js: ## run tests using npm
-npm test
test: test-js test-python ## run tests
install_transifex_client: ## Install the Transifex client
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
git checkout -- LICENSE README.md