-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (53 loc) · 1.82 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
PROJECT_NAME = youtube-crypto-index
REGION = eu-west-2
PYTHON_INTERPRETER = python
WD=$(shell pwd)
PYTHONPATH=${WD}
SHELL := /bin/bash
PROFILE = default
PIP:=pip
## Create python interpreter environment.
create-environment:
@echo ">>> About to create environment: $(PROJECT_NAME)..."
@echo ">>> check python3 version"
( \
$(PYTHON_INTERPRETER) --version; \
)
@echo ">>> Setting up VirtualEnv."
( \
$(PIP) install -q virtualenv virtualenvwrapper; \
virtualenv venv --python=$(PYTHON_INTERPRETER); \
)
# Define utility variable to help calling Python from the virtual environment
ACTIVATE_ENV := source venv/bin/activate
# Execute python related functionalities from within the project's environment
define execute_in_env
$(ACTIVATE_ENV) && $1
endef
## Build the environment requirements
requirements: create-environment
$(call execute_in_env, $(PIP) install -r ./requirements.txt)
## Add new environment requirements
add-requirements:
$(call execute_in_env, $(PIP) freeze > ./requirements.txt)
## spin up docker for dev-db
spin-dev-db:
docker-compose up -d
$(call execute_in_env, docker-compose up -d )
################################################################################################################
# Build / Run
## Run the security test (bandit + safety)
security-test:
$(call execute_in_env, safety check -r ./requirements.txt)
$(call execute_in_env, bandit -lll */*.py *c/*/*.py)
## Run the flake8 code check
run-flake:
$(call execute_in_env, flake8 ./src/*.py ./test/*.py)
## Run the unit tests
unit-test:
$(call execute_in_env, PYTHONPATH=${PYTHONPATH} pytest -v)
## Run the coverage check
check-coverage:
$(call execute_in_env, PYTHONPATH=${PYTHONPATH} coverage run --omit 'venv/*' -m pytest && coverage report -m)
## Run all checks
run-checks: run-flake unit-test check-coverage # security-test