← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/snap-core18 into lp:launchpad.

Commit message:
Allow selecting the core18 channel for snap builds.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snap-core18/+merge/367800

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snap-core18 into lp:launchpad.
=== modified file 'lib/lp/snappy/browser/tests/test_snap.py'
--- lib/lp/snappy/browser/tests/test_snap.py	2019-05-16 10:21:14 +0000
+++ lib/lp/snappy/browser/tests/test_snap.py	2019-05-22 19:56:26 +0000
@@ -428,6 +428,8 @@
         browser.getControl(
             name="field.auto_build_channels.core").value = "stable"
         browser.getControl(
+            name="field.auto_build_channels.core18").value = "beta"
+        browser.getControl(
             name="field.auto_build_channels.snapcraft").value = "edge"
         browser.getControl("Create snap package").click()
 
@@ -444,7 +446,7 @@
             MatchesTagText(content, "auto_build_pocket"))
         self.assertThat(
             "Source snap channels for automatic builds:\nEdit snap package\n"
-            "core\nstable\nsnapcraft\nedge\n",
+            "core\nstable\ncore18\nbeta\nsnapcraft\nedge\n",
             MatchesTagText(content, "auto_build_channels"))
 
     @responses.activate
@@ -1670,6 +1672,7 @@
             when building the snap package.
             Source snap channels:
             core
+            core18
             snapcraft
             The channels to use for build tools when building the snap
             package.

=== modified file 'lib/lp/snappy/browser/widgets/snapbuildchannels.py'
--- lib/lp/snappy/browser/widgets/snapbuildchannels.py	2018-08-30 16:15:20 +0000
+++ lib/lp/snappy/browser/widgets/snapbuildchannels.py	2019-05-22 19:56:26 +0000
@@ -1,4 +1,4 @@
-# Copyright 2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2018-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """A widget for selecting source snap channels for builds."""
@@ -36,7 +36,7 @@
 
     template = ViewPageTemplateFile("templates/snapbuildchannels.pt")
     hint = False
-    snap_names = ["core", "snapcraft"]
+    snap_names = ["core", "core18", "snapcraft"]
     _widgets_set_up = False
 
     def __init__(self, context, request):
@@ -77,8 +77,9 @@
         self.setUpSubWidgets()
         if not zope_isinstance(value, dict):
             value = {}
-        self.core_widget.setRenderedValue(value.get("core"))
-        self.snapcraft_widget.setRenderedValue(value.get("snapcraft"))
+        for snap_name in self.snap_names:
+            getattr(self, "%s_widget" % snap_name).setRenderedValue(
+                value.get(snap_name))
 
     def hasInput(self):
         """See `IInputWidget`."""

=== modified file 'lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt'
--- lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt	2018-04-30 16:48:47 +0000
+++ lib/lp/snappy/browser/widgets/templates/snapbuildchannels.pt	2019-05-22 19:56:26 +0000
@@ -8,6 +8,10 @@
     <td><div tal:content="structure view/core_widget" /></td>
   </tr>
   <tr>
+    <td>core18</td>
+    <td><div tal:content="structure view/core18_widget" /></td>
+  </tr>
+  <tr>
     <td>snapcraft</td>
     <td><div tal:content="structure view/snapcraft_widget" /></td>
   </tr>

=== modified file 'lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py'
--- lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py	2018-04-30 19:02:40 +0000
+++ lib/lp/snappy/browser/widgets/tests/test_snapbuildchannelswidget.py	2019-05-22 19:56:26 +0000
@@ -1,4 +1,4 @@
-# Copyright 2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2018-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from __future__ import absolute_import, print_function, unicode_literals
@@ -89,6 +89,7 @@
         self.widget.setUpSubWidgets()
         self.assertTrue(self.widget._widgets_set_up)
         self.assertIsNotNone(getattr(self.widget, "core_widget", None))
+        self.assertIsNotNone(getattr(self.widget, "core18_widget", None))
         self.assertIsNotNone(getattr(self.widget, "snapcraft_widget", None))
 
     def test_setUpSubWidgets_second_call(self):
@@ -97,29 +98,34 @@
         self.widget._widgets_set_up = True
         self.widget.setUpSubWidgets()
         self.assertIsNone(getattr(self.widget, "core_widget", None))
+        self.assertIsNone(getattr(self.widget, "core18_widget", None))
         self.assertIsNone(getattr(self.widget, "snapcraft_widget", None))
 
     def test_setRenderedValue_None(self):
         self.widget.setRenderedValue(None)
         self.assertIsNone(self.widget.core_widget._getCurrentValue())
+        self.assertIsNone(self.widget.core18_widget._getCurrentValue())
         self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
 
     def test_setRenderedValue_empty(self):
         self.widget.setRenderedValue({})
         self.assertIsNone(self.widget.core_widget._getCurrentValue())
+        self.assertIsNone(self.widget.core18_widget._getCurrentValue())
         self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
 
     def test_setRenderedValue_one_channel(self):
         self.widget.setRenderedValue({"snapcraft": "stable"})
         self.assertIsNone(self.widget.core_widget._getCurrentValue())
