← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/lpcraft:always-update-repositories into lpcraft:main

 

Jürgen Gmach has proposed merging ~jugmac00/lpcraft:always-update-repositories into lpcraft:main.

Commit message:
Always update apt cache index

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/422126
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/lpcraft:always-update-repositories into lpcraft:main.
diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
index fc0c80c..106ac2f 100644
--- a/lpcraft/commands/run.py
+++ b/lpcraft/commands/run.py
@@ -278,24 +278,24 @@ def _run_job(
                         group="root",
                         user="root",
                     )
-                # update local repository information
-                apt_update = ["apt", "update"]
-                with emit.open_stream(f"Running {apt_update}") as stream:
-                    proc = instance.execute_run(
-                        apt_update,
-                        cwd=remote_cwd,
-                        env=environment,
-                        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} "
-                        f"while running `{shlex.join(apt_update)}`.",
-                        retcode=proc.returncode,
-                    )
+            # update local repository information
+            apt_update = ["apt", "update"]
+            with emit.open_stream(f"Running {apt_update}") as stream:
+                proc = instance.execute_run(
+                    apt_update,
+                    cwd=remote_cwd,
+                    env=environment,
+                    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} "
+                    f"while running `{shlex.join(apt_update)}`.",
+                    retcode=proc.returncode,
+                )
             packages_cmd = ["apt", "install", "-y"] + packages
             emit.progress("Installing system packages")
             with emit.open_stream(f"Running {packages_cmd}") as stream:
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index df96d69..f52a84b 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -6,7 +6,7 @@ import json
 import os
 import re
 import subprocess
-from pathlib import Path
+from pathlib import Path, PosixPath
 from textwrap import dedent
 from typing import Any, AnyStr, Dict, List, Optional
 from unittest.mock import ANY, Mock, call, patch
@@ -1530,6 +1530,13 @@ class TestRun(RunBaseTestCase):
         self.assertEqual(
             [
                 call(
+                    ["apt", "update"],
+                    cwd=PosixPath("/root/lpcraft/project"),
+                    env={},
+                    stdout=ANY,
+                    stderr=ANY,
+                ),
+                call(
                     [
                         "apt",
                         "install",
@@ -1584,8 +1591,8 @@ class TestRun(RunBaseTestCase):
         self.assertEqual(
             [
                 call(
-                    ["apt", "install", "-y", "unknown_package"],
-                    cwd=Path("/root/lpcraft/project"),
+                    ["apt", "update"],
+                    cwd=PosixPath("/root/lpcraft/project"),
                     env={},
                     stdout=ANY,
                     stderr=ANY,
diff --git a/lpcraft/plugin/tests/test_plugins.py b/lpcraft/plugin/tests/test_plugins.py
index dbdd2c2..cda49e4 100644
--- a/lpcraft/plugin/tests/test_plugins.py
+++ b/lpcraft/plugin/tests/test_plugins.py
@@ -51,6 +51,13 @@ class TestPlugins(CommandBaseTestCase):
         self.assertEqual(
             [
                 call(
+                    ["apt", "update"],
+                    cwd=PosixPath("/root/lpcraft/project"),
+                    env={"TOX_TESTENV_PASSENV": "http_proxy https_proxy"},
+                    stdout=ANY,
+                    stderr=ANY,
+                ),
+                call(
                     [
                         "apt",
                         "install",
@@ -143,6 +150,13 @@ class TestPlugins(CommandBaseTestCase):
         self.assertEqual(
             [
                 call(
+                    ["apt", "update"],
+                    cwd=PosixPath("/root/lpcraft/project"),
+                    env={"TOX_TESTENV_PASSENV": "http_proxy https_proxy"},
+                    stdout=ANY,
+                    stderr=ANY,
+                ),
+                call(
                     [
                         "apt",
                         "install",
@@ -196,6 +210,13 @@ class TestPlugins(CommandBaseTestCase):
         self.assertEqual(
             [
                 call(
+                    ["apt", "update"],
+                    cwd=PosixPath("/root/lpcraft/project"),
+                    env={},
+                    stdout=ANY,
+                    stderr=ANY,
+                ),
+                call(
                     [
                         "apt",
                         "install",

Follow ups