Skip to content

Commit cca8f20

Browse files
authored
Merge branch 'main' into dev/build-bake
2 parents 812c8b2 + f1a56a5 commit cca8f20

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

.github/actions/docker-targets/get_targets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,8 @@ def main() -> int:
126126
stage_details: list[dict[str, str]] = []
127127
want_platform = canonical_platform(args.platform) if args.platform else ""
128128
for item in collect_non_eol(data, args.platform or None):
129-
if (
130-
not all
131-
and changed
132-
and (item["family"], item["distro"]) not in changed
129+
if (not all and not changed) or (
130+
not all and (item["family"], item["distro"]) not in changed
133131
):
134132
continue
135133
include.append(item)
@@ -144,7 +142,9 @@ def main() -> int:
144142
if not stage:
145143
continue
146144
platforms = target.get("platforms", "")
147-
if want_platform and not platforms_support(platforms, want_platform):
145+
if want_platform and not platforms_support(
146+
platforms, want_platform
147+
):
148148
continue
149149
stage_details.append(
150150
{

.github/actions/docker-targets/tests/test_get_targets.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,32 @@ def test_main_returns_all_when_flag_set(self) -> None:
142142
],
143143
)
144144

145+
def test_main_with_no_changes_produces_empty_outputs(self) -> None:
146+
self._write_templates(
147+
"""
148+
ros2:
149+
- name: rolling
150+
targets:
151+
- target: base
152+
"""
153+
)
154+
155+
argv = [
156+
"get_targets.py",
157+
"--all",
158+
"false",
159+
"--changed",
160+
"",
161+
]
162+
with patch.object(sys, "argv", argv):
163+
exit_code = TARGETS_MODULE.main()
164+
165+
self.assertEqual(exit_code, 0)
166+
outputs = self._outputs()
167+
self.assertEqual(outputs.get("distros"), [])
168+
self.assertEqual(outputs.get("families"), [])
169+
self.assertEqual(outputs.get("stages"), [])
170+
145171
def test_collect_non_eol_respects_platform_filter(self) -> None:
146172
data = {
147173
"ros2": [

.vscode/tasks.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@
4545
}
4646
]
4747
},
48+
{
49+
"label": "action tests",
50+
"type": "shell",
51+
"command": "python -m unittest discover -s .github/actions -p 'test_*.py'",
52+
"problemMatcher": "$python"
53+
},
4854
{
4955
"label": "test",
5056
"dependsOn": [
5157
"flake8",
52-
"pydocstyle"
58+
"pydocstyle",
59+
"action tests"
5360
]
5461
},
5562
{

0 commit comments

Comments
 (0)