Merge lp:~benji/charm-tools/prooflib into lp:charm-tools/1.2

Proposed by Benji York
Status: Merged
Merged at revision: 267
Proposed branch: lp:~benji/charm-tools/prooflib
Merge into: lp:charm-tools/1.2
Diff against target: 401 lines (+187/-26)
18 files modified
.bzrignore (+9/-0)
.lbox (+1/-0)
.lbox.check (+4/-0)
HACKING.txt (+61/-0)
Makefile (+86/-10)
charmtools/__init__.py (+0/-1)
charmtools/bundles.py (+0/-1)
charmtools/charms.py (+0/-1)
charmtools/cli.py (+0/-1)
charmtools/mr.py (+1/-1)
charmtools/promulgate.py (+0/-2)
charmtools/search.py (+0/-3)
charmtools/subscribers.py (+2/-1)
charmtools/tests/test_proof.py (+2/-2)
charmtools/update.py (+1/-1)
requirements.txt (+12/-0)
scripts/test (+7/-0)
setup.py (+1/-2)
To merge this branch: bzr merge lp:~benji/charm-tools/prooflib
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Review via email: mp+197439@code.launchpad.net

Description of the change

Additional project niceties.

https://codereview.appspot.com/36190043/

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :
Download full text (7.2 KiB)

Reviewers: mp+197439_code.launchpad.net,

Message:
Comments for Marco.

https://codereview.appspot.com/36190043/diff/20001/.lbox
File .lbox (right):

https://codereview.appspot.com/36190043/diff/20001/.lbox#newcode1
.lbox:1: propose -cr -for lp:charmtools
Set the default options for "lbox propose".

https://codereview.appspot.com/36190043/diff/20001/.lbox.check
File .lbox.check (right):

https://codereview.appspot.com/36190043/diff/20001/.lbox.check#newcode1
.lbox.check:1: #!/bin/bash
This file is run pre-propose and pre-submit. If it returns an error the
propose/submit is cancelled.

https://codereview.appspot.com/36190043/diff/20001/Makefile
File Makefile (right):

https://codereview.appspot.com/36190043/diff/20001/Makefile#newcode7
Makefile:7: #SHELL = $(warning [$@ ($^) ($?) ])$(OLD_SHELL)
This snippet is incredibly handy when debugging complex Makefile issues,
but for one this small it may not be worth maintaining here.

https://codereview.appspot.com/36190043/diff/20001/Makefile#newcode24
Makefile:24: virtualenv .
Using a virtualenv gives us (some) isolation from the system, enhancing
build reproducibility and reducing spurious errors.

https://codereview.appspot.com/36190043/diff/20001/Makefile#newcode34
Makefile:34: build: deps bin/python bin/pip develop bin/test
This target is the core of the Makefile.

https://codereview.appspot.com/36190043/diff/20001/Makefile#newcode36
Makefile:36: sysdeps:
This installs the (few) system dependencies.

https://codereview.appspot.com/36190043/diff/20001/Makefile#newcode122
Makefile:122: .DEFAULT_GOAL := build
A bare "make" command should build the software.

https://codereview.appspot.com/36190043/diff/20001/charmtools/__init__.py
File charmtools/__init__.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/__init__.py#oldcode19
charmtools/__init__.py:19: import glob
Lint: unused import.

https://codereview.appspot.com/36190043/diff/20001/charmtools/bundles.py
File charmtools/bundles.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/bundles.py#oldcode2
charmtools/bundles.py:2: import sys
More lint.

https://codereview.appspot.com/36190043/diff/20001/charmtools/charms.py
File charmtools/charms.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/charms.py#oldcode2
charmtools/charms.py:2: import sys
Lint.

https://codereview.appspot.com/36190043/diff/20001/charmtools/cli.py
File charmtools/cli.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/cli.py#oldcode4
charmtools/cli.py:4: import argparse
So much lint.

https://codereview.appspot.com/36190043/diff/20001/charmtools/mr.py
File charmtools/mr.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/mr.py#oldcode19
charmtools/mr.py:19: from bzrlib import errors, trace
Lint.

