-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
118 lines (94 loc) · 3.25 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
PROJECT_PACKAGE := js_routes
TEST_PACKAGE := tests
init:
@printf "\n\n${YELLOW}---------------- Initialization ---${RESET} ${GREEN}Python dependencies${RESET}\n\n"
poetry install
@printf "\n\n${YELLOW}---------------- Initialization ---${RESET} ${GREEN}Node.js dependencies${RESET}\n\n"
npm install
@printf "\n\n${YELLOW}---------------- Done.${RESET}\n\n"
# DEVELOPMENT
# ~~~~~~~~~~~
# The following rules can be used during development in order to launch development server, generate
# locales, etc.
# --------------------------------------------------------------------------------------------------
.PHONY: c console
## Alias of "console".
c: console
## Launch a development console.
console:
poetry run ipython
.PHONY: static_resolver
## Regenerate the static version of the routes resolver.
static_resolver:
poetry run ipython ./js_routes/_scripts/build_static_resolver.py
# QUALITY ASSURANCE
# ~~~~~~~~~~~~~~~~~
# The following rules can be used to check code quality, import sorting, etc.
# --------------------------------------------------------------------------------------------------
.PHONY: qa
## Trigger all quality assurance checks.
qa: lint isort
.PHONY: lint
## Trigger Python code quality checks (flake8).
lint:
poetry run flake8
.PHONY: isort
## Check Python imports sorting.
isort:
poetry run isort --check-only --diff $(PROJECT_PACKAGE) $(TEST_PACKAGE)
# TESTING
# ~~~~~~~
# The following rules can be used to trigger tests execution and produce coverage reports.
# --------------------------------------------------------------------------------------------------
.PHONY: t tests
## Alias of "tests".
t: tests
## Run all the test suites.
tests: tests_python tests_javascript
## Run the Javascript test suite.
tests_javascript:
npm test
## Run the Python test suite.
tests_python:
poetry run py.test
.PHONY: coverage
## Collects code coverage data for all codebases.
coverage: coverage_python coverage_javascript
## Collects code coverage data for the Javascript codebase.
coverage_javascript:
npm test
## Collects code coverage data for the Python codebase.
coverage_python:
poetry run py.test --cov-report term-missing --cov $(PROJECT_PACKAGE)
.PHONY: spec spec_python
# Run test suites in "spec" mode.
spec: spec_python
# Run the Python test suite in "spec" mode.
spec_python:
poetry run py.test --spec -p no:sugar
# MAKEFILE HELPERS
# ~~~~~~~~~~~~~~~~
# The following rules can be used to list available commands and to display help messages.
# --------------------------------------------------------------------------------------------------
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
.PHONY: help
## Print Makefile help.
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<action>${RESET}'
@echo ''
@echo 'Actions:'
@awk '/^[a-zA-Z\-\_0-9] :/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)-30s${RESET}\t${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort -t'|' -sk1,1