launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28757
[Merge] ~andrey-fedoseev/launchpad:snap-target-architectures into launchpad:master
Andrey Fedoseev has proposed merging ~andrey-fedoseev/launchpad:snap-target-architectures into launchpad:master.
Commit message:
Replace `build-to` with `build-for`
according to the new `snapcraft.yaml` specification
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/426570
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~andrey-fedoseev/launchpad:snap-target-architectures into launchpad:master.
diff --git a/lib/lp/snappy/adapters/buildarch.py b/lib/lp/snappy/adapters/buildarch.py
index 87f7b3d..3e1ea75 100644
--- a/lib/lp/snappy/adapters/buildarch.py
+++ b/lib/lp/snappy/adapters/buildarch.py
@@ -66,14 +66,14 @@ class SnapArchitecture:
def __init__(
self,
build_on: Union[str, List[str]],
- build_to: Optional[Union[str, List[str]]] = None,
+ build_for: Optional[Union[str, List[str]]] = None,
build_error: Optional[str] = None
):
"""Create a new architecture entry.
:param build_on: string or list; build-on property from
snapcraft.yaml.
- :param build_to: string or list; build-to property from
+ :param build_for: string or list; build-for property from
snapcraft.yaml (defaults to build_on).
:param build_error: string; build-error property from
snapcraft.yaml.
@@ -81,12 +81,12 @@ class SnapArchitecture:
self.build_on = (
[build_on] if isinstance(build_on, str) else build_on
) # type: List[str]
- if build_to:
- self.build_to = (
- [build_to] if isinstance(build_to, str) else build_to
+ if build_for:
+ self.build_for = (
+ [build_for] if isinstance(build_for, str) else build_for
) # type: List[str]
else:
- self.build_to = self.build_on
+ self.build_for = self.build_on
self.build_error = build_error
@classmethod
@@ -97,11 +97,11 @@ class SnapArchitecture:
except KeyError:
raise MissingPropertyError("build-on")
- build_to = properties.get("build-to", properties.get("run-on"))
+ build_for = properties.get("build-for", properties.get("run-on"))
return cls(
build_on=build_on,
- build_to=build_to,
+ build_for=build_for,
build_error=properties.get("build-error"),
)
@@ -138,7 +138,7 @@ class SnapBuildInstance:
except StopIteration:
raise UnsupportedBuildOnError(architecture.build_on)
- self.target_architectures = architecture.build_to
+ self.target_architectures = architecture.build_for
self.required = architecture.build_error != "ignore"
diff --git a/lib/lp/snappy/adapters/tests/test_buildarch.py b/lib/lp/snappy/adapters/tests/test_buildarch.py
index b3018ed..2f1610f 100644
--- a/lib/lp/snappy/adapters/tests/test_buildarch.py
+++ b/lib/lp/snappy/adapters/tests/test_buildarch.py
@@ -20,42 +20,42 @@ class TestSnapArchitecture(WithScenarios, TestCase):
scenarios = [
("lists", {
- "architectures": {"build-on": ["amd64"], "build-to": ["amd64"]},
+ "architectures": {"build-on": ["amd64"], "build-for": ["amd64"]},
"expected_build_on": ["amd64"],
- "expected_build_to": ["amd64"],
+ "expected_build_for": ["amd64"],
"expected_build_error": None,
}),
("strings", {
- "architectures": {"build-on": "amd64", "build-to": "amd64"},
+ "architectures": {"build-on": "amd64", "build-for": "amd64"},
"expected_build_on": ["amd64"],
- "expected_build_to": ["amd64"],
+ "expected_build_for": ["amd64"],
"expected_build_error": None,
}),
- ("no build-to", {
+ ("no build-for", {
"architectures": {"build-on": ["amd64"]},
"expected_build_on": ["amd64"],
- "expected_build_to": ["amd64"],
+ "expected_build_for": ["amd64"],
"expected_build_error": None,
}),
("not required", {
"architectures": {
"build-on": ["amd64"],
- "build-to": "amd64",
+ "build-for": "amd64",
"build-error": "ignore"},
"expected_build_on": ["amd64"],
- "expected_build_to": ["amd64"],
+ "expected_build_for": ["amd64"],
"expected_build_error": "ignore",
}),
- ("build-to", {
- "architectures": {"build-on": ["amd64"], "build-to": "all"},
+ ("build-for", {
+ "architectures": {"build-on": ["amd64"], "build-for": "all"},
"expected_build_on": ["amd64"],
- "expected_build_to": ["all"],
+ "expected_build_for": ["all"],
"expected_build_error": None,
}),
("run-on", {
"architectures": {"build-on": ["amd64"], "run-on": "all"},
"expected_build_on": ["amd64"],
- "expected_build_to": ["all"],
+ "expected_build_for": ["all"],
"expected_build_error": None,
}),
]
@@ -63,7 +63,7 @@ class TestSnapArchitecture(WithScenarios, TestCase):
def test_architecture(self):
architecture = SnapArchitecture.from_dict(self.architectures)
self.assertEqual(self.expected_build_on, architecture.build_on)
- self.assertEqual(self.expected_build_to, architecture.build_to)
+ self.assertEqual(self.expected_build_for, architecture.build_for)
self.assertEqual(self.expected_build_error, architecture.build_error)
@@ -74,14 +74,16 @@ class TestSnapBuildInstance(WithScenarios, TestCase):
scenarios = [
("i386", {
"architecture": SnapArchitecture(
- build_on="i386", build_to=["amd64", "i386"]),
+ build_on="i386", build_for=["amd64", "i386"]),
"supported_architectures": ["amd64", "i386", "armhf"],
"expected_architecture": "i386",
"expected_target_architectures": ["amd64", "i386"],
"expected_required": True,
}),
("amd64", {
- "architecture": SnapArchitecture(build_on="amd64", build_to="all"),
+ "architecture": SnapArchitecture(
+ build_on="amd64", build_for="all"
+ ),
"supported_architectures": ["amd64", "i386", "armhf"],
"expected_architecture": "amd64",
"expected_target_architectures": ["all"],
@@ -89,7 +91,7 @@ class TestSnapBuildInstance(WithScenarios, TestCase):
}),
("amd64 priority", {
"architecture": SnapArchitecture(
- build_on=["amd64", "i386"], build_to="all"),
+ build_on=["amd64", "i386"], build_for="all"),
"supported_architectures": ["amd64", "i386", "armhf"],
"expected_architecture": "amd64",
"expected_target_architectures": ["all"],
@@ -97,7 +99,7 @@ class TestSnapBuildInstance(WithScenarios, TestCase):
}),
("i386 priority", {
"architecture": SnapArchitecture(
- build_on=["amd64", "i386"], build_to="all"),
+ build_on=["amd64", "i386"], build_for="all"),
"supported_architectures": ["i386", "amd64", "armhf"],
"expected_architecture": "i386",
"expected_target_architectures": ["all"],
@@ -125,7 +127,7 @@ class TestSnapBuildInstance(WithScenarios, TestCase):
class TestSnapBuildInstanceError(TestCase):
def test_no_matching_arch_raises(self):
- architecture = SnapArchitecture(build_on="amd64", build_to="amd64")
+ architecture = SnapArchitecture(build_on="amd64", build_for="amd64")
raised = self.assertRaises(
UnsupportedBuildOnError, SnapBuildInstance, architecture, ["i386"])
self.assertEqual(["amd64"], raised.build_on)
@@ -160,7 +162,7 @@ class TestDetermineArchitecturesToBuild(WithScenarios, TestCase):
}),
("i386", {
"architectures": [
- {"build-on": "i386", "build-to": ["amd64", "i386"]},
+ {"build-on": "i386", "build-for": ["amd64", "i386"]},
],
"supported_architectures": ["amd64", "i386", "armhf"],
"expected": [
@@ -172,7 +174,7 @@ class TestDetermineArchitecturesToBuild(WithScenarios, TestCase):
],
}),
("amd64", {
- "architectures": [{"build-on": "amd64", "build-to": "all"}],
+ "architectures": [{"build-on": "amd64", "build-for": "all"}],
"supported_architectures": ["amd64", "i386", "armhf"],
"expected": [
{
@@ -184,8 +186,8 @@ class TestDetermineArchitecturesToBuild(WithScenarios, TestCase):
}),
("amd64 and i386", {
"architectures": [
- {"build-on": "amd64", "build-to": "amd64"},
- {"build-on": "i386", "build-to": "i386"},
+ {"build-on": "amd64", "build-for": "amd64"},
+ {"build-on": "i386", "build-for": "i386"},
],
"supported_architectures": ["amd64", "i386", "armhf"],
"expected": [
@@ -222,11 +224,11 @@ class TestDetermineArchitecturesToBuild(WithScenarios, TestCase):
}),
("amd64, i386, and armhf", {
"architectures": [
- {"build-on": "amd64", "build-to": "amd64"},
- {"build-on": "i386", "build-to": "i386"},
+ {"build-on": "amd64", "build-for": "amd64"},
+ {"build-on": "i386", "build-for": "i386"},
{
"build-on": "armhf",
- "build-to": "armhf",
+ "build-for": "armhf",
"build-error": "ignore",
},
],
@@ -251,7 +253,7 @@ class TestDetermineArchitecturesToBuild(WithScenarios, TestCase):
}),
("amd64 priority", {
"architectures": [
- {"build-on": ["amd64", "i386"], "build-to": "all"},
+ {"build-on": ["amd64", "i386"], "build-for": "all"},
],
"supported_architectures": ["amd64", "i386", "armhf"],
"expected": [
@@ -264,7 +266,7 @@ class TestDetermineArchitecturesToBuild(WithScenarios, TestCase):
}),
("i386 priority", {
"architectures": [
- {"build-on": ["amd64", "i386"], "build-to": "all"},
+ {"build-on": ["amd64", "i386"], "build-for": "all"},
],
"supported_architectures": ["i386", "amd64", "armhf"],
"expected": [