Skip to content

Commit c10ff87

Browse files
robkerseyclaude
andcommitted
build-dfu-tools: drop macos-13; alias darwin-x86_64 → darwin-arm64
GitHub deprecated macos-13 (Intel) runners; jobs targeting that label now queue indefinitely and never get picked up. Apple Silicon Macs have been Apple's only product since late 2023, and any remaining Intel Mac runs the arm64 binary fine via Rosetta 2 (bundled with macOS). Changes: - Remove macos-13 row from the build matrix. - Remove darwin-x86_64 entry from manifest.json's platforms map. - Add a platform_aliases section: darwin-x86_64 → darwin-arm64. The fetcher honours these on miss, picking up the aliased platform's binary (and recording the actual platform we picked in ToolSpec.platform so diagnostics aren't lying). Tests: 79 passing (+1 for the alias-fallback path). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0c5e6b6 commit c10ff87

4 files changed

Lines changed: 40 additions & 11 deletions

File tree

.github/workflows/build-dfu-tools.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
- runner: macos-14 # Apple Silicon
4444
platform_tag: darwin-arm64
4545
artifact_name: bert-dfu-darwin-arm64
46-
- runner: macos-13 # Intel
47-
platform_tag: darwin-x86_64
48-
artifact_name: bert-dfu-darwin-x86_64
46+
# macos-13 (Intel) runners deprecated by GitHub; queue indefinitely.
47+
# Intel Macs run the arm64 binary fine via Rosetta 2 (bundled with
48+
# macOS). The Bert runtime handles the platform-tag fallback.
4949
- runner: ubuntu-22.04
5050
platform_tag: linux-x86_64
5151
artifact_name: bert-dfu-linux-x86_64

src/bert/adapters/firmware_fetch.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,13 @@ def host_platform_tag() -> str:
146146

147147

148148
def load_tool_manifest() -> dict[str, ToolSpec]:
149-
"""Load all helper-binary specs for the current host platform."""
149+
"""Load all helper-binary specs for the current host platform.
150+
151+
Honours per-tool ``platform_aliases``: if the host's tag isn't in the
152+
``platforms`` map, look it up in ``platform_aliases`` to find a
153+
compatible alternative (e.g. Intel Macs falling back to ``darwin-arm64``
154+
binaries that run under Rosetta 2).
155+
"""
150156

151157
raw = _read_manifest()
152158
out: dict[str, ToolSpec] = {}
@@ -155,7 +161,18 @@ def load_tool_manifest() -> dict[str, ToolSpec]:
155161
if tool_name == "comment" or not isinstance(entry, dict):
156162
continue
157163
platforms = entry.get("platforms") or {}
158-
plat_entry = platforms.get(host_tag)
164+
aliases = entry.get("platform_aliases") or {}
165+
# Resolve host_tag → effective platform via alias chain (max one hop).
166+
effective_tag = host_tag
167+
if effective_tag not in platforms and effective_tag in aliases:
168+
aliased = aliases[effective_tag]
169+
if isinstance(aliased, str) and aliased in platforms:
170+
log.info(
171+
"platform %s: falling back to %s binary (alias)",
172+
host_tag, aliased,
173+
)
174+
effective_tag = aliased
175+
plat_entry = platforms.get(effective_tag)
159176
if plat_entry is None:
160177
log.debug("no %s binary for platform %s", tool_name, host_tag)
161178
continue
@@ -169,7 +186,7 @@ def load_tool_manifest() -> dict[str, ToolSpec]:
169186
continue
170187
out[tool_name] = ToolSpec(
171188
name=tool_name,
172-
platform=host_tag,
189+
platform=effective_tag, # actual binary's native platform; see alias resolution above
173190
filename=filename,
174191
url=url,
175192
sha256=sha,

src/bert/firmware/manifest.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
3232
"size_bytes": 0
3333
},
34-
"darwin-x86_64": {
35-
"filename": "bert-dfu-darwin-x86_64",
36-
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
37-
"size_bytes": 0
38-
},
3934
"linux-x86_64": {
4035
"filename": "bert-dfu-linux-x86_64",
4136
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
@@ -46,6 +41,10 @@
4641
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
4742
"size_bytes": 0
4843
}
44+
},
45+
"platform_aliases": {
46+
"_comment": "Map host platforms we don't ship binaries for to ones that work via emulation. macOS Intel runs darwin-arm64 binaries via Rosetta 2.",
47+
"darwin-x86_64": "darwin-arm64"
4948
}
5049
}
5150
}

tests/unit/test_firmware_fetch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ def test_load_tool_manifest_skips_unknown_platform(
214214
assert tools == {}
215215

216216

217+
def test_load_tool_manifest_resolves_platform_alias(
218+
monkeypatch: pytest.MonkeyPatch,
219+
) -> None:
220+
"""Intel Macs (darwin-x86_64) should pick up the darwin-arm64 binary
221+
via the manifest's platform_aliases. Rosetta 2 handles the rest."""
222+
monkeypatch.setattr(firmware_fetch, "host_platform_tag", lambda: "darwin-x86_64")
223+
tools = firmware_fetch.load_tool_manifest()
224+
if "bert-dfu" in tools:
225+
# The shipped manifest aliases darwin-x86_64 → darwin-arm64.
226+
assert tools["bert-dfu"].platform == "darwin-arm64"
227+
assert tools["bert-dfu"].filename == "bert-dfu-darwin-arm64"
228+
229+
217230
@pytest.fixture
218231
def isolated_tool_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
219232
monkeypatch.setenv("BERT_TOOLS_CACHE", str(tmp_path / "tcache"))

0 commit comments

Comments
 (0)