launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28028
[Merge] ~cjwatson/launchpad:lpcraft-more-expand-architectures into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:lpcraft-more-expand-architectures into launchpad:master.
Commit message:
Fix expansion of lpcraft job.architectures
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/414762
To match lpcraft's behaviour, the `architectures` field of a job definition should be expanded into a list even if it occurs outside a job matrix.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:lpcraft-more-expand-architectures into launchpad:master.
diff --git a/lib/lp/code/model/lpcraft.py b/lib/lp/code/model/lpcraft.py
index 4f932f4..cf736e7 100644
--- a/lib/lp/code/model/lpcraft.py
+++ b/lib/lp/code/model/lpcraft.py
@@ -32,13 +32,16 @@ def _expand_job_values(values):
for variant in values["matrix"]:
variant_values = base_values.copy()
variant_values.update(variant)
- # normalize `architectures` into a list
- architectures = variant_values.get("architectures")
- if isinstance(architectures, str):
- variant_values["architectures"] = [architectures]
expanded_values.append(variant_values)
else:
expanded_values.append(values)
+
+ for variant_values in expanded_values:
+ # normalize `architectures` into a list
+ architectures = variant_values.get("architectures")
+ if isinstance(architectures, str):
+ variant_values["architectures"] = [architectures]
+
return expanded_values
diff --git a/lib/lp/code/model/tests/test_lpcraft.py b/lib/lp/code/model/tests/test_lpcraft.py
index 3b6031d..096592e 100644
--- a/lib/lp/code/model/tests/test_lpcraft.py
+++ b/lib/lp/code/model/tests/test_lpcraft.py
@@ -132,13 +132,34 @@ class TestLoadConfiguration(TestCase):
}, configuration.jobs,
)
- def test_expand_matrix(self):
+ def test_expand_architectures(self):
# if `architectures` is a string, it will be converted into a list
c = dedent("""\
pipeline:
- [test]
jobs:
test:
+ series: focal
+ architectures: amd64
+ """)
+
+ configuration = load_configuration(c)
+
+ self.assertEqual(
+ [["test"]], configuration.pipeline,
+ )
+ self.assertEqual(
+ {
+ "test": [{'series': 'focal', 'architectures': ['amd64']}],
+ }, configuration.jobs,
+ )
+
+ def test_expand_matrix(self):
+ c = dedent("""\
+ pipeline:
+ - [test]
+ jobs:
+ test:
matrix:
- series: bionic
architectures: amd64