mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
The workspace jobs pulled every image anonymously from Docker Hub and two of them failed on its rate limit in run 39059128678 (#990): the fedora swarm drill on busybox:1.38 on all three nodes, the centos compose drill while building tor-smtp_custom. The regular deploy jobs pull through the GHCR mirror, but the mirror was tied to being a real GitHub runner: Profile.image_mirror_enabled() returned runs_on_github(), and the swarm routine generated mirrors.yml only when cli.meta.runtime reported github, which is act inside make swarm-zombie. The mirror is now its own capability, INFINITO_GHCR_MIRROR (next to INFINITO_GHCR_MIRROR_PREFIX), written as a run fact like INFINITO_CACHE_STACK: true on a real GitHub runner, false everywhere else, and a non-empty exported value wins for the run. Profile.image_mirror_enabled() reads the declaration and keeps runs_on_github() as the fallback, and 02_provision_inventory.sh gates on the same value instead of the runtime name. make swarm-zombie forwards it into act through ACT_ENV, since act ignores the host env. call-test-workspace.yml declares INFINITO_GHCR_MIRROR=true and passes INFINITO_GHCR_MIRROR_PREFIX into the workspace container. Nothing else of the workspace changes: is_ci, runs_on_github, the cache stack and the docker root stay local-like. The step that loads the rescue paths now removes the .env it generated on the runner, because on debian rows load.sh sourced it inside the container and the run inherited INFINITO_RUNNING_ON_GITHUB=true. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
"""Runtime-context helpers for the dev/CI compose stack."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
|
|
def _declared(name: str) -> bool | None:
|
|
"""Explicit capability declaration, or None when it is left to the default."""
|
|
raw = (os.environ.get(name) or "").strip()
|
|
if raw == "true":
|
|
return True
|
|
if raw == "false":
|
|
return False
|
|
return None
|
|
|
|
|
|
class Profile:
|
|
"""Runtime identity and the capability decisions derived from it."""
|
|
|
|
def is_ci(self) -> bool:
|
|
"""True when any standard CI signal is set."""
|
|
return (
|
|
os.environ.get("GITHUB_ACTIONS") == "true"
|
|
or os.environ.get("INFINITO_RUNNING_ON_GITHUB") == "true"
|
|
or os.environ.get("CI") == "true"
|
|
)
|
|
|
|
def runs_on_github(self) -> bool:
|
|
"""True on a real GitHub runner; act and generic CI are not that."""
|
|
return os.environ.get("INFINITO_RUNNING_ON_GITHUB") == "true"
|
|
|
|
def cache_stack_enabled(self) -> bool:
|
|
"""True iff the pull-through cache stack should be loaded."""
|
|
declared = _declared("INFINITO_CACHE_STACK")
|
|
return (not self.is_ci()) if declared is None else declared
|
|
|
|
def image_mirror_enabled(self) -> bool:
|
|
"""True iff image references should be rewritten to the GHCR mirror."""
|
|
declared = _declared("INFINITO_GHCR_MIRROR")
|
|
return self.runs_on_github() if declared is None else declared
|
|
|
|
def docker_root_ephemeral(self) -> bool:
|
|
"""True iff the docker data root may be wiped when the stack goes down."""
|
|
return self.runs_on_github()
|
|
|
|
def instance(self) -> int:
|
|
"""Slot index of this checkout; 0 is the primary one.
|
|
|
|
Bookkeeping only: the compose layering below keys off the concrete
|
|
resources a worktree was handed, never off this number, so a stray
|
|
slot cannot make compose demand a value nobody set.
|
|
"""
|
|
raw = (os.environ.get("INFINITO_INSTANCE") or "0").strip()
|
|
return int(raw) if raw.isdigit() else 0
|
|
|
|
def shared_git_dir(self) -> str:
|
|
"""Path of the checkout's shared .git directory, empty when it owns one."""
|
|
return (os.environ.get("INFINITO_GIT_COMMON_DIR") or "").strip()
|
|
|
|
def shared_cache_network(self) -> str:
|
|
"""Docker network of a cache stack owned elsewhere, empty when unset."""
|
|
return (os.environ.get("INFINITO_CACHE_NETWORK") or "").strip()
|
|
|
|
def owns_cache_stack(self) -> bool:
|
|
"""True iff this instance runs the cache stack rather than sharing it."""
|
|
return self.cache_stack_enabled() and not self.shared_cache_network()
|