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

Proposed by William Grant
Status: Merged
Merged at revision: 18887
Proposed branch: lp:~wgrant/launchpad/bug-1817544-makeAutoBuilds-infer
Merge into: lp:launchpad
Diff against target: 52 lines (+26/-3)
2 files modified
lib/lp/snappy/model/snap.py (+3/-3)
lib/lp/snappy/tests/test_snap.py (+23/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-1817544-makeAutoBuilds-infer
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+363646@code.launchpad.net

Commit message

Fix SnapSet.makeAutoBuilds to infer distroseries instead of crashing.

Description of the change

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

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Colin suggested the same thing, so...

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/model/snap.py'
2--- lib/lp/snappy/model/snap.py 2019-02-18 14:49:28 +0000
3+++ lib/lp/snappy/model/snap.py 2019-02-26 07:14:09 +0000
4@@ -726,11 +726,11 @@
5 raise CannotRequestAutoBuilds("auto_build_archive")
6 if self.auto_build_pocket is None:
7 raise CannotRequestAutoBuilds("auto_build_pocket")
8- if self.distro_series is None:
9+ if not fetch_snapcraft_yaml and self.distro_series is None:
10 raise IncompatibleArguments(
11 "Cannot use requestAutoBuilds for a snap package without "
12- "distro_series being set. Consider using requestBuilds "
13- "instead.")
14+ "inferring from snapcraft.yaml or distro_series being set. "
15+ "Consider using requestBuilds instead.")
16 self.is_stale = False
17 if logger is not None:
18 logger.debug(
19
20=== modified file 'lib/lp/snappy/tests/test_snap.py'
21--- lib/lp/snappy/tests/test_snap.py 2019-02-18 14:49:28 +0000
22+++ lib/lp/snappy/tests/test_snap.py 2019-02-26 07:14:09 +0000
23@@ -2009,6 +2009,29 @@
24 expected_log_entries, logger.getLogBuffer().splitlines())
25 self.assertFalse(snap.is_stale)
26
27+ def test_makeAutoBuilds_infers_distroseries(self):
28+ # ISnapSet.makeAutoBuilds can infer the series of a snap from the base
29+ # specified in its snapcraft.yaml.
30+ with admin_logged_in():
31+ snap_base = self.factory.makeSnapBase(name="core20")
32+ das = self.makeBuildableDistroArchSeries(
33+ distroseries=snap_base.distro_series, architecturetag='riscv64',
34+ processor=self.factory.makeProcessor(
35+ name='riscv64', supports_virtualized=True))
36+ [git_ref] = self.factory.makeGitRefs()
37+ owner = self.factory.makePerson()
38+ snap = self.factory.makeSnap(
39+ registrant=owner, distroseries=None, git_ref=git_ref,
40+ auto_build=True,
41+ auto_build_archive=self.factory.makeArchive(
42+ snap_base.distro_series.distribution, owner=owner))
43+ with GitHostingFixture(blob="base: core20\n"):
44+ builds = getUtility(ISnapSet).makeAutoBuilds()
45+ self.assertThat(set(builds), MatchesSetwise(
46+ MatchesStructure.byEquality(
47+ requester=snap.owner, snap=snap, distro_arch_series=das,
48+ status=BuildStatus.NEEDSBUILD)))
49+
50 def test_detachFromBranch(self):
51 # ISnapSet.detachFromBranch clears the given Bazaar branch from all
52 # Snaps.