← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:lpcraft-gpu-nvidia into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:lpcraft-gpu-nvidia into launchpad-buildd:master with ~cjwatson/launchpad-buildd:lxd-gpu-nvidia as a prerequisite.

Commit message:
Pass --gpu-nvidia to lpcraft if the gpu-nvidia constraint is given

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This relies on https://code.launchpad.net/~cjwatson/lpcraft/+git/lpcraft/+merge/435909.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:lpcraft-gpu-nvidia into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 6c2c622..7c250c9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,7 +6,7 @@ launchpad-buildd (226) UNRELEASED; urgency=medium
   * Remove the old "distroseries_name" argument from the sourcepackagerecipe
     manager, which duplicated the common "series" argument.
   * If the "gpu-nvidia" constraint is specified, then pass through an NVIDIA
-    GPU to the LXD container.
+    GPU to the LXD container, and pass the "--gpu-nvidia" option to lpcraft.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Wed, 04 Jan 2023 12:58:36 +0000
 
diff --git a/lpbuildd/target/run_ci.py b/lpbuildd/target/run_ci.py
index 28dc2e7..e75cdc9 100644
--- a/lpbuildd/target/run_ci.py
+++ b/lpbuildd/target/run_ci.py
@@ -197,6 +197,9 @@ class RunCI(BuilderProxyOperationMixin, Operation):
             lpcraft_args.extend(
                 ["--secrets", self.args.secrets])
 
+        if "gpu-nvidia" in self.backend.constraints:
+            lpcraft_args.append("--gpu-nvidia")
+
         escaped_lpcraft_args = (
             " ".join(shell_escape(arg) for arg in lpcraft_args))
         tee_args = ["tee", os.path.join(job_output_path, "log")]
diff --git a/lpbuildd/target/tests/test_run_ci.py b/lpbuildd/target/tests/test_run_ci.py
index c855eec..daee43f 100644
--- a/lpbuildd/target/tests/test_run_ci.py
+++ b/lpbuildd/target/tests/test_run_ci.py
@@ -552,6 +552,27 @@ class TestRunCI(TestCase):
         run_ci.backend.run = FailClamscan()
         self.assertRaises(subprocess.CalledProcessError, run_ci.run_job)
 
+    def test_run_job_gpu_nvidia(self):
+        args = [
+            "run-ci",
+            "--backend=fake", "--series=focal", "--arch=amd64",
+            "--constraint=gpu-nvidia", "1",
+            "test", "0",
+            ]
+        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 "
+                "--gpu-nvidia "
+                "2>&1 "
+                "| tee /build/output/test/0/log",
+                ], cwd="/build/tree"),
+            ]))
+
     def test_run_succeeds(self):
         args = [
             "run-ci",