0ef5fcb1c5
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim name:code-slim]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-nonroot name:nonroot]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim name:slim]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Waiting to run
Docker / docker-manifest (map[bake_target:runtime name:]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-code name:code]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-code-slim name:code-slim]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-nonroot name:nonroot]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-slim name:slim]) (push) Blocked by required conditions
Docker / docker-manifest (map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Blocked by required conditions
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime name:]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code name:code]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim name:code-slim]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-nonroot name:nonroot]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim name:slim]) (push) Waiting to run
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime name:]) (push) Waiting to run
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code name:code]) (push) Waiting to run
Docker / promote-latest (push) Blocked by required conditions
Init Native E2E / init-native (macos-latest, claude) (push) Waiting to run
Init Native E2E / init-native (macos-latest, codex) (push) Waiting to run
Init Native E2E / init-native (macos-latest, copilot) (push) Waiting to run
Install Native E2E / install-native (macos-latest) (push) Waiting to run
Wrap Native E2E / wrap-native (macos-latest) (push) Waiting to run
Security / Dependency audit (pip-audit) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Security / Secret scan (gitleaks) (push) Has been cancelled
rust / test (ubuntu) (push) Has been cancelled
rust / simulator e2e (macos-latest) (push) Has been cancelled
rust / simulator e2e (ubuntu-latest) (push) Has been cancelled
rust / simulator e2e (windows-latest) (push) Has been cancelled
rust / wheels (aarch64-apple-darwin) (push) Has been cancelled
rust / wheels (x86_64-unknown-linux-gnu) (push) Has been cancelled
rust / wheels (x86_64-apple-darwin) (push) Has been cancelled
rust / audit (push) Has been cancelled
rust / parity (nightly, allowed to fail during Phase 0) (push) Has been cancelled
CI / commitlint (push) Has been skipped
Dev Containers / validate (.devcontainer/devcontainer.json, default) (push) Failing after 0s
Dev Containers / validate (.devcontainer/memory-stack/devcontainer.json, memory-stack) (push) Failing after 0s
Dev Containers / validate-worktree (push) Failing after 0s
CI / changes (push) Failing after 4s
Deploy Documentation / validate (push) Has been skipped
Deploy Documentation / deploy (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, claude) (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, codex) (push) Failing after 1s
Install Native E2E / install-native (ubuntu-latest) (push) Failing after 1s
OpenCode Plugin / typecheck + build + test (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, copilot) (push) Failing after 1s
Release Please / release-please (push) Failing after 1s
Wrap E2E / docker-wrap-e2e (push) Failing after 1s
Wrap Native E2E / wrap-native (ubuntu-latest) (push) Failing after 1s
Init E2E / docker-init-e2e (push) Failing after 4s
Merge Conflicts / merge-conflicts (push) Failing after 4s
CI / lint (push) Has been cancelled
CI / build-wheel (push) Has been cancelled
CI / build-wheel-windows (push) Has been cancelled
CI / prefetch-model (push) Has been cancelled
CI / test-dashboard-ui (push) Has been cancelled
CI / test (1) (push) Has been cancelled
CI / test (2) (push) Has been cancelled
CI / test (3) (push) Has been cancelled
CI / test (4) (push) Has been cancelled
CI / test-extras (push) Has been cancelled
CI / test-agno (push) Has been cancelled
CI / build (push) Has been cancelled
CI / workflow-validation (push) Has been cancelled
CI / docker-native-e2e (push) Has been cancelled
CI / windows-native-wrapper (push) Has been cancelled
CI / macos-native-wrapper (push) Has been cancelled
97 lines
3.1 KiB
Python
97 lines
3.1 KiB
Python
"""Cross-platform agent binary shim factory for e2e tests.
|
|
|
|
A "shim" is a tiny executable with a given name (e.g. `claude`, `codex`) that
|
|
the harness drops into a temporary directory and prepends to PATH. It lets
|
|
tests drive `headroom init` without requiring a real Claude/Codex install.
|
|
|
|
Three behaviors are supported:
|
|
|
|
* ``noop`` — exits 0 with no output. Default.
|
|
* ``fail`` — exits 1 with a short stderr message.
|
|
* ``record-args`` — appends a JSON record of (tool, argv, cwd) to the file at
|
|
``$HEADROOM_E2E_SHIM_LOG``, then exits 0. Useful for
|
|
asserting that `init claude` invoked
|
|
`claude plugin install` with the right arguments.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import stat
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import Literal
|
|
|
|
ShimBehavior = Literal["noop", "fail", "record-args"]
|
|
|
|
_NOOP_SH = """#!/usr/bin/env bash
|
|
exit 0
|
|
"""
|
|
|
|
_FAIL_SH = """#!/usr/bin/env bash
|
|
echo "${0##*/}: simulated failure" >&2
|
|
exit 1
|
|
"""
|
|
|
|
_RECORD_SH = """#!/usr/bin/env bash
|
|
tool="${0##*/}"
|
|
log="${HEADROOM_E2E_SHIM_LOG:-/dev/null}"
|
|
mkdir -p "$(dirname "$log")" 2>/dev/null || true
|
|
python3 - "$tool" "$log" "$@" <<'PY'
|
|
import json, os, sys
|
|
tool, log, *argv = sys.argv[1:]
|
|
record = {"tool": tool, "argv": argv, "cwd": os.getcwd()}
|
|
if log != "/dev/null":
|
|
with open(log, "a", encoding="utf-8") as handle:
|
|
handle.write(json.dumps(record) + "\\n")
|
|
print(f"{tool} shim executed")
|
|
PY
|
|
exit 0
|
|
"""
|
|
|
|
# Windows equivalents. Use `.cmd` so `shutil.which` and PATHEXT find them.
|
|
_NOOP_CMD = "@echo off\r\nexit /b 0\r\n"
|
|
|
|
_FAIL_CMD = "@echo off\r\necho %~n0: simulated failure 1>&2\r\nexit /b 1\r\n"
|
|
|
|
_RECORD_CMD = (
|
|
"@echo off\r\n"
|
|
"setlocal\r\n"
|
|
'if "%HEADROOM_E2E_SHIM_LOG%"=="" set HEADROOM_E2E_SHIM_LOG=NUL\r\n'
|
|
"python -c \"import json,os,sys; name=r'%~n0'; log=os.environ['HEADROOM_E2E_SHIM_LOG']; "
|
|
"rec={'tool':name,'argv':sys.argv[1:],'cwd':os.getcwd()};\r\n"
|
|
"open(log,'a',encoding='utf-8').write(json.dumps(rec)+chr(10)) if log!='NUL' else None;\r\n"
|
|
"print(f'{name} shim executed')\" %*\r\n"
|
|
"exit /b 0\r\n"
|
|
)
|
|
|
|
|
|
def _is_windows() -> bool:
|
|
return os.name == "nt" or sys.platform == "win32"
|
|
|
|
|
|
def make_shim(name: str, dir: Path, behavior: ShimBehavior = "noop") -> Path:
|
|
"""Create an executable shim named ``name`` inside ``dir``.
|
|
|
|
Returns the absolute path to the created shim. On POSIX this is a ``.sh``
|
|
file made executable and named without extension (so ``shutil.which(name)``
|
|
finds it). On Windows this is a ``.cmd`` file — again, ``shutil.which``
|
|
honours ``PATHEXT`` and will find it.
|
|
"""
|
|
|
|
dir = Path(dir)
|
|
dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
if _is_windows():
|
|
body = {"noop": _NOOP_CMD, "fail": _FAIL_CMD, "record-args": _RECORD_CMD}[behavior]
|
|
path = dir / f"{name}.cmd"
|
|
path.write_text(body, encoding="utf-8")
|
|
return path
|
|
|
|
body = {"noop": _NOOP_SH, "fail": _FAIL_SH, "record-args": _RECORD_SH}[behavior]
|
|
path = dir / name
|
|
path.write_text(body, encoding="utf-8")
|
|
mode = path.stat().st_mode
|
|
path.chmod(mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
return path
|