-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (82 loc) · 2.34 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
PROJECT ?= fibo
HOST ?= horneds
VIRTUAL_ENV ?= env
BUILD_TAG ?= $(shell cat $(CURDIR)/.version)
all: $(VIRTUAL_ENV)
.PHONY: help
# target: help - Display callable targets
help:
@egrep "^# target:" [Mm]akefile
.PHONY: clean
# target: clean - Display callable targets
clean:
@rm -f *.deb *.tar
@rm -rf build/ dist/ docs/_build *.egg-info
@find $(CURDIR) -name "*.py[co]" -delete
@find $(CURDIR) -name "*.orig" -delete
@find $(CURDIR)/$(PROJECT) -name "*.c" -delete
@find $(CURDIR)/$(PROJECT) -name "*.so" -delete
@find $(CURDIR)/$(PROJECT) -name "__pycache__" | xargs rm -rf
# ==============
# Bump version
# ==============
.PHONY: release
RELEASE ?= minor
# target: release - Bump version
release:
@$(VIRTUAL_ENV)/bin/pip install bumpversion
@$(VIRTUAL_ENV)/bin/bumpversion $(RELEASE)
@git checkout master
@git merge develop
@git checkout develop
@git push origin develop master
@git push --tags
.PHONY: minor
minor: release
.PHONY: patch
patch:
make release RELEASE=patch
.PHONY: major
major:
make release RELEASE=major
.PHONY: version
version:
@echo Current version: $(shell cat $(CURDIR)/.version)
# ===============
# Build package
# ===============
.PHONY: docker
docker: clean
docker build -t $(HOST)/$(PROJECT):$(BUILD_TAG) $(CURDIR)
docker tag $(HOST)/$(PROJECT):$(BUILD_TAG) $(HOST)/$(PROJECT):latest
RUN =
.PHONY: docker
docker-run:
@docker run --rm -it -p 8000:8000 --name $(PROJECT) $(HOST)/$(PROJECT) $(RUN)
docker-clean:
@docker rm -v $(shell docker ps -a -q -f status=exited) || true
@docker rmi $(shell docker images -f dangling=true -q) || true
# =============
# Development
# =============
$(VIRTUAL_ENV): $(CURDIR)/requirements.txt
@[ -d $(VIRTUAL_ENV) ] || virtualenv --no-site-packages --python=python3 $(VIRTUAL_ENV)
@$(VIRTUAL_ENV)/bin/pip install -r requirements.txt
@touch $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/py.test: $(VIRTUAL_ENV) $(CURDIR)/requirements-tests.txt
@$(VIRTUAL_ENV)/bin/pip install -r requirements-tests.txt
@touch $(VIRTUAL_ENV)/bin/py.test
.PHONY: test
# target: test - Runs tests
test: $(VIRTUAL_ENV)/bin/py.test
@$(VIRTUAL_ENV)/bin/py.test -xs tests.py
.PHONY: t
t: test
MANAGER=$(VIRTUAL_ENV)/bin/muffin $(PROJECT)
CMD = --help
manage: $(VIRTUAL_ENV)
@$(MANAGER) $(CMD)
run: $(VIRTUAL_ENV)
@$(MANAGER) run --bind=:5000 --reload --timeout=300
shell: $(VIRTUAL_ENV)
@$(MANAGER) shell --ipython