Merge lp:~cjwatson/launchpad/snap-core18 into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18980
Proposed branch: lp:~cjwatson/launchpad/snap-core18
Merge into: lp:launchpad
Diff against target: 243 lines (+40/-20)
7 files modified
lib/lp/snappy/browser/tests/test_snap.py (+4/-1)
lib/lp/snappy/browser/widgets/snapbuildchannels.py (+5/-4)
lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt (+4/-0)
lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py (+15/-3)
lib/lp/snappy/interfaces/snap.py (+6/-6)
lib/lp/snappy/interfaces/snapbuild.py (+3/-3)
lib/lp/snappy/interfaces/snapjob.py (+3/-3)
To merge this branch: bzr merge lp:~cjwatson/launchpad/snap-core18
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+367800@code.launchpad.net

Commit message

Allow selecting the core18 channel for snap builds.

Description of the change

This relies on https://code.launchpad.net/~cjwatson/launchpad-buildd/better-snap-channel-handling/+merge/362859 (merged a while back) and https://code.launchpad.net/~cjwatson/launchpad-buildd/better-snap-channel-handling-2/+merge/367794.

Unlike in launchpad-buildd, I didn't bother adding core16 here because I'm not entirely sure of its current usefulness and so don't want to make users have to think about it, but it can be added later if need be; core18 is clearly useful now.

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/tests/test_snap.py'
2--- lib/lp/snappy/browser/tests/test_snap.py 2019-05-16 10:21:14 +0000
3+++ lib/lp/snappy/browser/tests/test_snap.py 2019-05-22 19:56:26 +0000
4@@ -428,6 +428,8 @@
5 browser.getControl(
6 name="field.auto_build_channels.core").value = "stable"
7 browser.getControl(
8+ name="field.auto_build_channels.core18").value = "beta"
9+ browser.getControl(
10 name="field.auto_build_channels.snapcraft").value = "edge"
11 browser.getControl("Create snap package").click()
12
13@@ -444,7 +446,7 @@
14 MatchesTagText(content, "auto_build_pocket"))
15 self.assertThat(
16 "Source snap channels for automatic builds:\nEdit snap package\n"
17- "core\nstable\nsnapcraft\nedge\n",
18+ "core\nstable\ncore18\nbeta\nsnapcraft\nedge\n",
19 MatchesTagText(content, "auto_build_channels"))
20
21 @responses.activate
22@@ -1670,6 +1672,7 @@
23 when building the snap package.
24 Source snap channels:
25 core
26+ core18
27 snapcraft
28 The channels to use for build tools when building the snap
29 package.
30
31=== modified file 'lib/lp/snappy/browser/widgets/snapbuildchannels.py'
32--- lib/lp/snappy/browser/widgets/snapbuildchannels.py 2018-08-30 16:15:20 +0000
33+++ lib/lp/snappy/browser/widgets/snapbuildchannels.py 2019-05-22 19:56:26 +0000
34@@ -1,4 +1,4 @@
35-# Copyright 2018 Canonical Ltd. This software is licensed under the
36+# Copyright 2018-2019 Canonical Ltd. This software is licensed under the
37 # GNU Affero General Public License version 3 (see the file LICENSE).
38
39 """A widget for selecting source snap channels for builds."""
40@@ -36,7 +36,7 @@
41
42 template = ViewPageTemplateFile("templates/snapbuildchannels.pt")
43 hint = False
44- snap_names = ["core", "snapcraft"]
45+ snap_names = ["core", "core18", "snapcraft"]
46 _widgets_set_up = False
47
48 def __init__(self, context, request):
49@@ -77,8 +77,9 @@
50 self.setUpSubWidgets()
51 if not zope_isinstance(value, dict):
52 value = {}
53- self.core_widget.setRenderedValue(value.get("core"))
54- self.snapcraft_widget.setRenderedValue(value.get("snapcraft"))
55+ for snap_name in self.snap_names:
56+ getattr(self, "%s_widget" % snap_name).setRenderedValue(
57+ value.get(snap_name))
58
59 def hasInput(self):
60 """See `IInputWidget`."""
61
62=== modified file 'lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt'
63--- lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt 2018-04-30 16:48:47 +0000
64+++ lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt 2019-05-22 19:56:26 +0000
65@@ -8,6 +8,10 @@
66 <td><div tal:content="structure view/core_widget" /></td>
67 </tr>
68 <tr>
69+ <td>core18</td>
70+ <td><div tal:content="structure view/core18_widget" /></td>
71+ </tr>
72+ <tr>
73 <td>snapcraft</td>
74 <td><div tal:content="structure view/snapcraft_widget" /></td>
75 </tr>
76
77=== modified file 'lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py'
78--- lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py 2018-04-30 19:02:40 +0000
79+++ lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py 2019-05-22 19:56:26 +0000
80@@ -1,4 +1,4 @@
81-# Copyright 2018 Canonical Ltd. This software is licensed under the
82+# Copyright 2018-2019 Canonical Ltd. This software is licensed under the
83 # GNU Affero General Public License version 3 (see the file LICENSE).
84
85 from __future__ import absolute_import, print_function, unicode_literals
86@@ -89,6 +89,7 @@
87 self.widget.setUpSubWidgets()
88 self.assertTrue(self.widget._widgets_set_up)
89 self.assertIsNotNone(getattr(self.widget, "core_widget", None))
90+ self.assertIsNotNone(getattr(self.widget, "core18_widget", None))
91 self.assertIsNotNone(getattr(self.widget, "snapcraft_widget", None))
92
93 def test_setUpSubWidgets_second_call(self):
94@@ -97,29 +98,34 @@
95 self.widget._widgets_set_up = True
96 self.widget.setUpSubWidgets()
97 self.assertIsNone(getattr(self.widget, "core_widget", None))
98+ self.assertIsNone(getattr(self.widget, "core18_widget", None))
99 self.assertIsNone(getattr(self.widget, "snapcraft_widget", None))
100
101 def test_setRenderedValue_None(self):
102 self.widget.setRenderedValue(None)
103 self.assertIsNone(self.widget.core_widget._getCurrentValue())
104+ self.assertIsNone(self.widget.core18_widget._getCurrentValue())
105 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
106
107 def test_setRenderedValue_empty(self):
108 self.widget.setRenderedValue({})
109 self.assertIsNone(self.widget.core_widget._getCurrentValue())
110+ self.assertIsNone(self.widget.core18_widget._getCurrentValue())
111 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
112
113 def test_setRenderedValue_one_channel(self):
114 self.widget.setRenderedValue({"snapcraft": "stable"})
115 self.assertIsNone(self.widget.core_widget._getCurrentValue())
116+ self.assertIsNone(self.widget.core18_widget._getCurrentValue())
117 self.assertEqual(
118 "stable", self.widget.snapcraft_widget._getCurrentValue())
119
120 def test_setRenderedValue_all_channels(self):
121 self.widget.setRenderedValue(
122- {"core": "candidate", "snapcraft": "stable"})
123+ {"core": "candidate", "core18": "beta", "snapcraft": "stable"})
124 self.assertEqual(
125 "candidate", self.widget.core_widget._getCurrentValue())
126+ self.assertEqual("beta", self.widget.core18_widget._getCurrentValue())
127 self.assertEqual(
128 "stable", self.widget.snapcraft_widget._getCurrentValue())
129
130@@ -140,6 +146,7 @@
131 # there is no "false" counterpart to this test.)
132 form = {
133 "field.auto_build_channels.core": "",
134+ "field.auto_build_channels.core18": "beta",
135 "field.auto_build_channels.snapcraft": "stable",
136 }
137 self.widget.request = LaunchpadTestRequest(form=form)
138@@ -148,20 +155,25 @@
139 def test_getInputValue(self):
140 form = {
141 "field.auto_build_channels.core": "",
142+ "field.auto_build_channels.core18": "beta",
143 "field.auto_build_channels.snapcraft": "stable",
144 }
145 self.widget.request = LaunchpadTestRequest(form=form)
146- self.assertEqual({"snapcraft": "stable"}, self.widget.getInputValue())
147+ self.assertEqual(
148+ {"core18": "beta", "snapcraft": "stable"},
149+ self.widget.getInputValue())
150
151 def test_call(self):
152 # The __call__ method sets up the widgets.
153 markup = self.widget()
154 self.assertIsNotNone(self.widget.core_widget)
155+ self.assertIsNotNone(self.widget.core18_widget)
156 self.assertIsNotNone(self.widget.snapcraft_widget)
157 soup = BeautifulSoup(markup)
158 fields = soup.findAll(["input"], {"id": re.compile(".*")})
159 expected_ids = [
160 "field.auto_build_channels.core",
161+ "field.auto_build_channels.core18",
162 "field.auto_build_channels.snapcraft",
163 ]
164 ids = [field["id"] for field in fields]
165
166=== modified file 'lib/lp/snappy/interfaces/snap.py'
167--- lib/lp/snappy/interfaces/snap.py 2019-05-16 10:21:14 +0000
168+++ lib/lp/snappy/interfaces/snap.py 2019-05-22 19:56:26 +0000
169@@ -387,8 +387,8 @@
170 title=_("Source snap channels to use for this build."),
171 description=_(
172 "A dictionary mapping snap names to channels to use for this "
173- "build. Currently only 'core' and 'snapcraft' keys are "
174- "supported."),
175+ "build. Currently only 'core', 'core18', and 'snapcraft' "
176+ "keys are supported."),
177 key_type=TextLine(), required=False))
178 # Really ISnapBuild, patched in lp.snappy.interfaces.webservice.
179 @export_factory_operation(Interface, [])
180@@ -416,8 +416,8 @@
181 title=_("Source snap channels to use for this build."),
182 description=_(
183 "A dictionary mapping snap names to channels to use for this "
184- "build. Currently only 'core' and 'snapcraft' keys are "
185- "supported."),
186+ "build. Currently only 'core', 'core18', and 'snapcraft' "
187+ "keys are supported."),
188 key_type=TextLine(), required=False))
189 @export_factory_operation(ISnapBuildRequest, [])
190 @operation_for_version("devel")
191@@ -744,8 +744,8 @@
192 key_type=TextLine(), required=False, readonly=False,
193 description=_(
194 "A dictionary mapping snap names to channels to use when building "
195- "this snap package. Currently only 'core' and 'snapcraft' keys "
196- "are supported.")))
197+ "this snap package. Currently only 'core', 'core18', and "
198+ "'snapcraft' keys are supported.")))
199
200 is_stale = Bool(
201 title=_("Snap package is stale and is due to be rebuilt."),
202
203=== modified file 'lib/lp/snappy/interfaces/snapbuild.py'
204--- lib/lp/snappy/interfaces/snapbuild.py 2018-12-12 10:31:40 +0000
205+++ lib/lp/snappy/interfaces/snapbuild.py 2019-05-22 19:56:26 +0000
206@@ -1,4 +1,4 @@
207-# Copyright 2015-2018 Canonical Ltd. This software is licensed under the
208+# Copyright 2015-2019 Canonical Ltd. This software is licensed under the
209 # GNU Affero General Public License version 3 (see the file LICENSE).
210
211 """Snap package build interfaces."""
212@@ -164,8 +164,8 @@
213 title=_("Source snap channels to use for this build."),
214 description=_(
215 "A dictionary mapping snap names to channels to use for this "
216- "build. Currently only 'core' and 'snapcraft' keys are "
217- "supported."),
218+ "build. Currently only 'core', 'core18', and 'snapcraft' keys "
219+ "are supported."),
220 key_type=TextLine()))
221
222 virtualized = Bool(
223
224=== modified file 'lib/lp/snappy/interfaces/snapjob.py'
225--- lib/lp/snappy/interfaces/snapjob.py 2018-09-13 15:21:05 +0000
226+++ lib/lp/snappy/interfaces/snapjob.py 2019-05-22 19:56:26 +0000
227@@ -1,4 +1,4 @@
228-# Copyright 2018 Canonical Ltd. This software is licensed under the
229+# Copyright 2018-2019 Canonical Ltd. This software is licensed under the
230 # GNU Affero General Public License version 3 (see the file LICENSE).
231
232 """Snap job interfaces."""
233@@ -74,8 +74,8 @@
234 title=_("Source snap channels to use for these builds."),
235 description=_(
236 "A dictionary mapping snap names to channels to use for these "
237- "builds. Currently only 'core' and 'snapcraft' keys are "
238- "supported."),
239+ "builds. Currently only 'core', 'core18', and 'snapcraft' keys "
240+ "are supported."),
241 key_type=TextLine(), required=False, readonly=True)
242
243 date_created = Datetime(