← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:snap-debug into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:snap-debug into launchpad-buildd:master.

Commit message:
Gather *.debug from snap builds

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/426459

As discussed with the desktop and snapcraft teams recently.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:snap-debug into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 8b90a45..f2ded18 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,7 @@ launchpad-buildd (216) UNRELEASED; urgency=medium
   [ Colin Watson ]
   * Add a timeout when revoking proxy tokens.
   * Log SHA-512 hash of built snaps (LP: #1979844).
+  * Gather *.debug from snap builds.
 
  -- Andrey Fedoseev <andrey.fedoseev@xxxxxxxxxxxxx>  Mon, 27 Jun 2022 12:32:05 +0500
 
diff --git a/lpbuildd/snap.py b/lpbuildd/snap.py
index 720b1d8..968b06c 100644
--- a/lpbuildd/snap.py
+++ b/lpbuildd/snap.py
@@ -126,6 +126,7 @@ class SnapBuildManager(BuildManagerProxyMixin, DebianBuildManager):
                 if self.backend.islink(path):
                     continue
                 if (entry.endswith(".snap") or entry.endswith(".manifest")
+                        or entry.endswith(".debug")
                         or entry.endswith(".dpkg.yaml")):
                     self.addWaitingFileFromBackend(path)
         if self.build_source_tarball:
diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
index 7791584..8aa0ecc 100644
--- a/lpbuildd/tests/test_snap.py
+++ b/lpbuildd/tests/test_snap.py
@@ -219,6 +219,57 @@ class TestSnapBuildManagerIteration(TestCase):
         self.assertFalse(self.builder.wasCalled("buildFail"))
 
     @defer.inlineCallbacks
+    def test_iterate_with_debug(self):
+        # The build manager iterates a build that uploads debug symbols from
+        # start to finish.
+        args = {
+            "git_repository": "https://git.launchpad.dev/~example/+git/snap";,
+            "git_path": "master",
+            }
+        expected_options = [
+            "--git-repository", "https://git.launchpad.dev/~example/+git/snap";,
+            "--git-path", "master",
+            ]
+        yield self.startBuild(args, expected_options)
+
+        log_path = os.path.join(self.buildmanager._cachepath, "buildlog")
+        with open(log_path, "w") as log:
+            log.write("I am a build log.")
+
+        self.buildmanager.backend.add_file(
+            "/build/test-snap/test-snap_0_all.snap", b"I am a snap package.")
+        self.buildmanager.backend.add_file(
+            "/build/test-snap/test-snap_0_all.debug", b"I am debug symbols.")
+
+        # After building the package, reap processes.
+        yield self.buildmanager.iterate(0)
+        expected_command = [
+            "sharepath/bin/in-target", "in-target", "scan-for-processes",
+            "--backend=lxd", "--series=xenial", "--arch=i386", self.buildid,
+            ]
+        self.assertEqual(SnapBuildState.BUILD_SNAP, self.getState())
+        self.assertEqual(expected_command, self.buildmanager.commands[-1])
+        self.assertNotEqual(
+            self.buildmanager.iterate, self.buildmanager.iterators[-1])
+        self.assertFalse(self.builder.wasCalled("buildFail"))
+        self.assertThat(self.builder, HasWaitingFiles.byEquality({
+            "test-snap_0_all.debug": b"I am debug symbols.",
+            "test-snap_0_all.snap": b"I am a snap package.",
+            }))
+
+        # Control returns to the DebianBuildManager in the UMOUNT state.
+        self.buildmanager.iterateReap(self.getState(), 0)
+        expected_command = [
+            "sharepath/bin/in-target", "in-target", "umount-chroot",
+            "--backend=lxd", "--series=xenial", "--arch=i386", self.buildid,
+            ]
+        self.assertEqual(SnapBuildState.UMOUNT, self.getState())
+        self.assertEqual(expected_command, self.buildmanager.commands[-1])
+        self.assertEqual(
+            self.buildmanager.iterate, self.buildmanager.iterators[-1])
+        self.assertFalse(self.builder.wasCalled("buildFail"))
+
+    @defer.inlineCallbacks
     def test_iterate_with_dpkg_yaml(self):
         # The build manager iterates a build that uploads dpkg.yaml from
         # start to finish.