Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion build_tools/github_actions/configure_multi_arch_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,8 @@ def expand_build_configs(
"""Build a BuildConfig for each platform that supports the variant.

Returns BuildConfigs with a BuildConfig per platform, or None for
platforms where the variant isn't available or no families match.
platforms where the variant isn't available, no families match, or no
artifacts will be built or reused.
"""
all_families = get_all_families_for_trigger_types(
["presubmit", "postsubmit", "nightly"]
Expand Down Expand Up @@ -1834,6 +1835,15 @@ def expand_build_configs(
linux_config: BuildConfig | None = None
windows_config: BuildConfig | None = None

# Prebuilt stages still supply artifacts; only SKIP removes a stage's work.
topology = get_topology()
active_artifacts = [
topology.artifacts[name]
for stage in topology.get_build_stages()
if jobs.build_rocm.stage_decisions.get(stage.name) != JobAction.SKIP
for name in topology.get_produced_artifacts(stage.name)
]

for platform, families, build_only, test_only in [
(
"linux",
Expand All @@ -1848,6 +1858,13 @@ def expand_build_configs(
targets.windows_test_only_families,
),
]:
if not any(
artifact.platform in (None, platform)
and platform not in artifact.disable_platforms
for artifact in active_artifacts
):
print(f" Platform {platform} has no artifacts to build or reuse, skipping")
continue
variant_config = all_build_variants.get(platform, {}).get(build_variant)
if not variant_config:
print(
Expand Down
2 changes: 1 addition & 1 deletion build_tools/github_actions/github_actions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def gha_append_step_summary(summary: str, mirror_to_job_file: bool = True):
# Use double newlines to split sections in markdown.
block = summary + "\n\n"

with open(step_summary_file, "a") as f:
with open(step_summary_file, "a", encoding="utf-8") as f:
# Use double newlines to split sections in markdown.
f.write(block)

Expand Down
50 changes: 49 additions & 1 deletion build_tools/github_actions/tests/configure_multi_arch_ci_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,7 @@ def _write_outputs(self, outputs: cm.CIOutputs) -> tuple[str, str]:

return (
github_output.read_text(),
step_summary.read_text(),
step_summary.read_text(encoding="utf-8"),
)

def test_running_ci(self):
Expand All @@ -2225,6 +2225,54 @@ def test_skipped_ci(self):
self.assertIn("enable_build_jobs=false", github_output)
self.assertTrue(step_summary.startswith("## Multi-Arch CI Configuration"))

def test_platform_outputs_follow_selected_stages(self):
"""Linux-only stages must not launch Windows artifact consumers.

Prebuilt stages count as work, but only inside the build allowlist.
Exercise the full setup pipeline and the outputs used by workflow gates.
"""
cases = [
(["emulation"], "", False),
(["emulation"], "emulation", False),
(["emulation"], "compiler-runtime", False),
(["compiler-runtime"], "", True),
(["compiler-runtime"], "compiler-runtime", True),
([], "", True),
([], "all", True),
]
for stages, prebuilt, expect_windows in cases:
with (
self.subTest(stages=stages, prebuilt=prebuilt),
patch.dict(os.environ, {"STAGE_REUSE_MODE": "dry-run"}),
):
inputs = cm.CIInputs(
run_id="12345",
event_name="pull_request",
commit_ref="feature",
base_ref="HEAD^",
build_variant="release",
linux_amdgpu_families=["gfx94x"],
windows_amdgpu_families=["gfx110x"],
build_stages=stages,
prebuilt_stages=prebuilt,
baseline_run_id="123" if prebuilt else "",
)
outputs = cm.configure(inputs, cm.GitContext.empty())
github_output, _ = self._write_outputs(outputs)
values = dict(line.split("=", 1) for line in github_output.splitlines())
linux = json.loads(values["linux_build_config"])
self.assertEqual(linux["dist_amdgpu_families"], "gfx94X-dcgpu")
if expect_windows:
windows = json.loads(values["windows_build_config"])
self.assertEqual(windows["dist_amdgpu_families"], "gfx110X-all")
self.assertEqual(linux["windows_amdgpu_families"], "gfx110X-all")
if prebuilt:
self.assertIn("compiler-runtime", windows["prebuilt_stages"])
self.assertEqual(windows["baseline_run_id"], "123")
else:
self.assertEqual(values["windows_build_config"], "")
self.assertEqual(linux["windows_amdgpu_families"], "")


# ---------------------------------------------------------------------------
# End-to-end: configure() pipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def test_append_writes_both_step_summary_and_mirror(self):
self.assertEqual(mirror.read_text(encoding="utf-8"), expected)

def test_append_multiline_summary(self):
summary = "### Heading\n\n- bullet a\n- bullet b\n\n| col |\n| --- |"
summary = "### 📋 Heading\n\n- bullet a\n- bullet b\n\n| col |\n| --- |"
with mock.patch.dict(os.environ, self.env, clear=False):
gha_append_step_summary(summary)

Expand Down
Loading