forked from line/promgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
127 lines (102 loc) · 2.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
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
121
122
123
124
125
126
127
lessopts="--tabs=4 --quit-if-one-screen --RAW-CONTROL-CHARS --no-init"
APP_BIN := .venv/bin/promgen
PIP_BIN := .venv/bin/pip
SPHINX := .venv/bin/sphinx-build
# Help 'function' taken from
# https://gist.github.com/prwhite/8168133#gistcomment-2278355
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20
.PHONY: help
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[\%a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
${PIP_BIN}:
python3 -m venv .venv
${PIP_BIN} install -U pip setuptools
${APP_BIN}: ${PIP_BIN}
${PIP_BIN} install -r docker/requirements.txt
${PIP_BIN} install -e .[dev,mysql]
.PHONY: pip
pip: ${PIP_BIN}
${PIP_BIN} install -r docker/requirements.txt
${PIP_BIN} install -e .[dev,mysql]
.PHONY: build
## Docker: Bulid container
build:
docker-compose build base
.PHONY: demo
## Docker: Run a demo via docker-compose
demo:
docker-compose up
#### Django Commands
.PHONY: test
test: ${APP_BIN}
## Django: Run tests
${APP_BIN} test -v 2
.PHONY: bootstrap
## Django: Bootstrap install
bootstrap: ${APP_BIN}
${APP_BIN} bootstrap
${APP_BIN} migrate
${APP_BIN} check
.PHONY: check
## Django: Run Django checks
check: ${APP_BIN}
${APP_BIN} check
.PHONY: migrate
## Django: Run migrations
migrate: ${APP_BIN}
${APP_BIN} migrate
.PHONY: run
## Django: Run development server
run: migrate
${APP_BIN} runserver
.PHONY: shell
## Django: Development shell
shell: ${APP_BIN}
@echo opening promgen shell
@${APP_BIN} shell
dump: ${APP_BIN}
${APP_BIN} dumpdata promgen.DefaultExporter --indent=2 --output promgen/fixtures/exporters.yaml --format=yaml
.PHONY: load
load: ${APP_BIN}
${APP_BIN} loaddata exporters
#### Documentation
${SPHINX}: ${PIP_BIN}
${PIP_BIN} install -e .[dev,docs]
.PHONY: docs
## Sphinx: Build documentation
docs: ${SPHINX}
${SPHINX} -avb html docs dist/html
#### Other assorted commands
.PHONY: clean
## Clean our repo
clean:
@echo Removing venv
@rm -rf .venv
@echo Clearing dist files
@rm -rf dist
.PHONY: circleci
## Test circleci configuration locally
circleci:
circleci local execute
.PHONY: changelog
changelog:
git log --color=always --first-parent --pretty='format:%s|%Cgreen%d%Creset' | column -ts '|' | less "$(lessopts)"