launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28921
[Merge] ~cjwatson/lpcraft:craft-providers-1.3.1 into lpcraft:main
Colin Watson has proposed merging ~cjwatson/lpcraft:craft-providers-1.3.1 into lpcraft:main.
Commit message:
Upgrade to craft-providers 1.3.1
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/lpcraft/+git/lpcraft/+merge/427613
This includes a refactoring of snap installation logic, which reduces dependencies on tools available on the host system.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lpcraft:craft-providers-1.3.1 into lpcraft:main.
diff --git a/NEWS.rst b/NEWS.rst
index 1798ef9..eb07d27 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,11 @@
Version history
===============
+0.0.22
+======
+
+- Upgrade to craft-providers 1.3.1, improving snap installation logic.
+
0.0.21 (2022-07-19)
===================
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index ddb521b..5ff89f9 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -1414,25 +1414,22 @@ class TestRun(RunBaseTestCase):
def test_install_snaps(
self, mock_get_host_architecture, mock_get_provider
):
+ def run_side_effect(
+ command: List[str], **kwargs: Any
+ ) -> "subprocess.CompletedProcess[bytes]":
+ if command[0] == "curl":
+ response = {"result": {"revision": "1"}, "status-code": 200}
+ return subprocess.CompletedProcess(
+ [], 0, stdout=json.dumps(response).encode()
+ )
+ else:
+ return subprocess.CompletedProcess([], 0)
+
launcher = Mock(spec=launch)
provider = makeLXDProvider(lxd_launcher=launcher)
mock_get_provider.return_value = provider
execute_run = launcher.return_value.execute_run
- execute_run.return_value = subprocess.CompletedProcess([], 0)
- responses.add(
- "GET",
- "http+unix://%2Frun%2Fsnapd.socket/v2/find?name=chromium",
- json={
- "result": [{"channels": {"latest/stable": {"revision": "1"}}}]
- },
- )
- responses.add(
- "GET",
- "http+unix://%2Frun%2Fsnapd.socket/v2/find?name=firefox",
- json={
- "result": [{"channels": {"latest/stable": {"revision": "1"}}}]
- },
- )
+ execute_run.side_effect = run_side_effect
config = dedent(
"""
pipeline:
@@ -1456,22 +1453,22 @@ class TestRun(RunBaseTestCase):
call(
[
"snap",
- "download",
+ "install",
"chromium",
- "--channel=latest/stable",
- "--basename=chromium",
- "--target-directory=/tmp",
+ "--channel",
+ "latest/stable",
+ "--classic",
],
check=True,
capture_output=True,
),
call(
[
- "snap",
- "install",
- "/tmp/chromium.snap",
- "--classic",
- "--dangerous",
+ "curl",
+ "--silent",
+ "--unix-socket",
+ "/run/snapd.socket",
+ "http://localhost/v2/snaps/chromium",
],
check=True,
capture_output=True,
@@ -1479,22 +1476,22 @@ class TestRun(RunBaseTestCase):
call(
[
"snap",
- "download",
+ "install",
"firefox",
- "--channel=latest/stable",
- "--basename=firefox",
- "--target-directory=/tmp",
+ "--channel",
+ "latest/stable",
+ "--classic",
],
check=True,
capture_output=True,
),
call(
[
- "snap",
- "install",
- "/tmp/firefox.snap",
- "--classic",
- "--dangerous",
+ "curl",
+ "--silent",
+ "--unix-socket",
+ "/run/snapd.socket",
+ "http://localhost/v2/snaps/firefox",
],
check=True,
capture_output=True,
diff --git a/requirements.txt b/requirements.txt
index a561f68..c36076e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,7 +10,7 @@ charset-normalizer==2.0.12
# via requests
craft-cli==0.6.0
# via -r requirements.in
-craft-providers==1.2.0
+craft-providers==1.3.1
# via -r requirements.in
idna==3.3
# via requests