-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (76 loc) · 2.66 KB
/
Makefile
File metadata and controls
92 lines (76 loc) · 2.66 KB
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
.DEFAULT_GOAL := help
include .env.local
AUTOPEP8 ?= autopep8
COMPOSE_FILE ?= compose.yaml
DOCKER_COMPOSE ?= docker compose -f $(COMPOSE_FILE)
PIP ?= pip
PYTEST ?= pytest
PYTHON ?= python
SERVER_ENV ?= prod
VERBOSE ?= 0
COLOR_SUPPORT ?= $(shell [ "$$(tput colors 2>/dev/null)" -ge 8 ] && echo 1 || echo 0)
COLOR_GREEN =
COLOR_YELLOW =
COLOR_END =
ifeq ($(COLOR_SUPPORT),1)
COLOR_GREEN = \033[0;32m
COLOR_YELLOW = \033[0;33m
COLOR_END = \033[0m
endif
.PHONY: help install lint lint-autopep8 lint-fix lint-fix-autopep8 start test docker-shell docker-start docker-stop
help:
@echo "$(COLOR_YELLOW)Usage:$(COLOR_END)"
@echo " make [target] [VARIABLE=value]"
@echo ""
@echo "$(COLOR_YELLOW)Example:$(COLOR_END)"
@echo " make start VERBOSE=1"
@echo ""
@echo "$(COLOR_YELLOW)Available targets: $(COLOR_END)"
@echo "$(COLOR_GREEN) install $(COLOR_END) Installs dependencies from requirements.txt"
@echo "$(COLOR_GREEN) start $(COLOR_END) Starts the web server"
@echo "$(COLOR_GREEN) test $(COLOR_END) Executes tests"
@echo "$(COLOR_YELLOW) coding standard $(COLOR_END)"
@echo "$(COLOR_GREEN) lint $(COLOR_END) Lints files"
@echo "$(COLOR_GREEN) lint-autopep8 $(COLOR_END) Lints files with autopep8"
@echo "$(COLOR_GREEN) lint-fix $(COLOR_END) Fixes files linting"
@echo "$(COLOR_GREEN) lint-fix-autopep8 $(COLOR_END) Fixes files linting with autopep8"
@echo "$(COLOR_YELLOW) docker $(COLOR_END)"
@echo "$(COLOR_GREEN) docker-start $(COLOR_END) Starts docker container"
@echo "$(COLOR_GREEN) docker-stop $(COLOR_END) Stops docker container"
@echo "$(COLOR_GREEN) docker-shell $(COLOR_END) Opens a shell in docker container"
install:
$(PIP) install -r requirements.txt
ifneq ($(SERVER_ENV),"prod")
$(PIP) install -r requirements-dev.txt
endif
lint: lint-autopep8
lint-autopep8:
$(AUTOPEP8) -v --diff --exit-code --recursive dapytains tests
lint-fix: lint-fix-autopep8
lint-fix-autopep8:
$(AUTOPEP8) -v --in-place --recursive dapytains tests
start:
ifeq ($(VERBOSE),1)
$(MAKE) install
else
@$(MAKE) install > /dev/null
endif
$(PYTHON) -m dapytains.app.app
test:
ifeq ($(SERVER_ENV),"prod")
$(error "Tests cannot run in 'prod' environment")
endif
ifeq ($(VERBOSE),1)
$(MAKE) install
else
@$(MAKE) install > /dev/null
endif
$(PYTEST) --doctest-modules --cov=dapytains --verbose
docker-shell: docker-start
$(DOCKER_COMPOSE) exec app zsh
docker-start:
$(DOCKER_COMPOSE) up -d --build --remove-orphans
docker-stop:
$(DOCKER_COMPOSE) down
.env.local:
if [ ! -f .env.local ]; then cat .env > .env.local; fi