Merge lp:~cjwatson/launchpad-buildd/better-snap-channel-handling-2 into lp:launchpad-buildd

Proposed by Colin Watson on 2019-05-22
Status: Merged
Merged at revision: 380
Proposed branch: lp:~cjwatson/launchpad-buildd/better-snap-channel-handling-2
Merge into: lp:launchpad-buildd
Diff against target: 105 lines (+65/-11)
3 files modified
debian/changelog (+7/-0)
lpbuildd/snap.py (+2/-11)
lpbuildd/tests/test_snap.py (+56/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/better-snap-channel-handling-2
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve on 2019-05-23
Launchpad code reviewers 2019-05-22 Pending
Review via email: mp+367794@code.launchpad.net

Commit message

Really allow channel selection for core16 and core18.

Description of the change

I meant to do this in https://code.launchpad.net/~cjwatson/launchpad-buildd/better-snap-channel-handling/+merge/362859, but missed a bit.

I don't think the unknown snap name check really buys us enough to justify its existence: it's a slightly useful typo check, but really it just makes it more effort to extend, as demonstrated by me getting this extension wrong even though I wrote the code in the first place.

To post a comment you must log in.
Adam Collard (adam-collard) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2019-05-08 16:15:24 +0000
3+++ debian/changelog 2019-05-22 18:02:19 +0000
4@@ -1,3 +1,10 @@
5+launchpad-buildd (174) UNRELEASED; urgency=medium
6+
7+ * Fix a missing piece from the changes in launchpad-buildd 168 that were
8+ intended to allow channel selection for core16 and core18.
9+
10+ -- Colin Watson <cjwatson@ubuntu.com> Wed, 22 May 2019 18:58:22 +0100
11+
12 launchpad-buildd (173) xenial; urgency=medium
13
14 [ Matias Bordese ]
15
16=== modified file 'lpbuildd/snap.py'
17--- lpbuildd/snap.py 2019-05-08 10:31:41 +0000
18+++ lpbuildd/snap.py 2019-05-22 18:02:19 +0000
19@@ -329,17 +329,8 @@
20 def doRunBuild(self):
21 """Run the process to build the snap."""
22 args = []
23- known_snaps = ("core", "snapcraft")
24- for snap in known_snaps:
25- if snap in self.channels:
26- args.extend(
27- ["--channel", "%s=%s" % (snap, self.channels[snap])])
28- unknown_snaps = set(self.channels) - set(known_snaps)
29- if unknown_snaps:
30- print(
31- "Channels requested for unknown snaps: %s" %
32- " ".join(sorted(unknown_snaps)),
33- file=sys.stderr)
34+ for snap, channel in sorted(self.channels.items()):
35+ args.extend(["--channel", "%s=%s" % (snap, channel)])
36 if self.build_request_id:
37 args.extend(["--build-request-id", str(self.build_request_id)])
38 if self.build_request_timestamp:
39
40=== modified file 'lpbuildd/tests/test_snap.py'
41--- lpbuildd/tests/test_snap.py 2019-05-08 10:31:41 +0000
42+++ lpbuildd/tests/test_snap.py 2019-05-22 18:02:19 +0000
43@@ -220,6 +220,62 @@
44 self.assertFalse(self.builder.wasCalled("buildFail"))
45
46 @defer.inlineCallbacks
47+ def test_iterate_with_channels(self):
48+ # The build manager iterates a build that specifies channels from
49+ # start to finish.
50+ args = {
51+ "git_repository": "https://git.launchpad.dev/~example/+git/snap",
52+ "git_path": "master",
53+ "channels": {
54+ "core": "candidate",
55+ "core18": "beta",
56+ "snapcraft": "edge",
57+ },
58+ }
59+ expected_options = [
60+ "--channel", "core=candidate",
61+ "--channel", "core18=beta",
62+ "--channel", "snapcraft=edge",
63+ "--git-repository", "https://git.launchpad.dev/~example/+git/snap",
64+ "--git-path", "master",
65+ ]
66+ yield self.startBuild(args, expected_options)
67+
68+ log_path = os.path.join(self.buildmanager._cachepath, "buildlog")
69+ with open(log_path, "w") as log:
70+ log.write("I am a build log.")
71+
72+ self.buildmanager.backend.add_file(
73+ "/build/test-snap/test-snap_0_all.snap", b"I am a snap package.")
74+
75+ # After building the package, reap processes.
76+ yield self.buildmanager.iterate(0)
77+ expected_command = [
78+ "sharepath/bin/in-target", "in-target", "scan-for-processes",
79+ "--backend=lxd", "--series=xenial", "--arch=i386", self.buildid,
80+ ]
81+ self.assertEqual(SnapBuildState.BUILD_SNAP, self.getState())
82+ self.assertEqual(expected_command, self.buildmanager.commands[-1])
83+ self.assertNotEqual(
84+ self.buildmanager.iterate, self.buildmanager.iterators[-1])
85+ self.assertFalse(self.builder.wasCalled("buildFail"))
86+ self.assertThat(self.builder, HasWaitingFiles.byEquality({
87+ "test-snap_0_all.snap": b"I am a snap package.",
88+ }))
89+
90+ # Control returns to the DebianBuildManager in the UMOUNT state.
91+ self.buildmanager.iterateReap(self.getState(), 0)
92+ expected_command = [
93+ "sharepath/bin/in-target", "in-target", "umount-chroot",
94+ "--backend=lxd", "--series=xenial", "--arch=i386", self.buildid,
95+ ]
96+ self.assertEqual(SnapBuildState.UMOUNT, self.getState())
97+ self.assertEqual(expected_command, self.buildmanager.commands[-1])
98+ self.assertEqual(
99+ self.buildmanager.iterate, self.buildmanager.iterators[-1])
100+ self.assertFalse(self.builder.wasCalled("buildFail"))
101+
102+ @defer.inlineCallbacks
103 def test_iterate_with_build_source_tarball(self):
104 # The build manager iterates a build that uploads a source tarball
105 # from start to finish.

Subscribers

People subscribed via source and target branches

to all changes: