launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #31753
[Merge] ~pelpsi/launchpad-buildd:propagate-launchpad-context-to-the-builders into launchpad-buildd:master
Simone Pelosi has proposed merging ~pelpsi/launchpad-buildd:propagate-launchpad-context-to-the-builders into launchpad-buildd:master.
Commit message:
Builders should be aware of the Launchpad context
Propagate the launchpad context to the builders,
LAUNCHPAD_INSTANCE and LAUNCHPAD_SERVER_URL env variables
populated for craft, rock, snap builds.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/475537
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pelpsi/launchpad-buildd:propagate-launchpad-context-to-the-builders into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 07dbbda..39686e9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+launchpad-buildd (246) UNRELEASED; urgency=medium
+
+ * Propagate the launchpad context to the builders,
+ LAUNCHPAD_INSTANCE and LAUNCHPAD_SERVER_URL env variables
+ populated for craft, rock, snap builds.
+
+ -- Simone Pelosi <simone.pelosi@xxxxxxxxxxxxx> Mon, 21 Oct 2024 18:09:43 +0200
+
launchpad-buildd (245) focal; urgency=medium
* Shallow git clone when fetch-service enabled.
diff --git a/lpbuildd/craft.py b/lpbuildd/craft.py
index cb4523a..407959f 100644
--- a/lpbuildd/craft.py
+++ b/lpbuildd/craft.py
@@ -35,6 +35,8 @@ class CraftBuildManager(BuildManagerProxyMixin, DebianBuildManager):
# currently only used to transport the mitm certificate
self.secrets = extra_args.get("secrets")
self.use_fetch_service = extra_args.get("use_fetch_service")
+ self.launchpad_instance = extra_args.get("launchpad_instance")
+ self.launchpad_server_url = extra_args.get("launchpad_server_url")
self.proxy_service = None
super().initiate(files, chroot, extra_args)
@@ -63,6 +65,10 @@ class CraftBuildManager(BuildManagerProxyMixin, DebianBuildManager):
self.secrets["fetch_service_mitm_certificate"],
]
)
+ if self.launchpad_instance:
+ args.extend(["--launchpad-instance", self.launchpad_instance])
+ if self.launchpad_server_url:
+ args.extend(["--launchpad-server-url", self.launchpad_server_url])
args.append(self.name)
self.runTargetSubProcess("build-craft", *args)
diff --git a/lpbuildd/rock.py b/lpbuildd/rock.py
index bf68348..ac38b4f 100644
--- a/lpbuildd/rock.py
+++ b/lpbuildd/rock.py
@@ -35,6 +35,8 @@ class RockBuildManager(BuildManagerProxyMixin, DebianBuildManager):
# currently only used to transport the mitm certificate
self.secrets = extra_args.get("secrets")
self.use_fetch_service = extra_args.get("use_fetch_service")
+ self.launchpad_instance = extra_args.get("launchpad_instance")
+ self.launchpad_server_url = extra_args.get("launchpad_server_url")
self.proxy_service = None
super().initiate(files, chroot, extra_args)
@@ -63,6 +65,10 @@ class RockBuildManager(BuildManagerProxyMixin, DebianBuildManager):
self.secrets["fetch_service_mitm_certificate"],
]
)
+ if self.launchpad_instance:
+ args.extend(["--launchpad-instance", self.launchpad_instance])
+ if self.launchpad_server_url:
+ args.extend(["--launchpad-server-url", self.launchpad_server_url])
args.append(self.name)
self.runTargetSubProcess("build-rock", *args)
diff --git a/lpbuildd/snap.py b/lpbuildd/snap.py
index af4d165..60b8921 100644
--- a/lpbuildd/snap.py
+++ b/lpbuildd/snap.py
@@ -39,6 +39,8 @@ class SnapBuildManager(BuildManagerProxyMixin, DebianBuildManager):
self.git_repository = extra_args.get("git_repository")
self.git_path = extra_args.get("git_path")
self.use_fetch_service = extra_args.get("use_fetch_service")
+ self.launchpad_instance = extra_args.get("launchpad_instance")
+ self.launchpad_server_url = extra_args.get("launchpad_server_url")
self.proxy_url = extra_args.get("proxy_url")
# currently only used to transport the mitm certificate
self.secrets = extra_args.get("secrets")
@@ -114,6 +116,10 @@ class SnapBuildManager(BuildManagerProxyMixin, DebianBuildManager):
self.secrets["fetch_service_mitm_certificate"],
]
)
+ if self.launchpad_instance:
+ args.extend(["--launchpad-instance", self.launchpad_instance])
+ if self.launchpad_server_url:
+ args.extend(["--launchpad-server-url", self.launchpad_server_url])
args.append(self.name)
self.runTargetSubProcess("buildsnap", *args)
diff --git a/lpbuildd/target/build_craft.py b/lpbuildd/target/build_craft.py
index d6bfb89..97b9ad0 100644
--- a/lpbuildd/target/build_craft.py
+++ b/lpbuildd/target/build_craft.py
@@ -55,6 +55,16 @@ class BuildCraft(
type=str,
help="content of the ca certificate",
)
+ parser.add_argument(
+ "--launchpad_instance",
+ type=str,
+ help="Launchpad instance.",
+ )
+ parser.add_argument(
+ "--launchpad_server_url",
+ type=str,
+ help="launchpad server url.",
+ )
def __init__(self, args, parser):
super().__init__(args, parser)
@@ -150,6 +160,10 @@ class BuildCraft(
proxy_url=self.args.proxy_url,
use_fetch_service=self.args.use_fetch_service,
)
+ if self.args.launchpad_instance:
+ env["LAUNCHPAD_INSTANCE"] = self.args.launchpad_instance
+ if self.args.launchpad_server_url:
+ env["LAUNCHPAD_SERVER_URL"] = self.args.launchpad_server_url
args = ["sourcecraft", "pack", "-v", "--destructive-mode"]
self.run_build_command(args, env=env, cwd=build_context_path)
diff --git a/lpbuildd/target/build_rock.py b/lpbuildd/target/build_rock.py
index 92208b3..422926f 100644
--- a/lpbuildd/target/build_rock.py
+++ b/lpbuildd/target/build_rock.py
@@ -48,6 +48,16 @@ class BuildRock(
type=str,
help="content of the ca certificate",
)
+ parser.add_argument(
+ "--launchpad_instance",
+ type=str,
+ help="Launchpad instance.",
+ )
+ parser.add_argument(
+ "--launchpad_server_url",
+ type=str,
+ help="launchpad server url.",
+ )
def __init__(self, args, parser):
super().__init__(args, parser)
@@ -146,6 +156,10 @@ class BuildRock(
proxy_url=self.args.proxy_url,
use_fetch_service=self.args.use_fetch_service,
)
+ if self.args.launchpad_instance:
+ env["LAUNCHPAD_INSTANCE"] = self.args.launchpad_instance
+ if self.args.launchpad_server_url:
+ env["LAUNCHPAD_SERVER_URL"] = self.args.launchpad_server_url
args = ["rockcraft", "pack", "-v", "--destructive-mode"]
self.run_build_command(args, env=env, cwd=build_context_path)
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index cd2e20a..e9e78d5 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -111,6 +111,16 @@ class BuildSnap(
type=str,
help="content of the ca certificate",
)
+ parser.add_argument(
+ "--launchpad_instance",
+ type=str,
+ help="Launchpad instance.",
+ )
+ parser.add_argument(
+ "--launchpad_server_url",
+ type=str,
+ help="launchpad server url.",
+ )
parser.add_argument("name", help="name of snap to build")
def install(self):
@@ -209,6 +219,10 @@ class BuildSnap(
proxy_url=self.args.proxy_url,
use_fetch_service=self.args.use_fetch_service,
)
+ if self.args.launchpad_instance:
+ env["LAUNCHPAD_INSTANCE"] = self.args.launchpad_instance
+ if self.args.launchpad_server_url:
+ env["LAUNCHPAD_SERVER_URL"] = self.args.launchpad_server_url
env["SNAPCRAFT_LOCAL_SOURCES"] = "1"
env["SNAPCRAFT_SETUP_CORE"] = "1"
if not self.args.private:
@@ -258,6 +272,10 @@ class BuildSnap(
proxy_url=self.args.proxy_url,
use_fetch_service=self.args.use_fetch_service,
)
+ if self.args.launchpad_instance:
+ env["LAUNCHPAD_INSTANCE"] = self.args.launchpad_instance
+ if self.args.launchpad_server_url:
+ env["LAUNCHPAD_SERVER_URL"] = self.args.launchpad_server_url
if not self.args.private:
env["SNAPCRAFT_BUILD_INFO"] = "1"
env["SNAPCRAFT_IMAGE_INFO"] = self.image_info
diff --git a/lpbuildd/target/tests/test_build_craft.py b/lpbuildd/target/tests/test_build_craft.py
index 3d0edee..f308244 100644
--- a/lpbuildd/target/tests/test_build_craft.py
+++ b/lpbuildd/target/tests/test_build_craft.py
@@ -893,6 +893,36 @@ class TestBuildCraft(TestCase):
),
)
+ def test_build_with_launchpad_instance(self):
+ args = [
+ "build-craft",
+ "--backend=fake",
+ "--series=xenial",
+ "--arch=amd64",
+ "1",
+ "--branch",
+ "lp:foo",
+ "test-image",
+ "--launchpad_server_url=launchpad.test",
+ "--launchpad_instance=devel",
+ ]
+ build_craft = parse_args(args=args).operation
+ build_craft.backend.add_dir("/build/test-directory")
+ build_craft.build()
+ self.assertThat(
+ build_craft.backend.run.calls,
+ MatchesListwise(
+ [
+ RanBuildCommand(
+ ["sourcecraft", "pack", "-v", "--destructive-mode"],
+ cwd="/home/buildd/test-image/.",
+ LAUNCHPAD_INSTANCE="devel",
+ LAUNCHPAD_SERVER_URL="launchpad.test",
+ ),
+ ]
+ ),
+ )
+
def test_build_with_path(self):
args = [
"build-craft",
diff --git a/lpbuildd/target/tests/test_build_rock.py b/lpbuildd/target/tests/test_build_rock.py
index 4cc1555..cdea942 100644
--- a/lpbuildd/target/tests/test_build_rock.py
+++ b/lpbuildd/target/tests/test_build_rock.py
@@ -894,6 +894,36 @@ class TestBuildRock(TestCase):
),
)
+ def test_build_with_launchpad_instance(self):
+ args = [
+ "build-rock",
+ "--backend=fake",
+ "--series=xenial",
+ "--arch=amd64",
+ "1",
+ "--branch",
+ "lp:foo",
+ "test-image",
+ "--launchpad_server_url=launchpad.test",
+ "--launchpad_instance=devel",
+ ]
+ build_rock = parse_args(args=args).operation
+ build_rock.backend.run = FakeRevisionID("42")
+ build_rock.build()
+ self.assertThat(
+ build_rock.backend.run.calls,
+ MatchesListwise(
+ [
+ RanBuildCommand(
+ ["rockcraft", "pack", "-v", "--destructive-mode"],
+ cwd="/home/buildd/test-image/.",
+ LAUNCHPAD_INSTANCE="devel",
+ LAUNCHPAD_SERVER_URL="launchpad.test",
+ ),
+ ]
+ ),
+ )
+
def test_build_with_path(self):
args = [
"build-rock",
diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py
index 5c721f9..e469cdf 100644
--- a/lpbuildd/target/tests/test_build_snap.py
+++ b/lpbuildd/target/tests/test_build_snap.py
@@ -834,6 +834,51 @@ class TestBuildSnap(TestCase):
),
)
+ def test_pull_with_launchpad_instance(self):
+ args = [
+ "buildsnap",
+ "--backend=fake",
+ "--series=xenial",
+ "--arch=amd64",
+ "1",
+ "--build-url",
+ "https://launchpad.example/build",
+ "--branch",
+ "lp:foo",
+ "--proxy-url",
+ "http://proxy.example:3128/",
+ "test-snap",
+ "--launchpad_server_url=launchpad.test",
+ "--launchpad_instance=devel",
+ ]
+ build_snap = parse_args(args=args).operation
+ build_snap.pull()
+ env = {
+ "SNAPCRAFT_LOCAL_SOURCES": "1",
+ "SNAPCRAFT_SETUP_CORE": "1",
+ "SNAPCRAFT_BUILD_INFO": "1",
+ "SNAPCRAFT_IMAGE_INFO": (
+ '{"build_url": "https://launchpad.example/build"}'
+ ),
+ "SNAPCRAFT_BUILD_ENVIRONMENT": "host",
+ "http_proxy": "http://proxy.example:3128/",
+ "https_proxy": "http://proxy.example:3128/",
+ "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy",
+ "SNAPPY_STORE_NO_CDN": "1",
+ "LAUNCHPAD_INSTANCE": "devel",
+ "LAUNCHPAD_SERVER_URL": "launchpad.test",
+ }
+ self.assertThat(
+ build_snap.backend.run.calls,
+ MatchesListwise(
+ [
+ RanBuildCommand(
+ ["snapcraft", "pull"], cwd="/build/test-snap", **env
+ ),
+ ]
+ ),
+ )
+
def test_pull_proxy(self):
args = [
"buildsnap",
@@ -1045,6 +1090,45 @@ class TestBuildSnap(TestCase):
),
)
+ def test_build_with_launchpad_instance(self):
+ args = [
+ "buildsnap",
+ "--backend=fake",
+ "--series=xenial",
+ "--arch=amd64",
+ "1",
+ "--branch",
+ "lp:foo",
+ "test-snap",
+ "--launchpad_server_url=launchpad.test",
+ "--launchpad_instance=devel",
+ ]
+ build_snap = parse_args(args=args).operation
+ build_snap.backend.run = FakeSnapcraft(
+ build_snap.backend, "test-snap_1.snap"
+ )
+ build_snap.build()
+ self.assertThat(
+ build_snap.backend.run.calls,
+ MatchesListwise(
+ [
+ RanBuildCommand(
+ ["snapcraft"],
+ cwd="/build/test-snap",
+ SNAPCRAFT_BUILD_INFO="1",
+ SNAPCRAFT_IMAGE_INFO="{}",
+ SNAPCRAFT_BUILD_ENVIRONMENT="host",
+ LAUNCHPAD_INSTANCE="devel",
+ LAUNCHPAD_SERVER_URL="launchpad.test",
+ ),
+ RanBuildCommand(
+ ["sha512sum", "test-snap_1.snap"],
+ cwd="/build/test-snap",
+ ),
+ ]
+ ),
+ )
+
def test_build_proxy(self):
args = [
"buildsnap",
diff --git a/lpbuildd/tests/test_craft.py b/lpbuildd/tests/test_craft.py
index 723641f..9f910cf 100644
--- a/lpbuildd/tests/test_craft.py
+++ b/lpbuildd/tests/test_craft.py
@@ -254,3 +254,18 @@ class TestCraftBuildManagerIteration(TestCase):
"content_of_cert",
]
yield self.startBuild(args, expected_options)
+
+ @defer.inlineCallbacks
+ def test_iterate_launchpad_url_and_instance(self):
+ # The builder should be aware of the launchpad context.
+ args = {
+ "launchpad_instance": "devel",
+ "launchpad_server_url": "launchpad.test",
+ }
+ expected_options = [
+ "--launchpad_instance",
+ "devel",
+ "--launchpad_server_url",
+ "launchpad.test",
+ ]
+ yield self.startBuild(args, expected_options)
diff --git a/lpbuildd/tests/test_rock.py b/lpbuildd/tests/test_rock.py
index d4f8ad3..bf55da5 100644
--- a/lpbuildd/tests/test_rock.py
+++ b/lpbuildd/tests/test_rock.py
@@ -253,3 +253,18 @@ class TestRockBuildManagerIteration(TestCase):
"content_of_cert",
]
yield self.startBuild(args, expected_options)
+
+ @defer.inlineCallbacks
+ def test_iterate_launchpad_url_and_instance(self):
+ # The builder should be aware of the launchpad context.
+ args = {
+ "launchpad_instance": "devel",
+ "launchpad_server_url": "launchpad.test",
+ }
+ expected_options = [
+ "--launchpad_instance",
+ "devel",
+ "--launchpad_server_url",
+ "launchpad.test",
+ ]
+ yield self.startBuild(args, expected_options)
diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
index bf2adfa..ecde707 100644
--- a/lpbuildd/tests/test_snap.py
+++ b/lpbuildd/tests/test_snap.py
@@ -770,6 +770,21 @@ class TestSnapBuildManagerIteration(TestCase):
yield self.startBuild(args, expected_options)
@defer.inlineCallbacks
+ def test_iterate_launchpad_url_and_instance(self):
+ # The builder should be aware of the launchpad context.
+ args = {
+ "launchpad_instance": "devel",
+ "launchpad_server_url": "launchpad.test",
+ }
+ expected_options = [
+ "--launchpad_instance",
+ "devel",
+ "--launchpad_server_url",
+ "launchpad.test",
+ ]
+ yield self.startBuild(args, expected_options)
+
+ @defer.inlineCallbacks
def test_iterate_disable_proxy_after_pull(self):
self.builder._config.set("builder", "proxyport", "8222")
args = {