launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28162
[Merge] ~jugmac00/lpcraft:do-not-hide-package-installation-error into lpcraft:main
Jürgen Gmach has proposed merging ~jugmac00/lpcraft:do-not-hide-package-installation-error into lpcraft:main.
Commit message:
Do not hide system package installation errors
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/415982
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/lpcraft:do-not-hide-package-installation-error into lpcraft:main.
diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
index 91fa7a1..7cb583d 100644
--- a/lpcraft/commands/run.py
+++ b/lpcraft/commands/run.py
@@ -231,6 +231,13 @@ def _run_job(
stdout=stream,
stderr=stream,
)
+ if proc.returncode != 0:
+ raise CommandError(
+ f"Job {job_name!r} for "
+ f"{job.series}/{host_architecture} failed with "
+ f"exit status {proc.returncode}.",
+ retcode=proc.returncode,
+ )
full_run_cmd = ["bash", "--noprofile", "--norc", "-ec", run_command]
emit.progress("Running the job")
original_mode = emit.get_mode()
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index 4fae0e0..afc2796 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -1259,6 +1259,47 @@ class TestRun(RunBaseTestCase):
@patch("lpcraft.commands.run.get_provider")
@patch("lpcraft.commands.run.get_host_architecture", return_value="amd64")
+ def test_installing_unknown_system_package_fails(
+ self, mock_get_host_architecture, mock_get_provider
+ ):
+ launcher = Mock(spec=launch)
+ provider = self.makeLXDProvider(lxd_launcher=launcher)
+ mock_get_provider.return_value = provider
+ execute_run = launcher.return_value.execute_run
+ execute_run.return_value = subprocess.CompletedProcess([], 100)
+ config = dedent(
+ """
+ pipeline:
+ - test
+
+ jobs:
+ test:
+ series: focal
+ architectures: amd64
+ run: ls -la
+ packages: [unknown_package]
+ """
+ )
+ Path(".launchpad.yaml").write_text(config)
+
+ result = self.run_command("run")
+
+ self.assertEqual(100, result.exit_code)
+ self.assertEqual(
+ [
+ call(
+ ["apt", "install", "-y", "unknown_package"],
+ cwd=Path("/root/project"),
+ env={},
+ stdout=ANY,
+ stderr=ANY,
+ )
+ ],
+ execute_run.call_args_list,
+ )
+
+ @patch("lpcraft.commands.run.get_provider")
+ @patch("lpcraft.commands.run.get_host_architecture", return_value="amd64")
@patch("sys.stderr", new_callable=io.StringIO)
def test_quiet(
self, mock_stderr, mock_get_host_architecture, mock_get_provider