https://codereview.appspot.com/36190043/diff/20001/charmtools/promulgate.py
File charmtools/promulgate.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/promulgate.py#oldcode27
charmtools/promulgate.py:27: import string
Lint.

https://codereview.app...

Read more...

Revision history for this message
Marco Ceppi (marcoceppi) wrote :

These changes look fine, I'm not sure if .lbox is configured properly or
not. Could you review?

https://codereview.appspot.com/36190043/diff/20001/.lbox
File .lbox (right):

https://codereview.appspot.com/36190043/diff/20001/.lbox#newcode1
.lbox:1: propose -cr -for lp:charmtools
On 2013/12/03 14:40:01, benji wrote:
> Set the default options for "lbox propose".

lp:charm-tools

https://codereview.appspot.com/36190043/diff/20001/charmtools/subscribers.py
File charmtools/subscribers.py (left):

https://codereview.appspot.com/36190043/diff/20001/charmtools/subscribers.py#oldcode126
charmtools/subscribers.py:126: charm =
charmdistro.getSourcePackage(name=charm_name)
On 2013/12/03 14:40:01, benji wrote:
> So... the linter complained that "charm" was assigned a value but
never used,
> which is true. Looking at the code I saw that "charm_name" was
appended to the
> list "charms" so I figured s/charm_name/charm/ was the right thing to
do, so I
> did it and ran the tests. None failed. I ran "make check" and some
failed. I
> changed the code back and "make check" still failed. I ran "make
check" on
> lp:charm-tools/1.2 and it failed in the same way there.

> I looked at the other code and despite the list being named "charms",
charm
> names are appended to it below, so I really don't know what to do
here.

> Therefore, just removed the assignment to make the linter happy and
left it for
> you to figure out. :)

Yeah, I didn't write this :) I'll go over it post merge and review what
it's trying to do.

https://codereview.appspot.com/36190043/

Revision history for this message
Benji York (benji) wrote :

Fixed typo.

https://codereview.appspot.com/36190043/diff/20001/.lbox
File .lbox (right):

https://codereview.appspot.com/36190043/diff/20001/.lbox#newcode1
.lbox:1: propose -cr -for lp:charmtools
On 2013/12/03 19:51:14, Marco Ceppi wrote:
> On 2013/12/03 14:40:01, benji wrote:
> > Set the default options for "lbox propose".

> lp:charm-tools

Done.

https://codereview.appspot.com/36190043/

Revision history for this message
Benji York (benji) wrote :
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

https://codereview.appspot.com/36190043/diff/40001/Makefile
File Makefile (right):

https://codereview.appspot.com/36190043/diff/40001/Makefile#newcode42
Makefile:42: bzr checkout lp:~juju-jitsu/charm-tools/dependencies
Can we not have it owned by ~juju-jitsu and instead place it under
~charmers?

https://codereview.appspot.com/36190043/diff/40001/Makefile#newcode47
Makefile:47: $(PYTHON_PACKAGE_CANARY): requirements.txt | bin/pip
dependencies
Why wouldn't we keep requirements.txt for deps? Decoupling them means
they could change between versions of charm-tools and the dependencies
branch. Having the requirements.txt be the source for deps makes more
sense to me. Unless I'm missing the point of this line.

https://codereview.appspot.com/36190043/

Revision history for this message
Benji York (benji) wrote :

Here are my responses to the most recent round of review notes.

https://codereview.appspot.com/36190043/diff/40001/Makefile
File Makefile (right):

https://codereview.appspot.com/36190043/diff/40001/Makefile#newcode42
Makefile:42: bzr checkout lp:~juju-jitsu/charm-tools/dependencies
On 2013/12/05 16:30:50, Marco Ceppi wrote:
> Can we not have it owned by ~juju-jitsu and instead place it under
~charmers?

Sure. Is lp:~charmers/charm-tools/dependencies an acceptable/valid
location?

https://codereview.appspot.com/36190043/diff/40001/Makefile#newcode47
Makefile:47: $(PYTHON_PACKAGE_CANARY): requirements.txt | bin/pip
dependencies
On 2013/12/05 16:30:50, Marco Ceppi wrote:
> Why wouldn't we keep requirements.txt for deps? Decoupling them means
they could
> change between versions of charm-tools and the dependencies branch.
Having the
> requirements.txt be the source for deps makes more sense to me. Unless
I'm
> missing the point of this line.

