mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
test(docker): align Dockerfile contract tests with simplified TUI flow
The Dockerfile dropped the manual `@hermes/ink` materialisation gymnastics
in favour of letting npm workspaces resolve the bundled package
naturally. Two contract tests still asserted the older flow:
`test_dockerfile_installs_tui_dependencies` required:
'ui-tui/packages/hermes-ink/package-lock.json' in dockerfile_text
…but the lockfile is no longer COPIED individually \u2014 the entire
`ui-tui/packages/hermes-ink/` tree is COPIED instead (the workspace
reference from `ui-tui/package.json` is `file:` so npm needs the
real source, not just a manifest stub).
`test_dockerfile_materializes_local_tui_ink_package` required a 7-clause
conjunction matching specific `rm -rf` / `npm install --omit=dev`
`--prefix node_modules/@hermes/ink` / `rm -rf .../react` invocations
that were stripped out when the workspace resolution was simplified.
Update the assertions to pin the *contract* the image actually has to
carry rather than the *exact shell incantations* the old flow used:
* TUI deps install: ui-tui/package.json + ui-tui/package-lock.json +
ui-tui/packages/hermes-ink/ tree are all COPIED, and an npm
install/ci step runs in ui-tui.
* Bundled hermes-ink: the workspace package source is COPIED (so
`await import('@hermes/ink')` resolves at runtime).
This keeps the spirit of #15012 / #16690 (zombie reaping + bundled
workspace materialisation must continue to work) without locking the
Dockerfile into one specific implementation flavour.
Validation:
$ pytest tests/tools/test_dockerfile_pid1_reaping.py -q
6 passed in 1.43s
No production code change. Fixes the two failures observed on `main`
(run 25250051126):
`tests/tools/test_dockerfile_pid1_reaping.py::test_dockerfile_installs_tui_dependencies`
`tests/tools/test_dockerfile_pid1_reaping.py::test_dockerfile_materializes_local_tui_ink_package`
This commit is contained in:
parent
e7eb07cec7
commit
033e533d05
1 changed files with 19 additions and 11 deletions
|
|
@ -106,8 +106,15 @@ def test_dockerfile_entrypoint_routes_through_the_init(dockerfile_text):
|
|||
|
||||
|
||||
def test_dockerfile_installs_tui_dependencies(dockerfile_text):
|
||||
# The TUI workspace manifests must be present so ``npm install`` can
|
||||
# resolve dependencies. The bundled ``hermes-ink`` workspace package is
|
||||
# now COPIED into the image as a whole tree (not just its lockfile)
|
||||
# because it's referenced as a ``file:`` workspace dependency from
|
||||
# ``ui-tui/package.json`` — copying the tree avoids npm stopping at a
|
||||
# bare ``package.json`` shell.
|
||||
assert "ui-tui/package.json" in dockerfile_text
|
||||
assert "ui-tui/packages/hermes-ink/package-lock.json" in dockerfile_text
|
||||
assert "ui-tui/package-lock.json" in dockerfile_text
|
||||
assert "ui-tui/packages/hermes-ink/" in dockerfile_text
|
||||
assert any(
|
||||
"ui-tui" in step and "npm" in step and (" install" in step or " ci" in step)
|
||||
for step in _run_steps(dockerfile_text)
|
||||
|
|
@ -122,16 +129,17 @@ def test_dockerfile_builds_tui_assets(dockerfile_text):
|
|||
|
||||
|
||||
def test_dockerfile_materializes_local_tui_ink_package(dockerfile_text):
|
||||
assert any(
|
||||
"ui-tui" in step
|
||||
and "node_modules/@hermes/ink" in step
|
||||
and "packages/hermes-ink" in step
|
||||
and "rm -rf packages/hermes-ink/node_modules" in step
|
||||
and "npm install --omit=dev" in step
|
||||
and "--prefix node_modules/@hermes/ink" in step
|
||||
and "rm -rf node_modules/@hermes/ink/node_modules/react" in step
|
||||
and "await import('@hermes/ink')" in step
|
||||
for step in _run_steps(dockerfile_text)
|
||||
# ``hermes-ink`` is a bundled workspace package referenced from
|
||||
# ``ui-tui/package.json`` via ``file:`` — not pulled from the npm
|
||||
# registry. The contract this test pins is just that the image
|
||||
# actually carries the package source so ``await import('@hermes/ink')``
|
||||
# can resolve at runtime; the previous, much pickier assertion (manual
|
||||
# ``rm -rf`` + ``npm install --omit=dev --prefix node_modules/@hermes/ink``)
|
||||
# baked in implementation details of an older materialisation flow that
|
||||
# was simplified once npm workspaces handled the resolution natively.
|
||||
assert "ui-tui/packages/hermes-ink/" in dockerfile_text, (
|
||||
"Dockerfile must COPY the bundled hermes-ink workspace package "
|
||||
"so ``await import('@hermes/ink')`` resolves at runtime."
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue