-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (63 loc) · 1.68 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
# https://opensource.com/article/18/8/what-how-makefile
#############
# Variables #
#############
# ?= -> Only set if var doesn't have a value
WORK_DIR ?= $(shell pwd)
##################
# Docker-Compose #
##################
down:
@docker-compose down ${APP}
up:
@docker-compose up -d ${APP}
bounce: down up
stop:
@docker-compose stop ${APP}
start:
@docker-compose start ${APP}
restart:
@docker-compose restart ${APP}
build:
@docker-compose build ${APP}
rebuild: down build up
build-nc:
@docker-compose build ${APP} --no-cache
rebuild-nc: down build-nc up
logs:
@docker-compose logs volobot
#################
# General Utils #
#################
# Install requirements.txt to venv
install:
@. .venv/bin/activate; \
pip install -r requirements.txt; \
###############
# Code Health #
###############
# Format code body, DIR=[file or directory]
black: needs-dir
@echo
@echo "Checking format for $(DIR)"
@find $(WORK_DIR)/$(DIR) -name "*.py" | xargs -I{} pre-commit run black --hook-stage manual --files {}
# Format imports, DIR=[file or directory]
isort: needs-dir
@find $(WORK_DIR)/$(DIR) -name "*.py" | xargs -I{} pre-commit run isort --hook-stage manual --files {}
# Format code using black (body) + isort (imports), DIR=[file or directory]
format: needs-dir black isort
# Lint, DIR=[file or directory]
lint: needs-dir
@echo
@echo "Checking lint for $(DIR)"
@find $(WORK_DIR)/$(DIR) -name "*.py" | xargs -I{} pre-commit run ruff --hook-stage manual --files {}
# Format, lint, typecheck (TDOD), DIR=[file or directory]
healthy: needs-dir format lint
###################
# Ensure env Vars #
###################
needs-dir:
ifeq ($(strip $(DIR)),)
@echo "DIR not set!"
@exit 1
endif