-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (58 loc) · 1.95 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
# Python code locations
app_code = bluepill/*.py
test_code = tests/*.py
package_name = "bluepill"
# Manage the location of pip-tools requirements
prod_reqs_in = setup.py
prod_reqs = requirements.txt
dev_reqs_in = dev-requirements.in
dev_reqs = dev-requirements.txt
all: clean test build
build: clean # Build the package
@printf "\n\n\033[0;32m** Packaging (dist) **\n\n\033[0m"
python setup.py sdist
pip install -e .
test: clean codelint seclint unittest
# Unit test with pytest and minimum 80% coverage with coverage.py
unittest: dev-deps
@printf "\n\n\033[0;32m** Unit testing (pytest) **\n\n\033[0m"
python setup.py test
# Static analysis with prospector for Python code
codelint: dev-deps
@printf "\n\n\033[0;32m** Static code analysis (prospector) **\n\n\033[0m"
prospector
# Static security analysis for Python code
seclint: dev-deps
@printf "\n\n\033[0;32m** Static code security analysis (bandit) **\n\n\033[0m"
bandit $(app_code)
# apply yapf formatting
yapf: dev-deps
@printf "\n\n\033[0;32m** Formatting (yapf) **\n\n\033[0m"
yapf -i $(app_code) $(test_code)
# Run yapf formatting then prospector. Use this for local dev.
dev-lint: dev-deps yapf
prospector $(app_code) $(test_code)
# clean artifacts between runs
clean:
rm -rf __pycache__
rm -rf .eggs
rm -rf *.egg-info
rm -rf .coverage
rm -rf dist
rm -rf .pytest_cache
rm -rf .coverage
pip uninstall $(package_name)
@CRAWLER_LOC=`which crawler` && rm -f $$CRAWLER_LOC && echo "Cleaned local install." || echo "No local install to clean."
# This section manages environment dependencies using pip-tools
# sync the prod dependecies if they changed
prod-deps: compile-prod-reqs
pip-sync $(prod_reqs)
# sync the dev dependencies if they changed
dev-deps: compile-dev-deps
pip-sync $(prod_reqs) $(dev_reqs)
# compile the prod dependecies from setup.py
compile-prod-reqs:
pip-compile
# compile the dev dependencies
compile-dev-deps: compile-prod-reqs
pip-compile $(dev_reqs_in) --output-file ./$(dev_reqs)