This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (66 loc) · 1.96 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
##########
# Config #
##########
CYAN ?= \033[0;36m
COFF ?= \033[0m
port ?= 8000
.PHONY: githooks \
init_demo_app run_demo_app \
check fix
.ONESHELL:
.DEFAULT: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf "$(CYAN)%-30s$(COFF) %s\n", $$1, $$2}\n'
###########
# Project #
###########
interpreter := $(shell poetry env info > /dev/null 2>&1 && echo "poetry run")
project_version = $(shell poetry version | cut -d' ' -f2)
check-venv:
$(if $(interpreter),, $(error No virtual environment found, run "make venv"))
githooks: ## Install git hooks
@$(interpreter) pre-commit install -t=pre-commit -t=pre-push
run_demo_app: ## Build local version and run demo_app
@poetry build
@cd demo_app
@$(interpreter) pip install ../dist/django_explorer-$(project_version)-py3-none-any.whl --force-reinstall
@$(interpreter) ./manage.py migrate --noinput
@$(interpreter) ./manage.py runserver $(port)
run_demo_shell: ## Run django-extension's shell_plus for demo_app
@$(interpreter) pip install ./manage.py shell_plus --ipython -- -i -c """from rich import pretty, inspect
pretty.install()
"""
###############
# Code checks #
###############
check: check-venv ## Run linters
@printf "$(CYAN)flake8$(COFF)\n"
@echo "======"
@$(interpreter) flake8 || exit 1
@echo "OK"
@echo;
@printf "$(CYAN)black$(COFF)\n"
@echo "======"
@$(interpreter) black --check . || exit 1
@echo;
@printf "$(CYAN)isort$(COFF)\n"
@echo "======"
@$(interpreter) isort --check-only .
test: check-venv ## Test code with pytest
@printf "$(CYAN)pytest$(COFF)\n"
@echo "========="
@$(interpreter) pytest .
fix: check-venv ## Run code formatters
@printf "$(CYAN)autoflake$(COFF)\n"
@echo "========="
@$(interpreter) autoflake -ri --remove-all-unused-imports --exclude __init__.py,conftest.py .
@echo ;
@printf "$(CYAN)black$(COFF)\n"
@echo "====="
@$(interpreter) black .
@echo;
@printf "$(CYAN)isort$(COFF)\n"
@echo "====="
@$(interpreter) isort .