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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
WD := $(shell pwd)
PY := bin/python
FLAKE8 := bin/flake8
PIP := bin/pip
CACHE := download-cache/dist
CSS_PATH := charmworld/static/css
LESSC := node_modules/less/bin/lessc
NOSE := INI="test.ini" bin/nosetests
PSERVE := bin/pserve
SYSTEM_DEPS := \
build-essential bzr charm-tools libyaml-dev python-dev python-virtualenv\
subversion npm
# Default ini file to use for all scripted commands. Can be overridden by
# specifying INI=development.ini
INI = charmworld.ini
# INI is the default ini file used for all work. By default we want to copy a
# sample.ini and generate a single charmworld.ini used.
ifeq ($(wildcard custom.ini), )
CONFIG_DEPS = default.ini
else
CONFIG_DEPS = default.ini custom.ini
endif
$(INI): $(CONFIG_DEPS)
scripts/config $(INI) $(CONFIG_DEPS)
test.ini: default.ini test-setup.ini
scripts/config test.ini default.ini test-setup.ini
# ###############
# INSTALL targets
# ###############
install: charmworld.egg-info
venv: bin/python
bin/python:
virtualenv .
# Made PHONY so that setup.py develop is rerun to include new entry point for
# mongo sessions.
.PHONY: charmworld.egg-info
charmworld.egg-info: deps bin/python $(INI) charmworld/static/css/theme.css
$(PY) setup.py develop
bin/es-update: $(PY)
$(PY) setup.py develop
es_update:
bin/es-update
clean_venv:
- rm -r bin include lib local
css: charmworld/static/css/theme.css
charmworld/static/css/theme.css: $(LESSC) $(CSS_PATH)/theme.less $(CSS_PATH)/variables.less
./$(LESSC) --compress $(CSS_PATH)/theme.less $(CSS_PATH)/theme.css
sysdeps:
sudo add-apt-repository -y ppa:juju/pkgs
sudo add-apt-repository -y ppa:ce-orange-squad/experimental
sudo apt-get update
sudo apt-get install -y $(SYSTEM_DEPS) mongodb-server elasticsearch-java;
# On quantal need to provide node bin for deps to work.
if test ! -e /usr/bin/node; \
then - sudo ln -s /usr/bin/nodejs /usr/bin/node; \
fi
deploy_sysdeps:
sudo apt-get install -y $(SYSTEM_DEPS) mongodb-clients;
deps: venv
if test -d download-cache; \
then bzr up download-cache; \
else bzr checkout lp:~juju-jitsu/charmworld/download-cache; \
fi
$(PIP) install --no-index --no-dependencies --find-links file:///$(WD)/$(CACHE) -r requirements.txt
npm install download-cache/npm/ycssmin.tar.gz
npm install download-cache/npm/less.tar.gz
- rm -r build
- rm -r share;
# ###################
# Development helpers
# ###################
test: test.ini $(INI) bin/nosetests
$(NOSE) charmworld
testid: test.ini bin/nosetests
# Run specific nose id tests.
# To set up the index you must run `make testid` once to completion to
# setup the index. Then you can run a group of tests like:
# Call with `ID="3 5" make testid`
$(NOSE) -v -s -x --with-id $(ID) charmworld
testdebug: test.ini bin/nosetests
$(NOSE) --with-id --pdb --pdb-failures charmworld
check: clear_ini clean sysdeps install testid
lint: sources = setup.py charmworld
lint:
@find $(sources) -name '*.py' ! -path '*/migrations/*' \
-! -path 'charmworld/teams.py' ! -print0 | xargs -r0 \
bin/flake8 --ignore=E125,E127
# Generate ctags for the code in the project.
tags:
ctags --tag-relative --python-kinds=-iv -Rf tags --sort=yes --exclude=.bzr --languages=python
doc: bin/sphinx-build
bin/sphinx-build docs docs/_build/html
doc-open: doc
xdg-open docs/_build/html/index.html
doc-upload: doc
scp -r docs/_build/html/* people.canonical.com:/home/rharding/public_html/charmworld
run: $(INI) charmworld/static/css/theme.css es_update
$(PSERVE) --reload --monitor-restart $(INI)
start_supervisor:
bin/supervisord -c charmworld/jobs/supervisord.conf
stop_supervisor:
if test -f ./supervisord.pid; \
then cat ./supervisord.pid | xargs kill -HUP; \
else echo "No pidfile for supervisor; is the process running?"; \
fi
start_worker:
bin/supervisorctl -c charmworld/jobs/supervisord.conf start ingest
stop_worker:
bin/supervisorctl -c charmworld/jobs/supervisord.conf stop ingest
worker_status:
bin/supervisorctl -c charmworld/jobs/supervisord.conf status ingest
clean:
find . -type f -name '*.py[co]' -print0 | xargs -r0 $(RM)
find . -type f -name '*~' -print0 | xargs -r0 $(RM)
clear_ini:
- rm -f charmworld.ini
distclean: clean clean_venv
$(RM) tags TAGS .installed.cfg
#
# Phony stuff.
#
define phony_targets
check
css
clean_venv
clean
deploy
deps
distclean
doc
doc-open
es_update
install
lint
run
tags
test
testid
venv
start_supervisord
stop_supervisord
start_worker
stop_worker
worker_status
endef
define phony
$(phony_targets)
endef
phony := $(sort $(strip $(phony)))
.PHONY: $(phony)
|