forked from DSMYTH0/de-project-vinson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
90 lines (71 loc) · 2.41 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
#################################################################################
#
# Makefile to build the project
#
#################################################################################
PROJECT_NAME = de-project-vinson
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
## Set up log directory
logdirs:
mkdir -p logs
## Build the environment requirements
requirements: create-environment logdirs
$(call execute_in_env, $(PIP) install -r ./requirements.txt)
# $(call execute_in_env, $(PIP) install -r ./requirements.txt -t python/lib/python3.12/site-packages/)
################################################################################################################
# Set Up
## Install bandit
bandit:
$(call execute_in_env, $(PIP) install bandit)
## Install safety
safety:
$(call execute_in_env, $(PIP) install safety)
## Install black
black:
$(call execute_in_env, $(PIP) install black==22.12.0)
## Install coverage
coverage:
$(call execute_in_env, $(PIP) install coverage)
## Set up dev requirements (bandit, safety, flake8)
dev-setup: bandit safety black coverage
# Build / Run
## Run the security test (bandit + safety)
security-test:
$(call execute_in_env, safety check --ignore=70612 -r ./requirements.txt)
$(call execute_in_env, bandit -lll src/*/*.py)
## Run the black code check
run-black:
$(call execute_in_env, black src tests)
## Run the unit tests
unit-test:
$(call execute_in_env, PYTHONPATH=${PYTHONPATH} pytest -vvv --testdox)
## 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: security-test run-black unit-test check-coverage
##########################################################