Skip to content

Commit 7eb49b4

Browse files
fix(release): chromium's compose writes its record in a folder of its own, and its first push needn't be answered (#713)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2c67e75 commit 7eb49b4

4 files changed

Lines changed: 34 additions & 5 deletions

File tree

‎.github/scripts/infra_build.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,11 @@ def _publish_computers(folder: Path) -> int:
286286
images = {arch: f"{repository}@{digest}" for arch, digest in digests.items()}
287287
index = f"{repository}:index-" + hashlib.sha256(
288288
",".join(images[arch] for arch in COMPUTER_ARCHES).encode()).hexdigest()
289-
if (code := _exists(index)) == 2:
290-
return 1
291-
if code == 1:
289+
served, error = _served(index)
290+
# GHCR may refuse a token a package before its first push, which a release's first of an app is.
291+
if served is None and ": not found" not in error:
292+
print(f"::warning::{index} is taken as unpublished, since the registry won't say: {error}")
293+
if served is None:
292294
source = f"https://github.com/{os.environ['GITHUB_REPOSITORY']}"
293295
created = _tried_again(lambda: _streamed([
294296
"docker", "buildx", "imagetools", "create", "-t", index,

‎.github/workflows/publish-pypi.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,10 @@ jobs:
408408
python3 .github/scripts/infra_build.py retry "$RUNNER_TEMP/venv/bin/python" -m pip install --quiet \
409409
--index-url https://pypi.org/simple dist/agentenv_framework-*.whl \
410410
"agentenv-framework-protocol[app]==${protocol}"
411+
# The folders first, as Docker makes a missing one it mounts root's, which the compose then can't write in.
411412
- name: Start the local registry, its storage in a folder handed on
412413
run: |
414+
mkdir -p "$RUNNER_TEMP/computers/registry" "$RUNNER_TEMP/computers/composed"
413415
docker run --detach --name registry --publish 5000:5000 \
414416
--volume "$RUNNER_TEMP/computers/registry:/var/lib/registry" mirror.gcr.io/library/registry:2
415417
timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done'

‎tst/unit/test_infra_build_script.py‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ def _composed(folder: Path, changes: dict | None = None, arches=("amd64", "arm64
312312
return folder
313313

314314

315-
def _computer_registry(served: dict[str, str], created: list, children: set[str] | None = None):
315+
def _computer_registry(served: dict[str, str], created: list, children: set[str] | None = None,
316+
before: str = "not found"):
316317
"""Docker as the registries answer: ``served`` as ``_docker`` serves it, the local registry's composed images, and
317318
the agentenv-chromium index, served once created, of ``children``, by default the two images it was made of."""
318319
published = _docker(served)
@@ -326,7 +327,7 @@ def run(command, **kw):
326327
return published(command, **kw)
327328
ref = command[4]
328329
if ref == _COMPUTER_INDEX and not created:
329-
return subprocess.CompletedProcess(command, 1, "", f"ERROR: {ref}: not found\n")
330+
return subprocess.CompletedProcess(command, 1, "", f"ERROR: {ref}: {before}\n")
330331
if command[5:] == ["--raw"]:
331332
raw = raws.get(ref) or (ref == _COMPUTER_INDEX and {"manifests": [
332333
{"digest": digest} for digest in sorted(children or {_AMD64, _ARM64})]})
@@ -357,6 +358,21 @@ def test_publish_computers_joins_each_apps_platform_manifests_into_one_index_and
357358
assert released_computers(record) == computers
358359

359360

361+
def test_publish_computers_creates_an_index_ghcr_wont_say_it_has_before_the_packages_first_push(script, monkeypatch,
362+
tmp_path, workflow,
363+
capsys):
364+
created = []
365+
refused = "denied: requested access to the resource is denied"
366+
monkeypatch.setattr(script.subprocess, "run", _computer_registry({}, created, before=refused))
367+
monkeypatch.setattr(script.subprocess, "Popen", lambda argv, **kw: (created.append(argv), _Process("", 0))[1])
368+
369+
assert _run(script, monkeypatch, "publish-computers", str(_composed(tmp_path))) == 0
370+
371+
out = capsys.readouterr().out
372+
assert len(created) == 1 and f"::warning::{_COMPUTER_INDEX} is taken as unpublished" in out
373+
assert "::error::" not in out
374+
375+
360376
@pytest.mark.parametrize("changes, arches, problem", [
361377
({"arm64": {"env": "@local/agentenv-framework/browsers/other"}}, ("amd64", "arm64"),
362378
"isn't an app a release publishes"),

‎tst/unit/test_release_infra_images.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ def test_what_a_registry_can_rate_limit_is_tried_again():
237237
assert JOBS["infra-build"]["strategy"]["max-parallel"] <= 4
238238

239239

240+
def test_the_folders_a_computers_compose_writes_are_made_before_docker_mounts_one():
241+
"""Docker makes a missing folder it mounts root's, and the compose then can't write its record beside it, as
242+
v0.9.1544's couldn't."""
243+
(start,) = [run for run in _runs("computer-build") if "--name registry" in run]
244+
245+
made = 'mkdir -p "$RUNNER_TEMP/computers/registry" "$RUNNER_TEMP/computers/composed"'
246+
assert made in start and start.index(made) < start.index("docker run")
247+
248+
240249
def test_the_computers_compose_is_tried_again_in_fresh_stores_while_pypi_doesnt_list_the_protocol():
241250
"""Its resolve asks PyPI for the protocol the release published moments earlier, as v0.9.1543's did, too soon."""
242251
(compose,) = [run for run in _runs("computer-build") if "release_computers.py compose" in run]

0 commit comments

Comments
 (0)