+        self.assertIsNone(self.widget.core18_widget._getCurrentValue())
         self.assertEqual(
             "stable", self.widget.snapcraft_widget._getCurrentValue())
 
     def test_setRenderedValue_all_channels(self):
         self.widget.setRenderedValue(
-            {"core": "candidate", "snapcraft": "stable"})
+            {"core": "candidate", "core18": "beta", "snapcraft": "stable"})
         self.assertEqual(
             "candidate", self.widget.core_widget._getCurrentValue())
+        self.assertEqual("beta", self.widget.core18_widget._getCurrentValue())
         self.assertEqual(
             "stable", self.widget.snapcraft_widget._getCurrentValue())
 
@@ -140,6 +146,7 @@
         # there is no "false" counterpart to this test.)
         form = {
             "field.auto_build_channels.core": "",
+            "field.auto_build_channels.core18": "beta",
             "field.auto_build_channels.snapcraft": "stable",
             }
         self.widget.request = LaunchpadTestRequest(form=form)
@@ -148,20 +155,25 @@
     def test_getInputValue(self):
         form = {
             "field.auto_build_channels.core": "",
+            "field.auto_build_channels.core18": "beta",
             "field.auto_build_channels.snapcraft": "stable",
             }
         self.widget.request = LaunchpadTestRequest(form=form)
-        self.assertEqual({"snapcraft": "stable"}, self.widget.getInputValue())
+        self.assertEqual(
+            {"core18": "beta", "snapcraft": "stable"},
+            self.widget.getInputValue())
 
     def test_call(self):
         # The __call__ method sets up the widgets.
         markup = self.widget()
         self.assertIsNotNone(self.widget.core_widget)
+        self.assertIsNotNone(self.widget.core18_widget)
         self.assertIsNotNone(self.widget.snapcraft_widget)
         soup = BeautifulSoup(markup)
         fields = soup.findAll(["input"], {"id": re.compile(".*")})
         expected_ids = [
             "field.auto_build_channels.core",
+            "field.auto_build_channels.core18",
             "field.auto_build_channels.snapcraft",
             ]
         ids = [field["id"] for field in fields]

=== modified file 'lib/lp/snappy/interfaces/snap.py'
--- lib/lp/snappy/interfaces/snap.py	2019-05-16 10:21:14 +0000
+++ lib/lp/snappy/interfaces/snap.py	2019-05-22 19:56:26 +0000
@@ -387,8 +387,8 @@
             title=_("Source snap channels to use for this build."),
             description=_(
                 "A dictionary mapping snap names to channels to use for this "
-                "build.  Currently only 'core' and 'snapcraft' keys are "
-                "supported."),
+                "build.  Currently only 'core', 'core18', and 'snapcraft' "
+                "keys are supported."),
             key_type=TextLine(), required=False))
     # Really ISnapBuild, patched in lp.snappy.interfaces.webservice.
     @export_factory_operation(Interface, [])
@@ -416,8 +416,8 @@
             title=_("Source snap channels to use for this build."),
             description=_(
                 "A dictionary mapping snap names to channels to use for this "
-                "build.  Currently only 'core' and 'snapcraft' keys are "
-                "supported."),
+                "build.  Currently only 'core', 'core18', and 'snapcraft' "
+                "keys are supported."),
             key_type=TextLine(), required=False))
     @export_factory_operation(ISnapBuildRequest, [])
     @operation_for_version("devel")
@@ -744,8 +744,8 @@
         key_type=TextLine(), required=False, readonly=False,
         description=_(
             "A dictionary mapping snap names to channels to use when building "
-            "this snap package.  Currently only 'core' and 'snapcraft' keys "
-            "are supported.")))
+            "this snap package.  Currently only 'core', 'core18', and "
+            "'snapcraft' keys are supported.")))
 
     is_stale = Bool(
         title=_("Snap package is stale and is due to be rebuilt."),

=== modified file 'lib/lp/snappy/interfaces/snapbuild.py'
--- lib/lp/snappy/interfaces/snapbuild.py	2018-12-12 10:31:40 +0000
+++ lib/lp/snappy/interfaces/snapbuild.py	2019-05-22 19:56:26 +0000
@@ -1,4 +1,4 @@
-# Copyright 2015-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Snap package build interfaces."""
@@ -164,8 +164,8 @@
         title=_("Source snap channels to use for this build."),
         description=_(
             "A dictionary mapping snap names to channels to use for this "
-            "build.  Currently only 'core' and 'snapcraft' keys are "
-            "supported."),
+            "build.  Currently only 'core', 'core18', and 'snapcraft' keys "
+            "are supported."),
         key_type=TextLine()))
 
     virtualized = Bool(

=== modified file 'lib/lp/snappy/interfaces/snapjob.py'
--- lib/lp/snappy/interfaces/snapjob.py	2018-09-13 15:21:05 +0000
+++ lib/lp/snappy/interfaces/snapjob.py	2019-05-22 19:56:26 +0000
@@ -1,4 +1,4 @@
-# Copyright 2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2018-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Snap job interfaces."""
@@ -74,8 +74,8 @@
         title=_("Source snap channels to use for these builds."),
         description=_(
             "A dictionary mapping snap names to channels to use for these "
-            "builds.  Currently only 'core' and 'snapcraft' keys are "
-            "supported."),
+            "builds.  Currently only 'core', 'core18', and 'snapcraft' keys "
+            "are supported."),
         key_type=TextLine(), required=False, readonly=True)
 
     date_created = Datetime(


Follow ups