Merge ~ilasc/launchpad-buildd:gather-dpkg-yaml into launchpad-buildd:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: d2ac9988532dd0a8cca4efa8683497d0ad33247c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad-buildd:gather-dpkg-yaml
Merge into: launchpad-buildd:master
Diff against target: 100 lines (+66/-1)
3 files modified
debian/changelog (+3/-0)
lpbuildd/snap.py (+2/-1)
lpbuildd/tests/test_snap.py (+61/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+408538@code.launchpad.net

Commit message

Gather dpkg.yaml for snap builds

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Needs Information
Revision history for this message
Ioana Lasc (ilasc) wrote :

Indentation fixed and PRs created to get the dpkg.yaml file copied into the top folder for Buildd to be able to gather it:
https://github.com/snapcore/core18/pull/181
https://github.com/snapcore/core20/pull/113
https://github.com/snapcore/core/pull/125

First 2 PRs are already approved and merged.
Purely from an "order of landing" perspective I don't think we need to wait for all those to be merged however to land this as Buildd just won't gather dpkg.yaml if is not in the expected folder.

MP ready for another look.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Could you also add an entry to debian/changelog describing this change before landing it? You should be able to use 'dch' to sort out the syntax.

Revision history for this message
Ioana Lasc (ilasc) wrote :

Done, thanks Colin!

Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Ioana Lasc (ilasc) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index df18746..a7ffa63 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -4,6 +4,9 @@ launchpad-buildd (202) UNRELEASED; urgency=medium
6 * Add git_shallow_clone option to vcs_fetch() and use it for OCI build
7 (LP: #1939392).
8
9+ [ Ioana Lasc ]
10+ * Gather dpkg.yaml for snap builds.
11+
12 -- Colin Watson <cjwatson@ubuntu.com> Thu, 09 Sep 2021 12:58:06 +0100
13
14 launchpad-buildd (201) bionic; urgency=medium
15diff --git a/lpbuildd/snap.py b/lpbuildd/snap.py
16index 2a5ffc4..5afead1 100644
17--- a/lpbuildd/snap.py
18+++ b/lpbuildd/snap.py
19@@ -141,7 +141,8 @@ class SnapBuildManager(BuildManagerProxyMixin, DebianBuildManager):
20 path = os.path.join(output_path, entry)
21 if self.backend.islink(path):
22 continue
23- if entry.endswith(".snap") or entry.endswith(".manifest"):
24+ if (entry.endswith(".snap") or entry.endswith(".manifest")
25+ or entry.endswith(".dpkg.yaml")):
26 self.addWaitingFileFromBackend(path)
27 if self.build_source_tarball:
28 source_tarball_path = os.path.join(
29diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
30index b018a53..5aa0671 100644
31--- a/lpbuildd/tests/test_snap.py
32+++ b/lpbuildd/tests/test_snap.py
33@@ -224,6 +224,67 @@ class TestSnapBuildManagerIteration(TestCase):
34 self.assertFalse(self.builder.wasCalled("buildFail"))
35
36 @defer.inlineCallbacks
37+ def test_iterate_with_dpkg_yaml(self):
38+ # The build manager iterates a build that uploads dpkg.yaml from
39+ # start to finish.
40+ args = {
41+ "git_repository": "https://git.launchpad.dev/~example/+git/snap",
42+ "git_path": "master",
43+ }
44+ expected_options = [
45+ "--git-repository", "https://git.launchpad.dev/~example/+git/snap",
46+ "--git-path", "master",
47+ ]
48+ yield self.startBuild(args, expected_options)
49+
50+ log_path = os.path.join(self.buildmanager._cachepath, "buildlog")
51+ with open(log_path, "w") as log:
52+ log.write("I am a build log.")
53+
54+ self.buildmanager.backend.add_file(
55+ "/build/test-snap/test-snap_0_all.snap", b"I am a snap package.")
56+ self.buildmanager.backend.add_file(
57+ "/build/test-snap/test-snap_0_all.manifest", b"I am a manifest.")
58+ self.buildmanager.backend.add_file(
59+ "/build/test-snap/test-snap_0_all.dpkg.yaml", b"I am a yaml file.")
60+
61+ # After building the package, reap processes.
62+ yield self.buildmanager.iterate(0)
63+ expected_command = [
64+ "sharepath/bin/in-target", "in-target", "scan-for-processes",
65+ "--backend=lxd", "--series=xenial", "--arch=i386", self.buildid,
66+ ]
67+ self.assertEqual(SnapBuildState.BUILD_SNAP, self.getState())
68+ self.assertEqual(expected_command, self.buildmanager.commands[-1])
69+ self.assertNotEqual(
70+ self.buildmanager.iterate, self.buildmanager.iterators[-1])
71+ self.assertFalse(self.builder.wasCalled("buildFail"))
72+ self.assertThat(self.builder, HasWaitingFiles.byEquality({
73+ "test-snap_0_all.manifest": b"I am a manifest.",
74+ "test-snap_0_all.snap": b"I am a snap package.",
75+ "test-snap_0_all.dpkg.yaml": b"I am a yaml file.",
76+ }))
77+ # Ensure we don't just gather any yaml file but exactly
78+ # the dpkg yaml.
79+ self.assertNotEqual(self.builder, HasWaitingFiles.byEquality({
80+ "test-snap_0_all.manifest": b"I am a manifest.",
81+ "test-snap_0_all.snap": b"I am a snap package.",
82+ "test-snap_0_all.snapcraft.yaml": b"I am a yaml file.",
83+ }))
84+
85+ # Control returns to the DebianBuildManager in the UMOUNT state.
86+ self.buildmanager.iterateReap(self.getState(), 0)
87+ expected_command = [
88+ "sharepath/bin/in-target", "in-target", "umount-chroot",
89+ "--backend=lxd", "--series=xenial", "--arch=i386", self.buildid,
90+ ]
91+ self.assertEqual(SnapBuildState.UMOUNT, self.getState())
92+ self.assertEqual(expected_command, self.buildmanager.commands[-1])
93+ self.assertEqual(
94+ self.buildmanager.iterate, self.buildmanager.iterators[-1])
95+ self.assertFalse(self.builder.wasCalled("buildFail"))
96+
97+ @defer.inlineCallbacks
98 def test_iterate_with_channels(self):
99 # The build manager iterates a build that specifies channels from
100 # start to finish.

Subscribers

People subscribed via source and target branches