test(e2e): upgrade harnesses install main from their tagless sandbox origins

Their origins publish commits on main and no release tags, so the stable
default (#139311) has no release to install there. Fresh installs pass
HERMES_INSTALL_CHANNEL=main and save the choice, so reruns pass nothing,
as users do and as the rerun-idempotence cell requires.
This commit is contained in:
Teknium
2026-10-15 11:57:54 -07:00
parent 6d63140782
commit f9bdaa303e
4 changed files with 21 additions and 12 deletions

View File

@@ -121,8 +121,9 @@ class Sandbox:
return str(python)
def run(self, argv: list[str], *, timeout: float = 600, cwd: Path | None = None,
input: str | None = None) -> subprocess.CompletedProcess:
return H.run(argv, env=self.env, cwd=cwd or self.root, writable=[self.root], timeout=timeout, input=input)
input: str | None = None, env: dict[str, str] | None = None) -> subprocess.CompletedProcess:
return H.run(argv, env=env or self.env, cwd=cwd or self.root, writable=[self.root], timeout=timeout,
input=input)
def cli(self, *args: str, timeout: float = 600) -> subprocess.CompletedProcess:
return self.run([self.hermes, *args], timeout=timeout)
@@ -161,13 +162,17 @@ def run_installer(sb: Sandbox, *, timeout: float = 1800) -> subprocess.Completed
"""HEAD's scripts/install.sh, non-interactive, as the documented `curl | bash` run does it."""
script = sb.root / "install.sh"
shutil.copy(H.WORKTREE / "scripts" / "install.sh", script)
env = dict(sb.env)
if not sb.checkout.exists():
# The origin publishes commits on main and no release tags, so a fresh install follows
# main; the channel it saves carries the reruns.
env["HERMES_INSTALL_CHANNEL"] = "main"
return H.run(["bash", str(script), "--non-interactive"], env=env, cwd=sb.root, writable=[sb.root],
timeout=timeout, input="")
return sb.run(["bash", str(script), "--non-interactive"], timeout=timeout, input="",
env=fresh_install_env(sb))
def fresh_install_env(sb: Sandbox) -> dict[str, str]:
"""The sandbox env, plus `main` as the channel for a FRESH install: sandbox origins publish
commits on main and no release tags, so the stable default has nothing to install. The
install saves the choice, which carries every rerun (a rerun passes nothing, as users do)."""
if sb.checkout.exists():
return sb.env
return {**sb.env, "HERMES_INSTALL_CHANNEL": "main"}
def pin_main_channel(sb: Sandbox) -> None:

View File

@@ -222,7 +222,10 @@ def world(root: Path, *, base: str, installer_ref: str | None = None,
_preclone(sb, preclone, w.git_env())
script = sb.root / "install.sh"
script.write_text(installer_script(installer_ref), encoding="utf-8")
cp = sb.run(["bash", str(script), "--non-interactive"], timeout=1800, input="")
# The served repo publishes commits on main and no release tags: install main (N-1's
# installer ignores the variable and installs main anyway).
cp = sb.run(["bash", str(script), "--non-interactive"], timeout=1800, input="",
env={**sb.env, "HERMES_INSTALL_CHANNEL": "main"})
assert cp.returncode == 0, f"install ({installer_ref or 'HEAD'} installer, base {base[:12]}) failed:\n{w.diag(cp)}"
head = w.head()
assert head == base, f"installer left HEAD at {head}, expected {base}\n{w.diag(cp)}"

View File

@@ -80,7 +80,7 @@ def alpine_install(tmp_path_factory):
objects = Path(I.git("rev-parse", "--path-format=absolute", "--git-common-dir", cwd=H.WORKTREE)) / "objects"
pull = subprocess.run(["docker", "pull", "-q", IMAGE], capture_output=True, text=True, timeout=600, check=False)
assert pull.returncode == 0, f"docker pull {IMAGE} failed (network?):\n{pull.stderr[-2000:]}"
argv = ["docker", "run", "--rm", "-e", f"ORIGIN={origin}",
argv = ["docker", "run", "--rm", "-e", f"ORIGIN={origin}", "-e", "HERMES_INSTALL_CHANNEL=main",
"-v", f"{origin}:{origin}:ro", "-v", f"{objects}:{objects}:ro", "-v", f"{work}:/work:ro",
IMAGE, "sh", "-c", SCRIPT]
cp = subprocess.run(argv, capture_output=True, text=True, timeout=1800, check=False)

View File

@@ -195,7 +195,8 @@ def seed_install(root: Path) -> Installed:
sb.env.pop("SSL_CERT_FILE", None)
script = sb.root / "install.sh"
shutil.copy(H.WORKTREE / "scripts" / "install.sh", script)
cp = sb.run(["bash", str(script), "--non-interactive", "--skip-browser"], timeout=1800, input="")
cp = sb.run(["bash", str(script), "--non-interactive", "--skip-browser"], timeout=1800, input="",
env=I.fresh_install_env(sb))
assert cp.returncode == 0, "seed install failed:\n" + I.describe(cp)
I.pin_main_channel(sb) # cells publish commits, not releases (test_release_channel_records opts back into stable)
# From here on the checkout talks to the official URL, which only the proxy can serve.