Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions .github/scripts/infra_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,11 @@ def _publish_computers(folder: Path) -> int:
images = {arch: f"{repository}@{digest}" for arch, digest in digests.items()}
index = f"{repository}:index-" + hashlib.sha256(
",".join(images[arch] for arch in COMPUTER_ARCHES).encode()).hexdigest()
if (code := _exists(index)) == 2:
return 1
if code == 1:
served, error = _served(index)
# GHCR may refuse a token a package before its first push, which a release's first of an app is.
if served is None and ": not found" not in error:
print(f"::warning::{index} is taken as unpublished, since the registry won't say: {error}")
if served is None:
source = f"https://github.com/{os.environ['GITHUB_REPOSITORY']}"
created = _tried_again(lambda: _streamed([
"docker", "buildx", "imagetools", "create", "-t", index,
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,10 @@ jobs:
python3 .github/scripts/infra_build.py retry "$RUNNER_TEMP/venv/bin/python" -m pip install --quiet \
--index-url https://pypi.org/simple dist/agentenv_framework-*.whl \
"agentenv-framework-protocol[app]==${protocol}"
# The folders first, as Docker makes a missing one it mounts root's, which the compose then can't write in.
- name: Start the local registry, its storage in a folder handed on
run: |
mkdir -p "$RUNNER_TEMP/computers/registry" "$RUNNER_TEMP/computers/composed"
docker run --detach --name registry --publish 5000:5000 \
--volume "$RUNNER_TEMP/computers/registry:/var/lib/registry" mirror.gcr.io/library/registry:2
timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done'
Expand Down
20 changes: 18 additions & 2 deletions tst/unit/test_infra_build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def _composed(folder: Path, changes: dict | None = None, arches=("amd64", "arm64
return folder


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


def test_publish_computers_creates_an_index_ghcr_wont_say_it_has_before_the_packages_first_push(script, monkeypatch,
tmp_path, workflow,
capsys):
created = []
refused = "denied: requested access to the resource is denied"
monkeypatch.setattr(script.subprocess, "run", _computer_registry({}, created, before=refused))
monkeypatch.setattr(script.subprocess, "Popen", lambda argv, **kw: (created.append(argv), _Process("", 0))[1])

assert _run(script, monkeypatch, "publish-computers", str(_composed(tmp_path))) == 0

out = capsys.readouterr().out
assert len(created) == 1 and f"::warning::{_COMPUTER_INDEX} is taken as unpublished" in out
assert "::error::" not in out


@pytest.mark.parametrize("changes, arches, problem", [
({"arm64": {"env": "@local/agentenv-framework/browsers/other"}}, ("amd64", "arm64"),
"isn't an app a release publishes"),
Expand Down
9 changes: 9 additions & 0 deletions tst/unit/test_release_infra_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ def test_what_a_registry_can_rate_limit_is_tried_again():
assert JOBS["infra-build"]["strategy"]["max-parallel"] <= 4


def test_the_folders_a_computers_compose_writes_are_made_before_docker_mounts_one():
"""Docker makes a missing folder it mounts root's, and the compose then can't write its record beside it, as
v0.9.1544's couldn't."""
(start,) = [run for run in _runs("computer-build") if "--name registry" in run]

made = 'mkdir -p "$RUNNER_TEMP/computers/registry" "$RUNNER_TEMP/computers/composed"'
assert made in start and start.index(made) < start.index("docker run")


def test_the_computers_compose_is_tried_again_in_fresh_stores_while_pypi_doesnt_list_the_protocol():
"""Its resolve asks PyPI for the protocol the release published moments earlier, as v0.9.1543's did, too soon."""
(compose,) = [run for run in _runs("computer-build") if "release_computers.py compose" in run]
Expand Down
Loading