← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-1817544-makeAutoBuilds-infer into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-1817544-makeAutoBuilds-infer into lp:launchpad.

Commit message:
Fix SnapSet.makeAutoBuilds to infer distroseries instead of crashing.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1817544 in Launchpad itself: "requestAutoBuilds crashes for snaps configured to detect distro_series"
  https://bugs.launchpad.net/launchpad/+bug/1817544

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1817544-makeAutoBuilds-infer/+merge/363646

The underlying requestBuildsFromJob already did the right thing, but
makeAutoBuilds had an extra guard from before the new inference capability was
introduced.

-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1817544-makeAutoBuilds-infer into lp:launchpad.
=== modified file 'lib/lp/snappy/model/snap.py'
--- lib/lp/snappy/model/snap.py	2019-02-18 14:49:28 +0000
+++ lib/lp/snappy/model/snap.py	2019-02-26 07:14:09 +0000
@@ -726,11 +726,11 @@
             raise CannotRequestAutoBuilds("auto_build_archive")
         if self.auto_build_pocket is None:
             raise CannotRequestAutoBuilds("auto_build_pocket")
-        if self.distro_series is None:
+        if not fetch_snapcraft_yaml and self.distro_series is None:
             raise IncompatibleArguments(
                 "Cannot use requestAutoBuilds for a snap package without "
-                "distro_series being set.  Consider using requestBuilds "
-                "instead.")
+                "inferring from snapcraft.yaml or distro_series being set.  "
+                "Consider using requestBuilds instead.")
         self.is_stale = False
         if logger is not None:
             logger.debug(

=== modified file 'lib/lp/snappy/tests/test_snap.py'
--- lib/lp/snappy/tests/test_snap.py	2019-02-18 14:49:28 +0000
+++ lib/lp/snappy/tests/test_snap.py	2019-02-26 07:14:09 +0000
@@ -2009,6 +2009,29 @@
             expected_log_entries, logger.getLogBuffer().splitlines())
         self.assertFalse(snap.is_stale)
 
+    def test_makeAutoBuilds_infers_distroseries(self):
+        # ISnapSet.makeAutoBuilds can infer the series of a snap from the base
+        # specified in its snapcraft.yaml.
+        with admin_logged_in():
+            snap_base = self.factory.makeSnapBase(name="core20")
+        das = self.makeBuildableDistroArchSeries(
+            distroseries=snap_base.distro_series, architecturetag='riscv64',
+            processor=self.factory.makeProcessor(
+                name='riscv64', supports_virtualized=True))
+        [git_ref] = self.factory.makeGitRefs()
+        owner = self.factory.makePerson()
+        snap = self.factory.makeSnap(
+            registrant=owner, distroseries=None, git_ref=git_ref,
+            auto_build=True,
+            auto_build_archive=self.factory.makeArchive(
+                snap_base.distro_series.distribution, owner=owner))
+        with GitHostingFixture(blob="base: core20\n"):
+            builds = getUtility(ISnapSet).makeAutoBuilds()
+        self.assertThat(set(builds), MatchesSetwise(
+            MatchesStructure.byEquality(
+                requester=snap.owner, snap=snap, distro_arch_series=das,
+                status=BuildStatus.NEEDSBUILD)))
+
     def test_detachFromBranch(self):
         # ISnapSet.detachFromBranch clears the given Bazaar branch from all
         # Snaps.


Follow ups