-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (83 loc) · 2.53 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
path := .
TEST_FOLDER := tests/
SRC_FOLDER := src/
.DEFAULT_GOAL := help
MAKEFLAGS += --silent --no-print-directory
RED := \\033[0;31m
GREEN := \\033[1;32m
YELLOW := \\033[1;33m
BLUE := \\033[0;36m
RESET := \\033[0m
# Main
##############################################################################
.PHONY: update
update:
poetry install
# Lint
##############################################################################
.PHONY: lint-check lint lints check
lint-check: ruff mypy pyright black ## Complete code base check with linters and formatters
# Alias
lint: lint-check ## Alias for 'lint-check'
lints: lint-check ## Alias for 'lint-check'
check: lint-check ## Alias for 'lint-check'
.PHONY: ruff
ruff: # Use 'ruff' utility as linter
@echo -e
@echo -e "$(BLUE)Applying ruff..."
@echo -e "$(GREEN)================$(RESET)"
@echo -e
poetry run ruff check $(path) --fix
@echo -e
.PHONY: mypy
mypy: # Use 'mypy' utility as linter
@echo -e
@echo -e "$(BLUE)Applying mypy..."
@echo -e "$(GREEN)================$(RESET)"
@echo -e
poetry run mypy $(path)
@echo -e
.PHONY: pyright
pyright: ## Use 'pyright' utility as linter
@echo -e
@echo -e "$(BLUE)Applying pyright..."
@echo -e "$(GREEN)===================$(RESET)"
@echo -e
poetry run pyright $(path)
@echo -e
.PHONY: black
black: ## Use 'black' utility as formatter
@echo -e
@echo -e "$(BLUE)Applying black..."
@echo -e "$(GREEN)=================$(RESET)"
@echo -e
poetry run black $(path)
@echo -e
# Clean cache
##############################################################################
.PHONY: clean
clean: ## Clear linter cache (.mypy_cache .ruff_cache)
@echo -e "$(RED)Remove:$(RESET) .mypy_cache/"
@echo -e "$(RED)Remove:$(RESET) .ruff_cache/"
@echo -e "$(RED)Remove:$(RESET) .pytest_cache/"
@rm -rf .mypy_cache
@rm -rf .ruff_cache
@rm -rf .pytest_cache
# Tests
##############################################################################
.PHONY: test
test: ## Runs tests for the application
poetry run python -m pytest --verbose $(TEST_FOLDER)
.PHONY: coverage
coverage: ## Runs tests and coverage
poetry run python -m pytest --verbose --cov=$(SRC_FOLDER)
# Other
##############################################################################
.PHONY: help
help: ## Show this output, i.e. help to use the commands
grep -E '^[a-zA-Z_-]+:.*?# .*$$' Makefile | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
info-%:
@make --dry-run --always-make $* | grep -v "info"
print-%:
@$(info '$*'='$($*)')
.SILENT: