-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
106 lines (81 loc) · 2.51 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#* Variables
SHELL:=/usr/bin/env bash
ARGS:=
CONSOLE:=bash
#* Docker variables
DOCKER=docker-compose --file docker/compose.yaml --env-file docker/.env
DOCKER_IMAGE:=epigraphhub_py
DOCKER_VERSION:=latest
DOCKER_SERVICES:=
DOCKER_SERVICE:=
TIMEOUT:=90
#* Formatters
.PHONY: linter
linter:
pre-commit run --all-files --verbose
poetry run darglint --verbosity 2 epigraphhub_py tests
#* Tests
.PHONY: test
test:
poetry run pytest --cov-report=html -vv --cov tests/ ${ARGS}
poetry run coverage-badge -o assets/images/coverage.svg -f
.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report
poetry run bandit -ll --recursive epigraphhub_py tests
#* Docker
# Example: make docker-build VERSION=latest
# Example: make docker-build IMAGE=some_name VERSION=0.1.0
.PHONY: docker-build
docker-build:
@echo Building docker $(DOCKER_IMAGE):$(DOCKER_VERSION) ...
docker build \
-t $(DOCKER_IMAGE):$(DOCKER_VERSION) . \
-f ./docker/Dockerfile --no-cache
# Example: make docker-remove VERSION=latest
# Example: make docker-remove IMAGE=some_name VERSION=0.1.0
.PHONY: docker-remove
docker-remove:
@echo Removing docker $(DOCKER_IMAGE):$(DOCKER_VERSION) ...
docker rmi -f $(DOCKER_IMAGE):$(DOCKER_VERSION)
.PHONY: docker-compose-build
docker-compose-build:
$(DOCKER) pull ${DOCKER_SERVICES}
$(DOCKER) build ${DOCKER_SERVICES}
.PHONY: docker-compose-start
docker-compose-start:
$(DOCKER) up -d ${DOCKER_SERVICES}
.PHONY: docker-compose-run-console
docker-compose-run-console:
$(DOCKER) run ${DOCKER_SERVICE} ${CONSOLE}
.PHONY: docker-compose-start-no-detatched
docker-compose-start-no-detatched: # useful for debugging
$(DOCKER) up ${DOCKER_SERVICES}
.PHONY: docker-compose-stop
docker-compose-stop:
$(DOCKER) stop ${DOCKER_SERVICES}
.PHONY: docker-compose-down
docker-compose-down:
$(DOCKER) down --volume ${DOCKER_SERVICES}
.PHONY: docker-compose-logs
docker-compose-logs:
$(DOCKER) logs ${ARGS} ${DOCKER_SERVICES}
.PHONY: docker-compose-restart
docker-compose-restart: docker-compose-stop docker-compose-stop
.PHONY: docker-compose-wait
docker-compose-wait:
timeout ${TIMEOUT} ./docker/healthcheck.sh ${SERVICE}
#* Config
.PHONY:
config-file: # for development
bash scripts/dev/create-config-file.sh
#* Cleaning
.PHONY: cleanup
cleanup:
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf
find . | grep -E ".DS_Store" | xargs rm -rf
find . | grep -E ".mypy_cache" | xargs rm -rf
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf
find . | grep -E ".pytest_cache" | xargs rm -rf
rm -rf build/