launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28600
[Merge] ~jugmac00/launchpad-buildd:add-support-for-conda-channels into launchpad-buildd:master
Jürgen Gmach has proposed merging ~jugmac00/launchpad-buildd:add-support-for-conda-channels into launchpad-buildd:master.
Commit message:
Add support for plugin settings for CI builds
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jugmac00/launchpad-buildd/+git/launchpad-buildd/+merge/424378
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad-buildd:add-support-for-conda-channels into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index a58d2b3..d3b9896 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,14 @@
launchpad-buildd (215) UNRELEASED; urgency=medium
+<<<<<<< debian/changelog
* Fix setup instructions for a development environment.
-- Jürgen Gmach <juergen.gmach@xxxxxxxxxxxxx> Tue, 14 Jun 2022 13:26:01 +0200
+=======
+ * Add support for plugin settings for CI builds.
+
+ -- Jürgen Gmach <juergen.gmach@xxxxxxxxxxxxx> Tue, 14 Jun 2022 11:41:34 +0200
+>>>>>>> debian/changelog
launchpad-buildd (214) focal; urgency=medium
diff --git a/lpbuildd/ci.py b/lpbuildd/ci.py
index 7b334d6..3119a09 100644
--- a/lpbuildd/ci.py
+++ b/lpbuildd/ci.py
@@ -60,6 +60,7 @@ class CIBuildManager(BuildManagerProxyMixin, DebianBuildManager):
self.job_status = {}
self.apt_repositories = extra_args.get("apt_repositories")
self.environment_variables = extra_args.get("environment_variables")
+ self.plugin_settings = extra_args.get("plugin_settings")
super().initiate(files, chroot, extra_args)
@@ -144,6 +145,10 @@ class CIBuildManager(BuildManagerProxyMixin, DebianBuildManager):
for key, value in self.environment_variables.items():
args.extend(
["--environment-variable", f"{key}={value}"])
+ if self.plugin_settings is not None:
+ for key, value in self.plugin_settings.items():
+ args.extend(
+ ["--plugin-setting", f"{key}={value}"])
job_name, job_index = self.current_job
self.current_job_id = _make_job_id(job_name, job_index)
args.extend([job_name, str(job_index)])
diff --git a/lpbuildd/target/run_ci.py b/lpbuildd/target/run_ci.py
index 5920346..a737994 100644
--- a/lpbuildd/target/run_ci.py
+++ b/lpbuildd/target/run_ci.py
@@ -108,6 +108,15 @@ class RunCI(BuilderProxyOperationMixin, Operation):
default=[],
help="single apt repository line",
)
+ parser.add_argument(
+ "--plugin-setting",
+ dest="plugin_settings",
+ type=str,
+ action="append",
+ default=[],
+ help="plugin setting where the key and value are separated by =",
+ )
+
def run_job(self):
logger.info("Running job phase...")
@@ -125,14 +134,23 @@ class RunCI(BuilderProxyOperationMixin, Operation):
self.args.job_name,
str(self.args.job_index),
]
+ for repository in self.args.apt_repositories:
+ lpcraft_args.extend(["--apt-replace-repositories", repository])
+
environment_variables = dict(
pair.split("=", maxsplit=1)
for pair in self.args.environment_variables
)
for key, value in environment_variables.items():
lpcraft_args.extend(["--set-env", "%s=%s" % (key, value)])
- for repository in self.args.apt_repositories:
- lpcraft_args.extend(["--apt-replace-repositories", repository])
+
+ plugin_settings = dict(
+ pair.split("=", maxsplit=1)
+ for pair in self.args.plugin_settings
+ )
+ for key, value in plugin_settings.items():
+ lpcraft_args.extend(["--plugin-setting", "%s=%s" % (key, value)])
+
escaped_lpcraft_args = (
" ".join(shell_escape(arg) for arg in lpcraft_args))
tee_args = ["tee", "%s.log" % output_path]
diff --git a/lpbuildd/target/tests/test_run_ci.py b/lpbuildd/target/tests/test_run_ci.py
index 1ee07a5..fe52b3e 100644
--- a/lpbuildd/target/tests/test_run_ci.py
+++ b/lpbuildd/target/tests/test_run_ci.py
@@ -396,6 +396,29 @@ class TestRunCI(TestCase):
], cwd="/build/tree"),
]))
+ def test_run_job_with_plugin_settings(self):
+ args = [
+ "run-ci",
+ "--backend=fake", "--series=focal", "--arch=amd64", "1",
+ "test", "0",
+ "--plugin-setting",
+ "miniconda_conda_channel=https://user:pass@xxxxxxxxxxxxxxxxxxxxx/artifactory/soss-conda-stable-local/", # noqa: E501
+ ]
+ run_ci = parse_args(args=args).operation
+ run_ci.run_job()
+ self.assertThat(run_ci.backend.run.calls, MatchesListwise([
+ RanCommand(["mkdir", "-p", "/build/output/test:0"]),
+ RanBuildCommand([
+ "/bin/bash", "-o", "pipefail", "-c",
+ "lpcraft -v run-one --output-directory /build/output/test:0 "
+ "test 0 "
+ "--plugin-setting "
+ "miniconda_conda_channel=https://user:pass@xxxxxxxxxxxxxxxxxxxxx/artifactory/soss-conda-stable-local/ "
+ "2>&1 "
+ "| tee /build/output/test:0.log",
+ ], cwd="/build/tree"),
+ ]))
+
def test_run_succeeds(self):
args = [
"run-ci",
diff --git a/lpbuildd/tests/test_ci.py b/lpbuildd/tests/test_ci.py
index 7aea827..ae3d665 100644
--- a/lpbuildd/tests/test_ci.py
+++ b/lpbuildd/tests/test_ci.py
@@ -122,7 +122,11 @@ class TestCIBuildManagerIteration(TestCase):
"apt_repositories": ["repository one", "repository two"],
"environment_variables": {
"INDEX": "http://example.com", "PATH": "foo"},
- }
+ "plugin_settings" :{
+ "miniconda_conda_channel": "https://user:pass@xxxxxxxxxxxxxxxxxxxxx/artifactory/soss-conda-stable-local/",
+ "foo": "bar",
+ },
+ }
expected_prepare_options = [
"--git-repository", "https://git.launchpad.test/~example/+git/ci",
"--git-path", "main",
@@ -135,6 +139,8 @@ class TestCIBuildManagerIteration(TestCase):
"--apt-repository", "repository two",
"--environment-variable", "INDEX=http://example.com",
"--environment-variable", "PATH=foo",
+ "--plugin-setting", "miniconda_conda_channel=https://user:pass@xxxxxxxxxxxxxxxxxxxxx/artifactory/soss-conda-stable-local/",
+ "--plugin-setting", "foo=bar",
]
yield self.expectRunJob("build", "0", options=expected_job_options)
self.buildmanager.backend.add_file(
@@ -247,7 +253,11 @@ class TestCIBuildManagerIteration(TestCase):
"apt_repositories": ["repository one", "repository two"],
"environment_variables": {
"INDEX": "http://example.com", "PATH": "foo"},
- }
+ "plugin_settings" :{
+ "miniconda_conda_channel": "https://user:pass@xxxxxxxxxxxxxxxxxxxxx/artifactory/soss-conda-stable-local/",
+ "foo": "bar",
+ },
+ }
expected_prepare_options = [
"--git-repository", "https://git.launchpad.test/~example/+git/ci",
"--git-path", "main",
@@ -260,6 +270,8 @@ class TestCIBuildManagerIteration(TestCase):
"--apt-repository", "repository two",
"--environment-variable", "INDEX=http://example.com",
"--environment-variable", "PATH=foo",
+ "--plugin-setting", "miniconda_conda_channel=https://user:pass@xxxxxxxxxxxxxxxxxxxxx/artifactory/soss-conda-stable-local/",
+ "--plugin-setting", "foo=bar",
]
yield self.expectRunJob("lint", "0", options=expected_job_options)
self.buildmanager.backend.add_file(