launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #33172
[Merge] ~ruinedyourlife/launchpad:native-pub-launchpad-channel into launchpad:master
RuinedYourLife has proposed merging ~ruinedyourlife/launchpad:native-pub-launchpad-channel into launchpad:master.
Commit message:
Distroarchseries in launchpad.channel property
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ruinedyourlife/launchpad/+git/launchpad/+merge/494761
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ruinedyourlife/launchpad:native-pub-launchpad-channel into launchpad:master.
diff --git a/lib/lp/crafts/model/craftrecipebuildjob.py b/lib/lp/crafts/model/craftrecipebuildjob.py
index 81b4912..2981e0b 100644
--- a/lib/lp/crafts/model/craftrecipebuildjob.py
+++ b/lib/lp/crafts/model/craftrecipebuildjob.py
@@ -692,9 +692,7 @@ class CraftPublishingJob(CraftRecipeBuildJobDerived):
new_properties["soss.type"] = ["source"]
new_properties["soss.license"] = [self._get_license_metadata()]
version_str = self._get_version_metadata()
- channel_value = (
- f"{version_str}/stable" if version_str else "unknown/stable"
- )
+ channel_value = self._build_channel_value(version_str)
new_properties["launchpad.channel"] = [channel_value]
# Repo name is derived from the URL
@@ -829,3 +827,35 @@ class CraftPublishingJob(CraftRecipeBuildJobDerived):
log.info("No version found in metadata.yaml, returning 'unknown'.")
return "unknown"
return str(metadata.get("version"))
+
+ def _get_series_name(self) -> str:
+ """Return the distro series name for this build, or 'unknown'.
+
+ We derive the series from the build's `distro_arch_series` to prefix
+ the channel value.
+ """
+ series_name = "unknown"
+ try:
+ das = getattr(self.build, "distro_arch_series", None)
+ if (
+ das is not None
+ and getattr(das, "distroseries", None) is not None
+ ):
+ series_attr = getattr(das.distroseries, "name", None)
+ if series_attr:
+ series_name = series_attr
+ except Exception:
+ # Best-effort only; keep "unknown" on failure.
+ pass
+ return series_name
+
+ def _build_channel_value(self, version_str: str) -> str:
+ """Compose the channel value as '<series>:<version>/stable'.
+
+ Falls back to 'unknown' when version or series cannot be resolved.
+ """
+ series_name = self._get_series_name()
+ channel_suffix = (
+ f"{version_str}/stable" if version_str else "unknown/stable"
+ )
+ return f"{series_name}:{channel_suffix}"
diff --git a/lib/lp/crafts/tests/test_craftrecipebuildjob.py b/lib/lp/crafts/tests/test_craftrecipebuildjob.py
index 6b95efd..88d0470 100644
--- a/lib/lp/crafts/tests/test_craftrecipebuildjob.py
+++ b/lib/lp/crafts/tests/test_craftrecipebuildjob.py
@@ -83,7 +83,11 @@ class TestCraftPublishingJob(TestCaseWithFactory):
self.useFixture(FakeLogger())
self.useFixture(FeatureFixture({CRAFT_RECIPE_ALLOW_CREATE: "on"}))
self.recipe = self.factory.makeCraftRecipe()
- self.build = self.factory.makeCraftRecipeBuild(recipe=self.recipe)
+ ds = self.factory.makeDistroSeries(name="noble")
+ das = self.factory.makeDistroArchSeries(distroseries=ds)
+ self.build = self.factory.makeCraftRecipeBuild(
+ recipe=self.recipe, distro_arch_series=das
+ )
# Set up the Artifactory fixture
self.base_url = "https://example.com/artifactory"
@@ -548,7 +552,8 @@ class TestCraftPublishingJob(TestCaseWithFactory):
self.assertEqual(artifact["properties"]["soss.type"], "source")
self.assertEqual(artifact["properties"]["soss.license"], license_value)
self.assertEqual(
- artifact["properties"].get("launchpad.channel"), "0.1.0/stable"
+ artifact["properties"].get("launchpad.channel"),
+ "noble:0.1.0/stable",
)
def test_run_missing_maven_config(self):
@@ -773,7 +778,8 @@ class TestCraftPublishingJob(TestCaseWithFactory):
self.assertEqual(artifact["properties"]["soss.type"], "source")
self.assertEqual(artifact["properties"]["soss.license"], license_value)
self.assertEqual(
- artifact["properties"].get("launchpad.channel"), "0.1.0/stable"
+ artifact["properties"].get("launchpad.channel"),
+ "noble:0.1.0/stable",
)
def test__publish_properties_sets_expected_properties(self):
@@ -819,7 +825,7 @@ class TestCraftPublishingJob(TestCaseWithFactory):
self.assertEqual(props["soss.type"], "source")
self.assertEqual(props["soss.license"], "MIT")
self.assertIn("launchpad.channel", props)
- self.assertEqual(props["launchpad.channel"], "unknown/stable")
+ self.assertEqual(props["launchpad.channel"], "noble:unknown/stable")
def test__publish_properties_artifact_not_found(self):
"""Test that _publish_properties raises NotFoundError if artifact is
@@ -867,7 +873,8 @@ class TestCraftPublishingJob(TestCaseWithFactory):
artifact = self._artifactory_search("repository", "artifact.file")
self.assertEqual(artifact["properties"]["soss.license"], "unknown")
self.assertEqual(
- artifact["properties"].get("launchpad.channel"), "unknown/stable"
+ artifact["properties"].get("launchpad.channel"),
+ "noble:unknown/stable",
)
def test__publish_properties_no_license_in_metadata_yaml(self):
@@ -912,7 +919,8 @@ class TestCraftPublishingJob(TestCaseWithFactory):
artifact = self._artifactory_search("repository", "artifact.file")
self.assertEqual(artifact["properties"]["soss.license"], "unknown")
self.assertEqual(
- artifact["properties"].get("launchpad.channel"), "unknown/stable"
+ artifact["properties"].get("launchpad.channel"),
+ "noble:unknown/stable",
)
def test__publish_properties_license_from_metadata_yaml(self):
@@ -958,7 +966,8 @@ class TestCraftPublishingJob(TestCaseWithFactory):
artifact = self._artifactory_search("repository", "artifact.file")
self.assertEqual(artifact["properties"]["soss.license"], license_value)
self.assertEqual(
- artifact["properties"].get("launchpad.channel"), "0.1.0/stable"
+ artifact["properties"].get("launchpad.channel"),
+ "noble:0.1.0/stable",
)
def test__publish_properties_git_repository_source_url(self):
Follow ups