Merge lp:~benji/juju-gui/npm-cache into lp:juju-gui/experimental

Proposed by Benji York
Status: Merged
Merged at revision: 627
Proposed branch: lp:~benji/juju-gui/npm-cache
Merge into: lp:juju-gui/experimental
Diff against target: 113 lines (+69/-4)
2 files modified
Makefile (+49/-4)
docs/process.rst (+20/-0)
To merge this branch: bzr merge lp:~benji/juju-gui/npm-cache
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+161479@code.launchpad.net

Description of the change

Add a Makefile npm-cache target to upload to LP

There is a parallel charm branch that uses the cache file to speed deploying
of branch builds.

https://codereview.appspot.com/8686048/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

LGTM very cool use of make to push updates to the cache.

https://codereview.appspot.com/8686048/

Revision history for this message
Gary Poster (gary) wrote :

LGTM with responses--changes preferred, but I'm open to counterarguments
instead--to comments.

Thank you! This is cool to have.

Gary

https://codereview.appspot.com/8686048/diff/1/Makefile
File Makefile (right):

https://codereview.appspot.com/8686048/diff/1/Makefile#newcode98
Makefile:98: NPM_CACHE_VERSION=$(shell date +%s)# Seconds since the
epoch.
I would prefer to connect this to the revid, since we have shrinkwrap
now. Is there a reason to prefer the date?

https://codereview.appspot.com/8686048/diff/1/Makefile#newcode553
Makefile:553: $(MAKE) clean-all
We really have to do that even if you specify a different cache location
in an environment variable? Yuck. :-(

https://codereview.appspot.com/8686048/diff/1/Makefile#newcode591
Makefile:591: main-doc npm-cache npm-cache-file npm-cache-file-signature
prep prod \
I wish you had divided things up the way you describe here--or at least
the file and the npm-cache. Would you be willing to add those in? If
not, clean these out.

https://codereview.appspot.com/8686048/

lp:~benji/juju-gui/npm-cache updated
594. By Benji York

review changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2013-04-15 14:54:29 +0000
3+++ Makefile 2013-04-30 14:58:26 +0000
4@@ -95,6 +95,9 @@
5 RELEASE_NAME=juju-gui-$(RELEASE_VERSION)
6 RELEASE_FILE=releases/$(RELEASE_NAME).tgz
7 RELEASE_SIGNATURE=releases/$(RELEASE_NAME).asc
8+NPM_CACHE_VERSION=$(BZR_REVNO)
9+NPM_CACHE_FILE=$(CURDIR)/releases/npm-cache-$(NPM_CACHE_VERSION).tgz
10+NPM_SIGNATURE=$(NPM_CACHE_FILE).asc
11 # Is the branch being released a branch of trunk?
12 ifndef BRANCH_IS_GOOD
13 ifndef IS_TRUNK_BRANCH
14@@ -199,6 +202,8 @@
15 mkdir -p build-shared/juju-ui/assets/images
16 cp app/assets/images/non-sprites/* build-shared/juju-ui/assets/images/
17
18+install-npm-packages: $(NODE_TARGETS)
19+
20 $(NODE_TARGETS): package.json
21 npm install
22 # Keep all targets up to date, not just new/changed ones.
23@@ -531,7 +536,46 @@
24 @echo "Please run this target without the NO_BZR flag defined if you"
25 @echo "wish to upload a release."
26 @echo
27- @echo "See the README for more information"
28+ @echo "See docs/process.rst for more information"
29+ @echo
30+ @false
31+endif
32+
33+$(NPM_SIGNATURE): $(NPM_CACHE_FILE)
34+ gpg --armor --sign --detach-sig $(NPM_CACHE_FILE)
35+
36+npm-cache-file: $(NPM_CACHE_FILE)
37+
38+$(NPM_CACHE_FILE):
39+ # We store the NPM cache file in the "releases" directory. It is kind
40+ # of like a release.
41+ mkdir -p releases
42+ # Remove any old cache or generated cache archives.
43+ rm -f releases/npm-cache-*.tgz*
44+ rm -rf temp-npm-cache
45+ # We have to get rid of all installed NPM packages so they will be
46+ # reinstalled into the (presently) empty cache.
47+ $(MAKE) clean-all
48+ # Install all the NPM packages, overriding the NPM cache.
49+ $(MAKE) npm_config_cache=temp-npm-cache install-npm-packages
50+ (cd temp-npm-cache && tar czvf $(NPM_CACHE_FILE) .)
51+ rm -rf temp-npm-cache
52+
53+npm-cache: $(NPM_CACHE_FILE) $(NPM_SIGNATURE)
54+ifdef BRANCH_IS_GOOD
55+ python2 upload_release.py juju-gui npm-cache $(NPM_CACHE_VERSION) \
56+ $(NPM_CACHE_FILE) $(LAUNCHPAD_API_ROOT)
57+else
58+ @echo "**************************************************************"
59+ @echo "**************** NPM CACHE GENERATION FAILED *****************"
60+ @echo "**************************************************************"
61+ @echo
62+ @echo "To create and upload an NPM cache file to Launchpad you must"
63+ @echo "be in a branch of lp:juju-gui without uncommitted/unpushed"
64+ @echo "changes, or you must override one of the pertinent variable "
65+ @echo "names to force an upload."
66+ @echo
67+ @echo "See docs/process.rst for more information"
68 @echo
69 @false
70 endif
71@@ -550,8 +594,9 @@
72 # targets are alphabetically sorted, they like it that way :-)
73 .PHONY: appcache-force appcache-touch beautify build build-files \
74 build-devel clean clean-all clean-deps clean-docs code-doc debug \
75- devel docs dist gjslint help jshint lint main-doc prep prod recess \
76- server spritegen test test-debug test-prep test-prod undocumented \
77- view-code-doc view-docs view-main-doc yuidoc-lint
78+ devel docs dist gjslint help install-npm-packages jshint lint \
79+ main-doc npm-cache npm-cache-file prep prod recess server spritegen \
80+ test test-debug test-prep test-prod undocumented view-code-doc \
81+ view-docs view-main-doc yuidoc-lint
82
83 .DEFAULT_GOAL := all
84
85=== modified file 'docs/process.rst'
86--- docs/process.rst 2013-04-10 00:36:48 +0000
87+++ docs/process.rst 2013-04-30 14:58:26 +0000
88@@ -254,6 +254,26 @@
89
90 You are done!
91
92+Making NPM Cache Files
93+======================
94+
95+We use archives of NPM caches to speed up deployment of non-release
96+branches of the Juju GUI via charm. This section describes how to
97+update the cache file stored in Launchpad.
98+
99+Checklist for Uploading a Cache File
100+------------------------------------
101+
102+- Get a clean branch of the trunk:: ``bzr branch lp:juju-gui``.
103+- If you are using a pre-existing branch, make sure it is up-to-date:
104+ ``bzr pull``.
105+- Run the tests and verify they pass: ``make test-prod`` and then
106+ ``make test-debug``.
107+- Create the tarball: ``PROD=1 make npm-cache``. The cache
108+ file (and a signature thereof) will be created and uploaded to
109+ Launchpad. If you wish to upload to staging.launchpad.net instead,
110+ omit "PROD=1".
111+
112 Checklist for Running a Daily Meeting
113 =====================================
114

Subscribers

People subscribed via source and target branches