generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
61 lines (47 loc) · 1.45 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
.ONESHELL:
PYTHON_SOURCE_FILES = ./tests operations_engineering_join_github.py ./app
help:
@echo "Available commands:"
@echo "make venv - venv the environment"
@echo "make test - Run tests"
@echo "make local - Run application locally"
@echo "make lint - Run Lint tools"
@echo "make report - Open the Code Coverage report"
venv: requirements.txt
python3 -m venv venv
venv/bin/pip3 install --upgrade pip
venv/bin/pip3 install -r requirements.txt
# Run MegaLinter
lint:
npx mega-linter-runner -e 'SHOW_ELAPSED_TIME=true'
format: venv
venv/bin/pip3 install black
venv/bin/black $(PYTHON_SOURCE_FILES)
test: venv
venv/bin/pip3 install pytest
venv/bin/pip3 install coverage
venv/bin/coverage run -m pytest tests/ -v
report:
venv/bin/coverage html && open htmlcov/index.html
flake8: venv
venv/bin/pip3 install flake8
venv/bin/flake8 --config=./.flake8 --exclude=venv,__pycache__,.pytest_cache,.venv .
clean-test:
rm -fr venv
rm -fr .venv
rm -fr .tox/
rm -fr .pytest_cache
rm -fr .mypy_cache
rm -fr .coverage
rm -fr htmlcov/
local: venv
venv/bin/python3 -m app.run
# Assumes you've already built the image locally
docker-up:
docker-compose -f docker-compose.yaml up -d
trivy-scan:
@echo "Running Trivy scan..."
docker build -t localbuild/testimage:latest .
trivy image --severity HIGH,CRITICAL localbuild/testimage:latest
all:
.PHONY: trivy-scan venv lint test format local clean-test report all