forked from openedx/tutor-contrib-aspects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (80 loc) · 3.83 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
.PHONY: build-pythonpackage dev-requirements format help release release-push \
release-tag release-unsafe requirements test test-format test-install \
test-lint test-pythonpackage test-types upgrade version
.DEFAULT_GOAL := help
PACKAGE=tutoraspects
PROJECT=tutor-contrib-aspects
SOURCES=./setup.py ./$(PACKAGE)
BLACK_OPTS = --exclude templates ${SOURCES}
UPGRADE=CUSTOM_COMPILE_COMMAND='make upgrade' pip-compile --upgrade
TUTOR_ROOT=$(PWD)/.ci
###### Development
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 -qr requirements/pip-tools.txt
$(UPGRADE) --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in
$(UPGRADE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -r requirements/pip-tools.txt
$(UPGRADE) -o requirements/base.txt requirements/base.in
$(UPGRADE) -o requirements/dev.txt requirements/dev.in
$(UPGRADE) -o requirements/translations.txt requirements/translations.in
requirements: ## Install packages from base requirement files
pip install -r requirements/pip.txt
pip install -r requirements/base.txt
pip uninstall --yes $(PROJECT)
pip install .
dev-requirements: ## Install packages from developer requirement files
pip install -r requirements/pip.txt
pip install -r requirements/dev.txt
pip uninstall --yes $(PROJECT)
pip install -e .
translation-requirements: ## Install packages from translation requirements
pip install -r requirements/pip.txt
pip install -r requirements/translations.txt
build-pythonpackage: ## Build Python packages ready to upload to pypi
python setup.py sdist bdist_wheel
test: dev-requirements test-lint test-format test-pythonpackage ## Run all tests by decreasing order of priority
test-format: ## Run code formatting tests
black --check --diff $(BLACK_OPTS)
test-lint: ## Run code linting tests
pylint ${SOURCES}
test-install: ## Run installation test script
tests/test-install.sh
test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi
twine check dist/$(PROJECT)-$(shell make version).tar.gz
format: ## Format code automatically
black $(BLACK_OPTS)
###### Deployment
release: test release-unsafe ## Create a release tag and push it to origin
release-unsafe:
$(MAKE) release-tag release-push TAG=v$(shell make version)
release-tag:
@echo "=== Creating tag $(TAG)"
git tag -d $(TAG) || true
git tag $(TAG)
release-push:
@echo "=== Pushing tag $(TAG) to origin"
git push origin
git push origin :$(TAG) || true
git push origin $(TAG)
###### Additional commands
pull_translations: translation-requirements
rm -rf tutoraspects/templates/aspects/apps/superset/conf/locale/*;
atlas pull $(OPENEDX_ATLAS_ARGS) translations/tutor-contrib-aspects/tutoraspects/templates/aspects/apps/superset/conf/locale/:tutoraspects/templates/aspects/apps/superset/conf/locale/
@echo "Translations have been pulled via Atlas."
python scripts/translate.py . compile
extract_translations: translation-requirements
python scripts/translate.py . extract
version: ## Print the current tutor version
@python -c 'import io, os; about = {}; exec(io.open(os.path.join("$(PACKAGE)", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])'
ESCAPE =
help: ## Print this help
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
| sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'