-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
174 lines (113 loc) · 3.67 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
MANAGE_PY = python -Wall manage.py
ROOT_DIR = axpay
DOC_DIR = docs
SERVICES = core www
MANAGE_OPTIONS = --traceback
RUN_OPTIONS = --traceback
# In order to help newcomers, this variable holds a full doc of the current Makefile.
# Please keep it up to date with regard to new commands.
#
# Structure:
# - Group commands in sections
# - Align command descriptions
define helpmsg
Makefile command help
The following commands are available.
- Running:
run_www: Start a development server for the site on http://127.0.0.1:8000/
shell: Open a development Python shell using the current database
- Preparation & compilation:
makemessages: Update all .po files
compilemessages: Rebuild .mo files
static: Collect static files
prepare: Perform all required preparation steps (collectstatic, po->mo, etc.)
- Database:
resetdb: Reinitialize the database schema
demodb: Reinitialize the database to a demo-ready setup
- Quality:
test: Run the test suite
pylint: Check the code for coding style errors
- Production:
docker: Build the docker image
rundocker: Run the docker image
- Misc:
clean: Cleanup all temporary files (*.pyc, ...)
doc: Generate the documentation
viewdoc: Open a web browser on the (local) documentation
help: Display this help message
endef
default: help
all: prepare
help:
@echo -n "" # Don't display extra lines.
$(info $(helpmsg))
.PHONY: all default help
# Running
# =======
run_www: static_www compilemessages
AXPAY_SERVICE=www $(MANAGE_PY) runserver $(RUN_OPTIONS) 8000
shell:
$(MANAGE_PY) shell
.PHONY: run_www shell
# Preparation & compilation
# =========================
STATICS = $(addprefix static_,$(SERVICES))
static: $(STATICS)
$(STATICS): static_% :
AXPAY_SERVICE=$* $(MANAGE_PY) collectstatic --noinput $(MANAGE_OPTIONS) --verbosity=0
PO_FILES = $(shell find $(ROOT_DIR) -name '*.po')
makemessages:
cd $(ROOT_DIR) && django-admin.py makemessages --all --no-wrap
MO_FILES = $(PO_FILES:.po=.mo)
compilemessages: $(MO_FILES)
%.mo: %.po
msgfmt --check-format -o $@ $<
prepare: compilemessages static
.PHONY: compilemessages makemesssages prepare static $(STATICS)
# Development
# ===========
TESTS = $(addprefix test_,$(SERVICES))
test: $(TESTS)
@:
$(TESTS): test_% : static_%
AXPAY_SERVICE=$* $(MANAGE_PY) test $(MANAGE_OPTIONS)
pylint:
pylint --rcfile=.pylintrc --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
--reports=no --output-format=colorized $(ROOT_DIR) || true
resetdb:
rm -f db/axpay.sqlite
[ -d db ] || mkdir db
$(MANAGE_PY) migrate --noinput $(MANAGE_OPTIONS)
demodb: resetdb
$(MANAGE_PY) loaddemo $(MANAGE_OPTIONS)
.PHONY: demodb resetdb test $(TESTS)
# Continuous integration
# ======================
JENKINS_TARGETS = $(addprefix jenkins_,$(SERVICES))
jenkins: $(JENKINS_TARGETS)
@:
$(JENKINS_TARGETS): jenkins_% : static_%
@echo "Running tests on $*..."
AXPAY_SERVICE=$* DEV_JENKINS=1 $(MANAGE_PY) test $(MANAGE_OPTIONS)
.PHONY: jenkins $(JENKINS_TARGETS)
# Production
# ==========
docker:
docker build -t rbarrois/axpay .
rundocker:
docker run -p 8080:80 -p 8000:8000 -v $(PWD)/db:/db -e AXPAY_DEV_DEBUG=true -e AXPAY_ENVIRONMENT=dev rbarrois/axpay
rundockershell:
docker run -p 8080:80 -p 8000:8000 -v $(PWD)/db:/db -ti rbarrois/axpay /bin/bash
.PHONY: docker rundocker rundockershell
# Misc
# ====
clean:
find . "(" -name "*.pyc" -or -name "*.pyo" -or -name "*.mo" ")" -delete
find . -type d -empty -delete
rm -rf axpay/static/*
rm -rf reports/
doc:
$(MAKE) -C $(DOC_DIR) html
viewdoc: doc
python -c "import webbrowser; webbrowser.open('$(DOC_DIR)/_build/html/index.html')"
.PHONY: clean doc