The requirements.txt file specifies the dependencies. The dependencies
directory exists so all the dependencies are conveniently available in
one place and to make sure the dependencies are available (people have a
bad habit of removing "old" distributions from the web) wile also
removing the need for web access to build the software (building on a
plane or behind an egress-filtering firewall are important use cases).

https://codereview.appspot.com/36190043/

Revision history for this message
Marco Ceppi (marcoceppi) wrote :

On 2013/12/05 16:41:16, benji wrote:
> Here are my responses to the most recent round of review notes.

> https://codereview.appspot.com/36190043/diff/40001/Makefile
> File Makefile (right):

> https://codereview.appspot.com/36190043/diff/40001/Makefile#newcode42
> Makefile:42: bzr checkout lp:~juju-jitsu/charm-tools/dependencies
> On 2013/12/05 16:30:50, Marco Ceppi wrote:
> > Can we not have it owned by ~juju-jitsu and instead place it under
~charmers?

> Sure. Is lp:~charmers/charm-tools/dependencies an acceptable/valid
location?

This is fine, thanks!

> https://codereview.appspot.com/36190043/diff/40001/Makefile#newcode47
> Makefile:47: $(PYTHON_PACKAGE_CANARY): requirements.txt | bin/pip
dependencies
> On 2013/12/05 16:30:50, Marco Ceppi wrote:
> > Why wouldn't we keep requirements.txt for deps? Decoupling them
means they
> could
> > change between versions of charm-tools and the dependencies branch.
Having the
> > requirements.txt be the source for deps makes more sense to me.
Unless I'm
> > missing the point of this line.

> The requirements.txt file specifies the dependencies. The
dependencies
> directory exists so all the dependencies are conveniently available in
one place
> and to make sure the dependencies are available (people have a bad
habit of
> removing "old" distributions from the web) wile also removing the need
for web
> access to build the software (building on a plane or behind an
egress-filtering
> firewall are important use cases).

I appreciate the explanation. So as we add deps/move to other versions
we'd just include those in addition to the older versions? Either way I
approve of this.

LGTM!

https://codereview.appspot.com/36190043/

