Merge lp:~cjwatson/launchpad/snap-source-tarball into lp:launchpad
- snap-source-tarball
- Merge into devel
Proposed by
Colin Watson
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 18623 | ||||
Proposed branch: | lp:~cjwatson/launchpad/snap-source-tarball | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
388 lines (+91/-9) 11 files modified
lib/lp/snappy/browser/snap.py (+4/-0) lib/lp/snappy/browser/tests/test_snap.py (+27/-0) lib/lp/snappy/interfaces/snap.py (+7/-0) lib/lp/snappy/model/snap.py (+10/-4) lib/lp/snappy/model/snapbuildbehaviour.py (+1/-0) lib/lp/snappy/templates/snap-edit.pt (+4/-0) lib/lp/snappy/templates/snap-index.pt (+9/-0) lib/lp/snappy/templates/snap-new.pt (+3/-0) lib/lp/snappy/tests/test_snap.py (+4/-0) lib/lp/snappy/tests/test_snapbuildbehaviour.py (+14/-0) lib/lp/testing/factory.py (+8/-5) |
||||
To merge this branch: | bzr merge lp:~cjwatson/launchpad/snap-source-tarball | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+343727@code.launchpad.net |
Commit message
Add an option to build source tarballs for snaps.
Description of the change
See https:/
Landing https:/
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/snappy/browser/snap.py' |
2 | --- lib/lp/snappy/browser/snap.py 2018-04-04 13:28:28 +0000 |
3 | +++ lib/lp/snappy/browser/snap.py 2018-04-21 10:15:59 +0000 |
4 | @@ -320,6 +320,7 @@ |
5 | 'private', |
6 | 'require_virtualized', |
7 | 'allow_internet', |
8 | + 'build_source_tarball', |
9 | 'auto_build', |
10 | 'store_upload', |
11 | ]) |
12 | @@ -374,6 +375,7 @@ |
13 | 'owner', |
14 | 'name', |
15 | 'store_distro_series', |
16 | + 'build_source_tarball', |
17 | 'auto_build', |
18 | 'auto_build_archive', |
19 | 'auto_build_pocket', |
20 | @@ -511,6 +513,7 @@ |
21 | auto_build_archive=data['auto_build_archive'], |
22 | auto_build_pocket=data['auto_build_pocket'], |
23 | processors=data['processors'], private=private, |
24 | + build_source_tarball=data['build_source_tarball'], |
25 | store_upload=data['store_upload'], |
26 | store_series=data['store_distro_series'].snappy_series, |
27 | store_name=data['store_name'], |
28 | @@ -681,6 +684,7 @@ |
29 | 'vcs', |
30 | 'branch', |
31 | 'git_ref', |
32 | + 'build_source_tarball', |
33 | 'auto_build', |
34 | 'auto_build_archive', |
35 | 'auto_build_pocket', |
36 | |
37 | === modified file 'lib/lp/snappy/browser/tests/test_snap.py' |
38 | --- lib/lp/snappy/browser/tests/test_snap.py 2018-04-04 14:14:30 +0000 |
39 | +++ lib/lp/snappy/browser/tests/test_snap.py 2018-04-21 10:15:59 +0000 |
40 | @@ -243,6 +243,9 @@ |
41 | "Source:\n%s\nEdit snap package" % source_display, |
42 | MatchesTagText(content, "source")) |
43 | self.assertThat( |
44 | + "Build source tarball:\nNo\nEdit snap package", |
45 | + MatchesTagText(content, "build_source_tarball")) |
46 | + self.assertThat( |
47 | "Build schedule:\n(?)\nBuilt on request\nEdit snap package\n", |
48 | MatchesTagText(content, "auto_build")) |
49 | self.assertThat( |
50 | @@ -277,6 +280,9 @@ |
51 | "Source:\n%s\nEdit snap package" % source_display, |
52 | MatchesTagText(content, "source")) |
53 | self.assertThat( |
54 | + "Build source tarball:\nNo\nEdit snap package", |
55 | + MatchesTagText(content, "build_source_tarball")) |
56 | + self.assertThat( |
57 | "Build schedule:\n(?)\nBuilt on request\nEdit snap package\n", |
58 | MatchesTagText(content, "auto_build")) |
59 | self.assertThat( |
60 | @@ -355,6 +361,20 @@ |
61 | extract_text(find_tag_by_id(browser.contents, "privacy")) |
62 | ) |
63 | |
64 | + def test_create_new_snap_build_source_tarball(self): |
65 | + # We can create a new snap and ask for it to build a source tarball. |
66 | + branch = self.factory.makeAnyBranch() |
67 | + browser = self.getViewBrowser( |
68 | + branch, view_name="+new-snap", user=self.person) |
69 | + browser.getControl(name="field.name").value = "snap-name" |
70 | + browser.getControl("Build source tarball").selected = True |
71 | + browser.getControl("Create snap package").click() |
72 | + |
73 | + content = find_main_content(browser.contents) |
74 | + self.assertThat( |
75 | + "Build source tarball:\nYes\nEdit snap package", |
76 | + MatchesTagText(content, "build_source_tarball")) |
77 | + |
78 | def test_create_new_snap_auto_build(self): |
79 | # Creating a new snap and asking for it to be automatically built |
80 | # sets all the appropriate fields. |
81 | @@ -686,6 +706,7 @@ |
82 | browser.getControl("Git repository").value = ( |
83 | new_git_ref.repository.identity) |
84 | browser.getControl("Git branch").value = new_git_ref.path |
85 | + browser.getControl("Build source tarball").selected = True |
86 | browser.getControl( |
87 | "Automatically build when branch changes").selected = True |
88 | browser.getControl("PPA").click() |
89 | @@ -705,6 +726,9 @@ |
90 | "Source:\n%s\nEdit snap package" % new_git_ref.display_name, |
91 | MatchesTagText(content, "source")) |
92 | self.assertThat( |
93 | + "Build source tarball:\nYes\nEdit snap package", |
94 | + MatchesTagText(content, "build_source_tarball")) |
95 | + self.assertThat( |
96 | "Build schedule:\n(?)\nBuilt automatically\nEdit snap package\n", |
97 | MatchesTagText(content, "auto_build")) |
98 | self.assertThat( |
99 | @@ -1223,6 +1247,7 @@ |
100 | Owner: Test Person |
101 | Distribution series: Ubuntu Shiny |
102 | Source: lp://dev/~test-person/\\+junk/snap-branch |
103 | + Build source tarball: No |
104 | Build schedule: \(\?\) |
105 | Built on request |
106 | Source archive for automatic builds: |
107 | @@ -1250,6 +1275,7 @@ |
108 | Owner: Test Person |
109 | Distribution series: Ubuntu Shiny |
110 | Source: ~test-person/\\+git/snap-repository:master |
111 | + Build source tarball: No |
112 | Build schedule: \(\?\) |
113 | Built on request |
114 | Source archive for automatic builds: |
115 | @@ -1277,6 +1303,7 @@ |
116 | Owner: Test Person |
117 | Distribution series: Ubuntu Shiny |
118 | Source: https://git.example.org/foo master |
119 | + Build source tarball: No |
120 | Build schedule: \(\?\) |
121 | Built on request |
122 | Source archive for automatic builds: |
123 | |
124 | === modified file 'lib/lp/snappy/interfaces/snap.py' |
125 | --- lib/lp/snappy/interfaces/snap.py 2018-04-15 16:23:14 +0000 |
126 | +++ lib/lp/snappy/interfaces/snap.py 2018-04-21 10:15:59 +0000 |
127 | @@ -498,6 +498,13 @@ |
128 | "The Git branch containing a snap/snapcraft.yaml, snapcraft.yaml, " |
129 | "or .snapcraft.yaml recipe at the top level."))) |
130 | |
131 | + build_source_tarball = exported(Bool( |
132 | + title=_("Build source tarball"), |
133 | + required=True, readonly=False, |
134 | + description=_( |
135 | + "Whether builds of this snap package should also build a tarball " |
136 | + "containing all source code, including external dependencies."))) |
137 | + |
138 | auto_build = exported(Bool( |
139 | title=_("Automatically build when branch changes"), |
140 | required=True, readonly=False, |
141 | |
142 | === modified file 'lib/lp/snappy/model/snap.py' |
143 | --- lib/lp/snappy/model/snap.py 2018-04-04 14:14:30 +0000 |
144 | +++ lib/lp/snappy/model/snap.py 2018-04-21 10:15:59 +0000 |
145 | @@ -200,6 +200,8 @@ |
146 | |
147 | allow_internet = Bool(name='allow_internet', allow_none=False) |
148 | |
149 | + build_source_tarball = Bool(name='build_source_tarball', allow_none=False) |
150 | + |
151 | store_upload = Bool(name='store_upload', allow_none=False) |
152 | |
153 | store_series_id = Int(name='store_series', allow_none=True) |
154 | @@ -216,8 +218,9 @@ |
155 | auto_build_archive=None, auto_build_pocket=None, |
156 | auto_build_channels=None, require_virtualized=True, |
157 | date_created=DEFAULT, private=False, allow_internet=True, |
158 | - store_upload=False, store_series=None, store_name=None, |
159 | - store_secrets=None, store_channels=None): |
160 | + build_source_tarball=False, store_upload=False, |
161 | + store_series=None, store_name=None, store_secrets=None, |
162 | + store_channels=None): |
163 | """Construct a `Snap`.""" |
164 | super(Snap, self).__init__() |
165 | self.registrant = registrant |
166 | @@ -236,6 +239,7 @@ |
167 | self.date_last_modified = date_created |
168 | self.private = private |
169 | self.allow_internet = allow_internet |
170 | + self.build_source_tarball = build_source_tarball |
171 | self.store_upload = store_upload |
172 | self.store_series = store_series |
173 | self.store_name = store_name |
174 | @@ -672,8 +676,9 @@ |
175 | auto_build_archive=None, auto_build_pocket=None, |
176 | auto_build_channels=None, require_virtualized=True, |
177 | processors=None, date_created=DEFAULT, private=False, |
178 | - allow_internet=True, store_upload=False, store_series=None, |
179 | - store_name=None, store_secrets=None, store_channels=None): |
180 | + allow_internet=True, build_source_tarball=False, |
181 | + store_upload=False, store_series=None, store_name=None, |
182 | + store_secrets=None, store_channels=None): |
183 | """See `ISnapSet`.""" |
184 | if not registrant.inTeam(owner): |
185 | if owner.is_team: |
186 | @@ -717,6 +722,7 @@ |
187 | auto_build_channels=auto_build_channels, |
188 | require_virtualized=require_virtualized, date_created=date_created, |
189 | private=private, allow_internet=allow_internet, |
190 | + build_source_tarball=build_source_tarball, |
191 | store_upload=store_upload, store_series=store_series, |
192 | store_name=store_name, store_secrets=store_secrets, |
193 | store_channels=store_channels) |
194 | |
195 | === modified file 'lib/lp/snappy/model/snapbuildbehaviour.py' |
196 | --- lib/lp/snappy/model/snapbuildbehaviour.py 2018-04-04 14:14:30 +0000 |
197 | +++ lib/lp/snappy/model/snapbuildbehaviour.py 2018-04-21 10:15:59 +0000 |
198 | @@ -132,6 +132,7 @@ |
199 | raise CannotBuild( |
200 | "Source branch/repository for ~%s/%s has been deleted." % |
201 | (build.snap.owner.name, build.snap.name)) |
202 | + args["build_source_tarball"] = build.snap.build_source_tarball |
203 | defer.returnValue(args) |
204 | |
205 | @defer.inlineCallbacks |
206 | |
207 | === modified file 'lib/lp/snappy/templates/snap-edit.pt' |
208 | --- lib/lp/snappy/templates/snap-edit.pt 2017-03-27 19:28:36 +0000 |
209 | +++ lib/lp/snappy/templates/snap-edit.pt 2018-04-21 10:15:59 +0000 |
210 | @@ -60,6 +60,10 @@ |
211 | </td> |
212 | </tr> |
213 | |
214 | + <tal:widget define="widget nocall:view/widgets/build_source_tarball"> |
215 | + <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
216 | + </tal:widget> |
217 | + |
218 | <tal:widget define="widget nocall:view/widgets/auto_build"> |
219 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
220 | </tal:widget> |
221 | |
222 | === modified file 'lib/lp/snappy/templates/snap-index.pt' |
223 | --- lib/lp/snappy/templates/snap-index.pt 2017-01-04 20:52:12 +0000 |
224 | +++ lib/lp/snappy/templates/snap-index.pt 2018-04-21 10:15:59 +0000 |
225 | @@ -61,6 +61,15 @@ |
226 | <a tal:replace="structure view/menu:overview/edit/fmt:icon"/> |
227 | </dd> |
228 | </dl> |
229 | + <dl id="build_source_tarball" |
230 | + tal:define="build_source_tarball context/build_source_tarball"> |
231 | + <dt>Build source tarball:</dt> |
232 | + <dd> |
233 | + <span tal:condition="build_source_tarball">Yes</span> |
234 | + <span tal:condition="not: build_source_tarball">No</span> |
235 | + <a tal:replace="structure view/menu:overview/edit/fmt:icon"/> |
236 | + </dd> |
237 | + </dl> |
238 | |
239 | <dl id="auto_build"> |
240 | <dt>Build schedule: |
241 | |
242 | === modified file 'lib/lp/snappy/templates/snap-new.pt' |
243 | --- lib/lp/snappy/templates/snap-new.pt 2017-03-27 19:28:36 +0000 |
244 | +++ lib/lp/snappy/templates/snap-new.pt 2018-04-21 10:15:59 +0000 |
245 | @@ -35,6 +35,9 @@ |
246 | <tal:widget define="widget nocall:view/widgets/processors"> |
247 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
248 | </tal:widget> |
249 | + <tal:widget define="widget nocall:view/widgets/build_source_tarball"> |
250 | + <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
251 | + </tal:widget> |
252 | |
253 | <tal:widget define="widget nocall:view/widgets/auto_build"> |
254 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
255 | |
256 | === modified file 'lib/lp/snappy/tests/test_snap.py' |
257 | --- lib/lp/snappy/tests/test_snap.py 2018-04-15 16:23:14 +0000 |
258 | +++ lib/lp/snappy/tests/test_snap.py 2018-04-21 10:15:59 +0000 |
259 | @@ -654,6 +654,7 @@ |
260 | self.assertTrue(snap.require_virtualized) |
261 | self.assertFalse(snap.private) |
262 | self.assertTrue(snap.allow_internet) |
263 | + self.assertFalse(snap.build_source_tarball) |
264 | |
265 | def test_creation_git(self): |
266 | # The metadata entries supplied when a Snap is created for a Git |
267 | @@ -676,6 +677,7 @@ |
268 | self.assertTrue(snap.require_virtualized) |
269 | self.assertFalse(snap.private) |
270 | self.assertTrue(snap.allow_internet) |
271 | + self.assertFalse(snap.build_source_tarball) |
272 | |
273 | def test_creation_git_url(self): |
274 | # A Snap can be backed directly by a URL for an external Git |
275 | @@ -1381,6 +1383,7 @@ |
276 | self.assertIsNone(snap["git_ref_link"]) |
277 | self.assertTrue(snap["require_virtualized"]) |
278 | self.assertTrue(snap["allow_internet"]) |
279 | + self.assertFalse(snap["build_source_tarball"]) |
280 | |
281 | def test_new_git(self): |
282 | # Ensure Snap creation based on a Git branch works. |
283 | @@ -1402,6 +1405,7 @@ |
284 | self.assertEqual(self.getURL(ref), snap["git_ref_link"]) |
285 | self.assertTrue(snap["require_virtualized"]) |
286 | self.assertTrue(snap["allow_internet"]) |
287 | + self.assertFalse(snap["build_source_tarball"]) |
288 | |
289 | def test_new_private(self): |
290 | # Ensure private Snap creation works. |
291 | |
292 | === modified file 'lib/lp/snappy/tests/test_snapbuildbehaviour.py' |
293 | --- lib/lp/snappy/tests/test_snapbuildbehaviour.py 2018-04-04 14:14:30 +0000 |
294 | +++ lib/lp/snappy/tests/test_snapbuildbehaviour.py 2018-04-21 10:15:59 +0000 |
295 | @@ -278,6 +278,7 @@ |
296 | "archives": expected_archives, |
297 | "arch_tag": "i386", |
298 | "branch": branch.bzr_identity, |
299 | + "build_source_tarball": False, |
300 | "build_url": canonical_url(job.build), |
301 | "name": "test-snap", |
302 | "proxy_url": self.proxy_url, |
303 | @@ -300,6 +301,7 @@ |
304 | "archive_private": False, |
305 | "archives": expected_archives, |
306 | "arch_tag": "i386", |
307 | + "build_source_tarball": False, |
308 | "build_url": canonical_url(job.build), |
309 | "git_repository": ref.repository.git_https_url, |
310 | "git_path": ref.name, |
311 | @@ -325,6 +327,7 @@ |
312 | "archive_private": False, |
313 | "archives": expected_archives, |
314 | "arch_tag": "i386", |
315 | + "build_source_tarball": False, |
316 | "build_url": canonical_url(job.build), |
317 | "git_repository": ref.repository.git_https_url, |
318 | "name": "test-snap", |
319 | @@ -350,6 +353,7 @@ |
320 | "archive_private": False, |
321 | "archives": expected_archives, |
322 | "arch_tag": "i386", |
323 | + "build_source_tarball": False, |
324 | "build_url": canonical_url(job.build), |
325 | "git_repository": url, |
326 | "git_path": "master", |
327 | @@ -375,6 +379,7 @@ |
328 | "archive_private": False, |
329 | "archives": expected_archives, |
330 | "arch_tag": "i386", |
331 | + "build_source_tarball": False, |
332 | "build_url": canonical_url(job.build), |
333 | "git_repository": url, |
334 | "name": "test-snap", |
335 | @@ -414,6 +419,7 @@ |
336 | self.assertFalse(isProxy(args["channels"])) |
337 | self.assertEqual({"snapcraft": "edge"}, args["channels"]) |
338 | |
339 | + @defer.inlineCallbacks |
340 | def test_extraBuildArgs_disallow_internet(self): |
341 | # If external network access is not allowed for the snap, |
342 | # _extraBuildArgs does not dispatch a proxy token. |
343 | @@ -423,6 +429,14 @@ |
344 | self.assertNotIn("revocation_endpoint", args) |
345 | |
346 | @defer.inlineCallbacks |
347 | + def test_extraBuildArgs_build_source_tarball(self): |
348 | + # If the snap requests building of a source tarball, _extraBuildArgs |
349 | + # sends the appropriate arguments. |
350 | + job = self.makeJob(build_source_tarball=True) |
351 | + args = yield job._extraBuildArgs() |
352 | + self.assertTrue(args["build_source_tarball"]) |
353 | + |
354 | + @defer.inlineCallbacks |
355 | def test_composeBuildRequest_proxy_url_set(self): |
356 | job = self.makeJob() |
357 | build_request = yield job.composeBuildRequest(None) |
358 | |
359 | === modified file 'lib/lp/testing/factory.py' |
360 | --- lib/lp/testing/factory.py 2018-04-04 14:14:30 +0000 |
361 | +++ lib/lp/testing/factory.py 2018-04-21 10:15:59 +0000 |
362 | @@ -4673,8 +4673,9 @@ |
363 | auto_build_channels=None, is_stale=None, |
364 | require_virtualized=True, processors=None, |
365 | date_created=DEFAULT, private=False, allow_internet=True, |
366 | - store_upload=False, store_series=None, store_name=None, |
367 | - store_secrets=None, store_channels=None): |
368 | + build_source_tarball=False, store_upload=False, |
369 | + store_series=None, store_name=None, store_secrets=None, |
370 | + store_channels=None): |
371 | """Make a new Snap.""" |
372 | if registrant is None: |
373 | registrant = self.makePerson() |
374 | @@ -4699,9 +4700,11 @@ |
375 | auto_build=auto_build, auto_build_archive=auto_build_archive, |
376 | auto_build_pocket=auto_build_pocket, |
377 | auto_build_channels=auto_build_channels, private=private, |
378 | - allow_internet=allow_internet, store_upload=store_upload, |
379 | - store_series=store_series, store_name=store_name, |
380 | - store_secrets=store_secrets, store_channels=store_channels) |
381 | + allow_internet=allow_internet, |
382 | + build_source_tarball=build_source_tarball, |
383 | + store_upload=store_upload, store_series=store_series, |
384 | + store_name=store_name, store_secrets=store_secrets, |
385 | + store_channels=store_channels) |
386 | if is_stale is not None: |
387 | removeSecurityProxy(snap).is_stale = is_stale |
388 | IStore(snap).flush() |