mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 09:28:56 +00:00
Discard the cached branch checkout in its installation layer, share the native VNC binaries, remove unused browser bundles and inputimeout, and reuse image Python for compatible new plugin workers. Preserve existing worker environments and the parser/speech Python pins. Remove the redundant OS upgrade and refresh two stale UI test fixtures. Verified fresh base/local and branch-stage Docker builds, one source layer, pip check, 3346 Python tests plus 120 subtests (34 skips), and 63 Node tests. Live amd64 checks cover offline embeddings, archives, OCI pull/unpack, gVisor workers, browser editor/audio, PAM, terminal/GUI input and resizing.
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize("requested,existing", [(None, False), ("/usr/local/bin/python", False), ("/usr/local/bin/python", True)])
|
|
def test_worker_python_selection_preserves_existing_environments(tmp_path, requested, existing):
|
|
runtime = tmp_path / "runtime"
|
|
commands = tmp_path / "commands"
|
|
commands.mkdir()
|
|
log = tmp_path / "commands.log"
|
|
for name in ("python", "uv"):
|
|
command = commands / name
|
|
command.write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> "$BOOTSTRAP_LOG"\n')
|
|
command.chmod(0o755)
|
|
if existing:
|
|
(runtime / "bin").mkdir(parents=True)
|
|
(runtime / "bin/python").symlink_to(sys.executable)
|
|
source = Path(__file__).resolve().parents[1] / "plugins/_sandboxing/sandbox/python.sh"
|
|
script = source.read_text().replace("/opt/runtime", str(runtime)).replace("/usr/local/share/fonts", str(tmp_path / "fonts"))
|
|
env = {**os.environ, "PATH": f"{commands}:{os.environ['PATH']}", "BOOTSTRAP_LOG": str(log)}
|
|
env.pop("WORKER_PYTHON", None)
|
|
if requested:
|
|
env["WORKER_PYTHON"] = requested
|
|
subprocess.run(["sh", "-c", script], env=env, check=True)
|
|
if existing:
|
|
assert not log.exists()
|
|
assert (runtime / "bin/python").resolve() == Path(sys.executable).resolve()
|
|
else:
|
|
assert log.read_text().splitlines() == [
|
|
"-m pip install --no-cache-dir uv",
|
|
f"venv --python {requested or '3.12'} {runtime}",
|
|
]
|