Revision history for this message
Marco Ceppi (marcoceppi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-04-23 20:46:55 +0000
3+++ .bzrignore 2013-12-04 15:05:03 +0000
4@@ -1,1 +1,10 @@
5 tests/proof/results/*
6+.noseids
7+charm_tools.egg-info
8+dependencies
9+tags
10+bin
11+include
12+lib
13+local
14+man
15
16=== added file '.lbox'
17--- .lbox 1970-01-01 00:00:00 +0000
18+++ .lbox 2013-12-04 15:05:03 +0000
19@@ -0,0 +1,1 @@
20+propose -cr -for lp:charm-tools
21
22=== added file '.lbox.check'
23--- .lbox.check 1970-01-01 00:00:00 +0000
24+++ .lbox.check 2013-12-04 15:05:03 +0000
25@@ -0,0 +1,4 @@
26+#!/bin/bash
27+set -e
28+make lint
29+make test
30
31=== added file 'HACKING.txt'
32--- HACKING.txt 1970-01-01 00:00:00 +0000
33+++ HACKING.txt 2013-12-04 15:05:03 +0000
34@@ -0,0 +1,61 @@
35+=======
36+HACKING
37+=======
38+
39+Herein lay instructions on how to contribute to this project.
40+
41+
42+Developer install
43+=================
44+
45+This codebase requires a few system-wide dependencies be installed. The
46+"sysdeps" make target will install them::
47+
48+ make sysdeps
49+
50+Next the build needs to be run::
51+
52+ make
53+
54+Tests can be run my make or as a script (which allows for command-line options
55+to be passed).
56+
57+::
58+
59+ make test
60+ bin/test
61+
62+
63+Submitting a branch
64+===================
65+
66+In order to submit code for review we use a tool called lbox. If you are using
67+Ubuntu < 13.04 you can install lbox by::
68+
69+ sudo apt-get install lbox
70+
71+If you are using a newer version you will have to build it from source. First
72+step is to install Go lang, you can find the instructions on installing it
73+here http://golang.org/doc/install#bsd_linux , making sure to set your GOROOT
74+environment variable appropriately. After that, you should set up an install
75+directory that you can access, such as $HOME/bin/go which you can set as your
76+GOPATH directory (see `go help gopath` for more information). For ease of
77+use, you can append $GOROOT/bin and $GOPATH/bin to your PATH environment
78+variable. Then follow the instructions::
79+
80+ sudo go get launchpad.net/lbox
81+ sudo go install launchpad.net/lbox
82+
83+To submit for review::
84+
85+ lbox propose
86+
87+After review, to merge into trunk::
88+
89+ lbox submit
90+
91+
92+Filing Bugs
93+===========
94+
95+Please file bugs here: https://bugs.launchpad.net/charm-tools/+filebug
96
97=== modified file 'Makefile'
98--- Makefile 2013-08-27 18:18:35 +0000
99+++ Makefile 2013-12-04 15:05:03 +0000
100@@ -1,3 +1,12 @@
101+# Makefile debugging hack: uncomment the two lines below and make will tell you
102+# more about what is happening. The output generated is of the form
103+# "FILE:LINE [TARGET (DEPENDENCIES) (NEWER)]" where DEPENDENCIES are all the
104+# things TARGET depends on and NEWER are all the files that are newer than
105+# TARGET. DEPENDENCIES will be colored green and NEWER will be blue.
106+#OLD_SHELL := $(SHELL)
107+#SHELL = $(warning [$@ ($^) ($?) ])$(OLD_SHELL)
108+
109+WD := $(shell pwd)
110 DESTDIR =
111 prefix = /usr
112 DDIR = $(DESTDIR)$(prefix)
113@@ -8,7 +17,61 @@
114 confdir = $(DESTDIR)/etc
115 INSTALL = install
116
117-all:
118+bin/pip:
119+ virtualenv .
120+
121+bin/python:
122+ virtualenv .
123+
124+# We use a "canary" file to tell us if the package has been installed in
125+# "develop" mode.
126+DEVELOP_CANARY := lib/__develop_canary
127+develop: $(DEVELOP_CANARY)
128+$(DEVELOP_CANARY): | bin/python
129+ bin/python setup.py develop
130+ touch $(DEVELOP_CANARY)
131+
132+build: deps bin/python bin/pip develop bin/test
133+
134+sysdeps:
135+ sudo apt-get update
136+ sudo apt-get install -y build-essential bzr python-dev \
137+ python-virtualenv
138+
139+dependencies:
140+ bzr checkout lp:~juju-jitsu/charm-tools/dependencies
141+
142+# We use a "canary" file to tell us if the Python packages have been installed.
143+PYTHON_PACKAGE_CANARY := lib/python2.7/site-packages/___canary
144+python-deps: $(PYTHON_PACKAGE_CANARY)
145+$(PYTHON_PACKAGE_CANARY): requirements.txt | bin/pip dependencies
146+ bin/pip install --no-index --no-dependencies --find-links \
147+ file:///$(WD)/dependencies/python -r requirements.txt
148+ touch $(PYTHON_PACKAGE_CANARY)
149+
150+deps: python-deps | dependencies
151+
152+bin/nosetests: python-deps
153+
154+bin/test: | bin/nosetests
155+ ln scripts/test bin/test
156+
157+test: build bin/test
158+ bin/test
159+
160+lint: sources = setup.py charmtools
161+lint: build
162+ @find $(sources) -name '*.py' -print0 | xargs -r0 bin/flake8
163+
164+tags:
165+ ctags --tag-relative --python-kinds=-iv -Rf tags --sort=yes \
166+ --exclude=.bzr --languages=python
167+
168+clean:
169+ find . -name '*.py[co]' -delete
170+ find . -type f -name '*~' -delete
171+ find . -name '*.bak' -delete
172+ rm -rf bin include lib local man
173
174 install:
175 $(INSTALL) -d $(mandir)
176@@ -27,17 +90,30 @@
177 check:
178 tests/helpers/helpers.sh || sh -x tests/helpers/helpers.sh timeout
179 @echo Test shell helpers with dash
180- bash tests/helpers/helpers.sh || bash -x tests/helpers/helpers.sh timeout
181+ bash tests/helpers/helpers.sh \
182+ || bash -x tests/helpers/helpers.sh timeout
183 tests/helpers/helpers.bash || sh -x tests/helpers/helpers.bash timeout
184 @echo Test shell helpers with bash
185- bash tests/helpers/helpers.bash || bash -x tests/helpers/helpers.bash timeout
186+ bash tests/helpers/helpers.bash \
187+ || bash -x tests/helpers/helpers.bash timeout
188 @echo Test charm proof
189 tests/proof/test.sh
190 tests/create/test.sh
191- PYTHONPATH=helpers/python python helpers/python/charmhelpers/tests/test_charmhelpers.py
192-# @echo PEP8 Lint of Python files
193-# @echo `grep -rl '^#!/.*python' .` | xargs -r -n1 pep8
194-
195-clean:
196- find . -name '*.pyc' -delete
197- find . -name '*.bak' -delete
198+
199+define phony
200+ build
201+ check
202+ clean
203+ deps
204+ develop
205+ install
206+ lint
207+ python-deps
208+ sysdeps
209+ tags
210+ test
211+endef
212+
213+.PHONY: $(phony)
214+
215+.DEFAULT_GOAL := build
216
217=== modified file 'charmtools/__init__.py'
218--- charmtools/__init__.py 2013-10-31 04:29:33 +0000
219+++ charmtools/__init__.py 2013-12-04 15:05:03 +0000
220@@ -16,7 +16,6 @@
221
222 import os
223 import sys
224-import glob
225
226 import subprocess
227
228
229=== modified file 'charmtools/bundles.py'
230--- charmtools/bundles.py 2013-11-04 20:59:11 +0000
231+++ charmtools/bundles.py 2013-12-04 15:05:03 +0000
232@@ -1,5 +1,4 @@
233 import os
234-import sys
235 import yaml
236 import glob
237 import json
238
239=== modified file 'charmtools/charms.py'
240--- charmtools/charms.py 2013-11-04 20:41:01 +0000
241+++ charmtools/charms.py 2013-12-04 15:05:03 +0000
242@@ -1,5 +1,4 @@
243 import os
244-import sys
245
246 import re
247 import yaml
248
249=== modified file 'charmtools/cli.py'
250--- charmtools/cli.py 2013-11-01 01:53:58 +0000
251+++ charmtools/cli.py 2013-12-04 15:05:03 +0000
252@@ -1,7 +1,6 @@
253 import os
254 import sys
255 import glob
256-import argparse
257
258
259 def parser_defaults(parser):
260
261=== modified file 'charmtools/mr.py'
262--- charmtools/mr.py 2013-10-31 04:13:18 +0000
263+++ charmtools/mr.py 2013-12-04 15:05:03 +0000
264@@ -16,7 +16,7 @@
265 import os
266 import ConfigParser
267
268-from bzrlib import errors, trace
269+from bzrlib import trace
270 from bzrlib.bzrdir import BzrDir
271 from bzrlib.branch import Branch
272 from bzrlib.plugin import load_plugins
273
274=== modified file 'charmtools/promulgate.py'
275--- charmtools/promulgate.py 2013-10-20 18:23:16 +0000
276+++ charmtools/promulgate.py 2013-12-04 15:05:03 +0000
277@@ -24,12 +24,10 @@
278
279 import os
280 import sys
281-import string
282
283 from optparse import OptionParser
284
285 from bzrlib import bzrdir
286-from bzrlib.plugins.launchpad import lp_api
287
288 import yaml
289
290
291=== modified file 'charmtools/search.py'
292--- charmtools/search.py 2013-10-31 04:13:18 +0000
293+++ charmtools/search.py 2013-12-04 15:05:03 +0000
294@@ -14,9 +14,6 @@
295 # You should have received a copy of the GNU General Public License
296 # along with this program. If not, see <http://www.gnu.org/licenses/>.
297
298-import os
299-import sys
300-import re
301 import argparse
302
303 from . import charms
304
305=== modified file 'charmtools/subscribers.py'
306--- charmtools/subscribers.py 2013-10-31 04:13:18 +0000
307+++ charmtools/subscribers.py 2013-12-04 15:05:03 +0000
308@@ -123,7 +123,8 @@
309 charms = []
310 if len(args.charms):
311 for charm_name in args.charms:
312- charm = charmdistro.getSourcePackage(name=charm_name)
313+ # XXX Is this line really neccesary?
314+ charmdistro.getSourcePackage(name=charm_name)
315 charms.append(charm_name)
316 else:
317 branches = charmdistro.getBranchTips()
318
319=== added directory 'charmtools/tests'
320=== renamed file 'tests/proof/test_proof.py' => 'charmtools/tests/test_proof.py'
321--- tests/proof/test_proof.py 2013-10-15 15:07:14 +0000
322+++ charmtools/tests/test_proof.py 2013-12-04 15:05:03 +0000
323@@ -25,7 +25,7 @@
324 proof_path = dirname(dirname(dirname(abspath(__file__))))
325 proof_path = join(proof_path, 'charmtools')
326 sys.path.append(proof_path)
327-from proof import Linter
328+from charmtools.charms import CharmLinter
329
330
331 class TestProof(TestCase):
332@@ -33,7 +33,7 @@
333 def setUp(self):
334 self.charm_dir = mkdtemp()
335 self.config_path = join(self.charm_dir, 'config.yaml')
336- self.linter = Linter()
337+ self.linter = CharmLinter()
338
339 def tearDown(self):
340 rmtree(self.charm_dir)
341
342=== modified file 'charmtools/update.py'
343--- charmtools/update.py 2013-10-31 04:13:18 +0000
344+++ charmtools/update.py 2013-12-04 15:05:03 +0000
345@@ -52,5 +52,5 @@
346 mr.save()
347 except Exception as e:
348 # Got this from http://stackoverflow.com/q/5574702/196832
349- print >> sys.stderr, ".mrconfig not saved: ", e
350+ print >> sys.stderr, ".mrconfig not saved: ", e
351 sys.exit(1)
352
353=== added file 'requirements.txt'
354--- requirements.txt 1970-01-01 00:00:00 +0000
355+++ requirements.txt 2013-12-04 15:05:03 +0000
356@@ -0,0 +1,12 @@
357+PyYAML==3.10
358+launchpadlib==1.10.2
359+nose==1.2.1
360+requests==1.1.0
361+lazr.authentication==0.1.2
362+lazr.restfulclient==0.13.1
363+lazr.uri==1.0.3
364+simplejson==2.2.1
365+wadllib==1.3.1
366+httplib2==0.7.7
367+oauth==1.0.1
368+flake8==1.6.2
369
370=== added directory 'scripts'
371=== added file 'scripts/test'
372--- scripts/test 1970-01-01 00:00:00 +0000
373+++ scripts/test 2013-12-04 15:05:03 +0000
374@@ -0,0 +1,7 @@
375+#!/bin/bash
376+# If the --pdb switch is passed, inject --pdb-failures too.
377+if [[ $* =~ --pdb( .*|$) ]]
378+then
379+ extra_args="--pdb-failures"
380+fi
381+bin/nosetests --exe --with-id $extra_args $@
382
383=== modified file 'setup.py'
384--- setup.py 2013-11-01 03:10:36 +0000
385+++ setup.py 2013-12-04 15:05:03 +0000
386@@ -3,14 +3,13 @@
387 # Copyright 2012 Canonical Ltd. This software is licensed under the
388 # GNU General Public License version 3 (see the file LICENSE).
389
390-import sys
391 import ez_setup
392
393
394 ez_setup.use_setuptools()
395
396 from charmtools.version import __VERSION__
397-from setuptools import setup, find_packages
398+from setuptools import setup
399
400
401 setup(

Subscribers

People subscribed via source and target branches

to all changes: