-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (53 loc) · 1.79 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
APP_NAME:=homelab
PACKAGE_NAME:=homelab
# Helpers for local files discovery
TOP_LEVEL_SCRIPTS:=./run.py
CODE_DIRS:=${TOP_LEVEL_SCRIPTS} ./${PACKAGE_NAME} ./tests
CODE_FILES:=${TOP_LEVEL_SCRIPTS} $(shell find ./${PACKAGE_NAME} -name '*.py')
# Dinamically defining the image tag according to env vars
# `CIRCLE_BRANCH` will have the branch name during CircleCI builds
ifeq (${CIRCLE_BRANCH},)
TAG=${APP_NAME}-${subst /,_,$(shell git rev-parse --abbrev-ref HEAD)}
else ifeq (${CIRCLE_BRANCH},production)
TAG=${APP_NAME}-master
else
TAG=${APP_NAME}-${subst /,_,${CIRCLE_BRANCH}}
endif
.PHONY: check-all check-commit check-format check-push clean env env-prune format image image-push test
#---------------------------------
check-all: check-commit check-push
check-commit:
flake8 ${CODE_DIRS}
isort ${CODE_DIRS} --check
mypy ${CODE_FILES} --ignore-missing-imports
black ${CODE_DIRS} --check
sqlfluff lint ${CODE_DIRS}
check-format: format check-all
check-push:
vulture ${CODE_DIRS}
pydocstyle ${CODE_DIRS}
bandit -r ./${PACKAGE_NAME} -q
git ls-files -z | xargs -0 detect-secrets-hook --exclude-files "helm/*" --baseline .secrets.baseline
clean:
find . -name "*.pyc" -type f -delete
rm -rf .pytest_cache
env-windows:
virtualenv .venv --python=3.11 && . .venv/Scripts/activate && poetry install
env-prune-windows:
rmdir /s /q .venv
env:
virtualenv .venv --python=3.11
. .venv/Scripts/activate; poetry install;
env-prune:
rm -r .venv
format:
black ${CODE_DIRS}
isort ${CODE_DIRS}
sqlfluff fix ${CODE_DIRS}
image:
docker build -t rockerbox/rockerbox-metrics:${TAG} .
image-push:
docker image push rockerbox/rockerbox-metrics:${TAG}
test:
python -m coverage run -m pytest --junitxml=tests-results/junit.xml
coverage report --omit='.tox/*,*/test_*,*/test*/*' 2>&1 | tee tests-results/coverage.txt