-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
147 lines (97 loc) · 2.93 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
SHELL=/bin/bash
.DEFAULT_GOAL := help
# ---------------------------------
# Project specific targets
# ---------------------------------
#
# Add any targets specific to the current project in here.
# -------------------------------
# Common targets for Dev projects
# -------------------------------
#
# Edit these targets so they work as expected on the current project.
#
# Remember there may be other tools which use these targets, so if a target is not suitable for
# the current project, then keep the target and simply make it do nothing.
help: ## This help dialog.
help: help-display
clean: ## Remove unneeded files generated from the various build tasks.
clean: coverage-clean
reset: ## Reset your local environment. Useful after switching branches, etc.
reset: venv-check venv-wipe install-local
clear: ## Like reset but without the wiping of the installs.
clear: ;
check: ## Check for any obvious errors in the project's setup.
check: pipdeptree-check npm-check
format: ## Run this project's code formatters.
format: black-format isort-format
lint: ## Lint the project.
lint: black-lint isort-lint flake8-lint
test: ## Run unit and integration tests.
test: pytest-test
test-report: ## Run and report on unit and integration tests.
test-report: coverage-clean test coverage-report
serve: ## Run a local development server.
serve: flask-serve
deploy: ## Deploy this project to demo or live.
deploy: fab-deploy
# ---------------
# Utility targets
# ---------------
#
# Targets which are used by the common targets. You likely want to customise these per project,
# to ensure they're pointing at the correct directories, etc.
# Virtual Environments
venv-check:
ifndef VIRTUAL_ENV
$(error Must be in a virtualenv)
endif
venv-wipe: venv-check
if ! pip list --format=freeze | grep -v "^pip=\|^setuptools=\|^wheel=" | xargs pip uninstall -y; then \
echo "Nothing to remove"; \
fi
# Installs
install-local: npm-install pip-install-local
# Pip
pip-install-local: venv-check
pip install -r requirements/local.txt
# Fabfile
fab-deploy:
fab deploy
# ISort
isort-lint:
isort --check-only --diff project tests
isort-format:
isort project tests
# Flake8
flake8-lint:
flake8 project tests
# Coverage
coverage-report: coverage-html
coverage report --show-missing
coverage-html:
coverage html
coverage-clean:
rm -rf htmlcov
rm -f .coverage
# Project testing
pytest-test:
PYTHONWARNINGS=all coverage run -m pytest
# NPM
npm-check: npm-install
npm-install:
cmp --silent package-lock.json node_modules/.package-lock.json || (npm ci && cp -a package-lock.json node_modules/.package-lock.json)
# Black
black-lint:
black --check project tests
black-format:
black project tests
#pipdeptree
pipdeptree-check:
pipdeptree --warn fail > /dev/null
# Local server
flask-serve:
FLASK_APP=project FLASK_DEBUG=1 python -m flask run
# Help
help-display:
@awk '/^[\-[:alnum:]]*: ##/ { split($$0, x, "##"); printf "%20s%s\n", x[1], x[2]; }' $(MAKEFILE_LIST)