-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (75 loc) · 2.5 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
# ENV defaults to local (so that requirements/local.txt are installed), but can be overridden
# (e.g. ENV=production make setup).
ENV ?= local
# PYTHON specifies the python binary to use when creating virtualenv
PYTHON ?= python3.12
# Editor can be defined globally but defaults to nano
EDITOR ?= nano
# By default we open the editor after copying settings, but can be overridden
# (e.g. EDIT_SETTINGS=no make settings).
EDIT_SETTINGS ?= yes
# Get root dir and project dir
PROJECT_ROOT ?= $(PWD)
SITE_ROOT ?= $(PROJECT_ROOT)
BLACK ?= \033[0;30m
RED ?= \033[0;31m
GREEN ?= \033[0;32m
YELLOW ?= \033[0;33m
BLUE ?= \033[0;34m
PURPLE ?= \033[0;35m
CYAN ?= \033[0;36m
GRAY ?= \033[0;37m
COFF ?= \033[0m
.PHONY: all help setup pycharm coverage test clean
.PHONY: isort isort-fix quality flake8
all: help
help:
@echo "+------<<<< Configuration >>>>------+"
@echo ""
@echo "ENV: $(ENV)"
@echo "PYTHON: $(PYTHON)"
@echo "PROJECT_ROOT: $(PROJECT_ROOT)"
@echo "SITE_ROOT: $(SITE_ROOT)"
@echo ""
@echo "+------<<<< Tasks >>>>------+"
@echo ""
@echo "$(CYAN)make pycharm$(COFF) - Copies default PyCharm settings (unless they already exist)"
@echo ""
@echo "$(CYAN)make test$(COFF) - Runs automatic tests on your python code"
@echo ""
@echo "$(CYAN)make coverage$(COFF) - Runs code test coverage calculation"
@echo ""
@echo "$(CYAN)make quality$(COFF) - Runs automatic code quality tests on your code"
@echo ""
pycharm: $(PROJECT_ROOT)/.idea
$(PROJECT_ROOT)/.idea:
@echo "$(CYAN)Creating pycharm settings from template$(COFF)"
@mkdir -p $(PROJECT_ROOT)/.idea && cp -R $(PROJECT_ROOT)/.idea_template/* $(PROJECT_ROOT)/.idea/
settings: $(PROJECT_ROOT)/.env
coverage:
@echo "$(CYAN)Running automatic code coverage check$(COFF)"
@coverage run -m py.test
@coverage html
@coverage report
pre-commit:
@echo "$(CYAN)Running pre-commit routine$(COFF)"
pipenv run pre-commit run --all-files
make flake8
test: clean
@echo "$(CYAN)Running automatic tests$(COFF)"
@py.test --disable-warnings
clean:
@echo "$(CYAN)Cleaning pyc files$(COFF)"
@cd $(SITE_ROOT) && find . -name "*.pyc" -exec rm -rf {} \;
isort:
@echo "$(CYAN)Checking imports with isort$(COFF)"
isort --recursive --check-only -p . --diff
isort-fix:
@echo "$(CYAN)Fixing imports with isort$(COFF)"
isort --recursive -p .
quality: flake8 isort
flake8:
@echo "$(CYAN)Running flake8$(COFF)"
@flake8
docker-django:
$(cmd)