← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pelpsi/launchpad:add-support-for-bare-base-for-rock-builds into launchpad:master

 

Simone Pelosi has proposed merging ~pelpsi/launchpad:add-support-for-bare-base-for-rock-builds into launchpad:master.

Commit message:
Rockcraft build supports bare base
    
When base is set to bare in the rockcraft.yaml configuration file,
the build-base key becomes mandatory, and is evaluated for where the rock will be built.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/473769
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pelpsi/launchpad:add-support-for-bare-base-for-rock-builds into launchpad:master.
diff --git a/lib/lp/rocks/adapters/buildarch.py b/lib/lp/rocks/adapters/buildarch.py
index f4a8c83..57ce120 100644
--- a/lib/lp/rocks/adapters/buildarch.py
+++ b/lib/lp/rocks/adapters/buildarch.py
@@ -134,6 +134,12 @@ class UnifiedRockBaseConfiguration:
     def from_dict(cls, rockcraft_data, supported_arches):
         base = rockcraft_data["base"]
         if isinstance(base, str):
+            if base == "bare" and "build-base" not in rockcraft_data:
+                raise BadPropertyError(
+                    "If base is 'bare', then build-base must be specified."
+                )
+            if base == "bare":
+                base = rockcraft_data["build-base"]
             # Expected short-form value looks like 'ubuntu@24.04'
             match = re.match(r"(.+)@(.+)", base)
             if not match:
diff --git a/lib/lp/rocks/tests/test_rockrecipe.py b/lib/lp/rocks/tests/test_rockrecipe.py
index c7019be..ae56494 100644
--- a/lib/lp/rocks/tests/test_rockrecipe.py
+++ b/lib/lp/rocks/tests/test_rockrecipe.py
@@ -462,6 +462,66 @@ class TestRockRecipe(TestCaseWithFactory):
                     channels=removeSecurityProxy(job.channels),
                 )
 
+    def test_requestBuildsFromJob_unified_rockcraft_yaml_base_bare(self):
+        self.useFixture(
+            GitHostingFixture(
+                blob=dedent(
+                    """\
+                    base: bare
+                    build-base: ubuntu@20.04
+                    platforms:
+                        ubuntu-amd64:
+                            build-on: [amd64]
+                            build-for: [amd64]
+            """
+                )
+            )
+        )
+        job = self.makeRequestBuildsJob("20.04", ["amd64", "riscv64", "arm64"])
+        self.assertEqual(
+            get_transaction_timestamp(IStore(job.recipe)), job.date_created
+        )
+        transaction.commit()
+        with person_logged_in(job.requester):
+            builds = job.recipe.requestBuildsFromJob(
+                job.build_request, channels=removeSecurityProxy(job.channels)
+            )
+        self.assertRequestedBuildsMatch(
+            builds, job, "20.04", ["amd64"], job.channels
+        )
+
+    def test_requestBuildsFromJob_unified_rockcraft_yaml_missing_build_base(
+        self,
+    ):
+        self.useFixture(
+            GitHostingFixture(
+                blob=dedent(
+                    """\
+                    base: bare
+                    platforms:
+                        ubuntu-amd64:
+                            build-on: [amd64]
+                            build-for: [amd64]
+                    """
+                )
+            )
+        )
+        job = self.makeRequestBuildsJob("24.04", ["amd64", "riscv64", "arm64"])
+
+        self.assertEqual(
+            get_transaction_timestamp(IStore(job.recipe)), job.date_created
+        )
+        transaction.commit()
+        with person_logged_in(job.requester):
+            with ExpectedException(
+                BadPropertyError,
+                "If base is 'bare', then build-base must be specified.",
+            ):
+                job.recipe.requestBuildsFromJob(
+                    job.build_request,
+                    channels=removeSecurityProxy(job.channels),
+                )
+
     def test_requestBuildsFromJob_unified_rockcraft_yaml_platforms_missing(
         self,
     ):