From 815eb60d02fd0c6275eab9be7108c19768c8c215 Mon Sep 17 00:00:00 2001 From: James Wiesebron Date: Sat, 25 Apr 2026 13:31:13 -0700 Subject: [PATCH] Fix #2065: decouple test/test-all from venv prerequisite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sandbox container pre-installs pytest, ruff, mypy, and the rest of the dev tools globally (sandbox/Dockerfile lines 156-178), but never installs uv. The Makefile comment at lines 12-13 already documents this intent: "CI uses venv (via uv sync); the sandbox has tools installed globally." However, `test:` and `test-all:` were declared with `venv` as a prerequisite, and `venv:` hard-errors when uv is missing — so the BRC tester running inside the sandbox could never invoke `make test` and silently fell back to ad-hoc pytest invocations that miss half of pyproject.toml's testpaths (PR #2061 / CI run 24937921821). Add a `sync-venv-if-uv` target that delegates to `venv` only when uv is on PATH, and depend on it from `test:` and `test-all:` instead. Dev machines and CI continue to get the same `uv sync --extra dev` behavior; the sandbox now falls through to the existing PYTEST/PYTHON system-PATH fallbacks already wired into the Makefile. Co-Authored-By: Claude Opus 4.7 (1M context) --- Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ec8fb900f4..d70f0872d4 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ PYTHON := $(if $(wildcard $(VENV_BIN)/python),$(VENV_BIN)/python,python3) EGG_IMAGE_TAG := $(shell git describe --always --dirty 2>/dev/null || echo latest) .PHONY: help \ - setup deps venv install-linters check-linters \ + setup deps venv sync-venv-if-uv install-linters check-linters \ lint lint-python lint-shell lint-yaml lint-docker lint-actions lint-custom \ test test-all test-record-good security \ test-integration test-e2e test-security smoketest-long-poll \ @@ -115,6 +115,14 @@ venv: @echo "==> Syncing venv..." @uv sync --extra dev +# Sync the venv if uv is on PATH; no-op otherwise. +# The sandbox container pre-installs pytest/ruff/mypy globally (see +# sandbox/Dockerfile) and does not ship uv, so test targets that depend +# on this stay green there. Dev machines and CI both have uv and get +# the same `uv sync` behavior as the strict `venv` target. Issue #2065. +sync-venv-if-uv: + @if command -v uv >/dev/null 2>&1; then $(MAKE) venv; fi + # Install all linting tools install-linters: venv @echo "Installing linting tools..." @@ -272,7 +280,7 @@ lint-custom: ## one place. LKG sidecar is NEVER updated by `make test` (Q12); ## only `make test-all` records LKG on green. test: export PYTHONPATH := shared:gateway:orchestrator -test: venv +test: sync-venv-if-uv @echo "==> Running narrowed unit tests (changeset-aware; see docs/guides/testing.md)..." @selected_file=$$(mktemp); \ PYTEST_ARGS_RAW="$(PYTEST_ARGS)" \ @@ -322,7 +330,7 @@ test: venv ## unchanged (decision-d2). Local developers can run it any time ## to refresh their LKG without remembering the script invocation. test-all: export PYTHONPATH := shared:gateway:orchestrator -test-all: venv ## Run the full unit-test suite + record LKG on green +test-all: sync-venv-if-uv ## Run the full unit-test suite + record LKG on green @echo "==> Running full unit-test suite (issue #1973: this updates LKG on green)..." @$(PYTEST) tests/ gateway/tests/ orchestrator/tests/ shared/tests/ -v -m "not functional" $(PYTEST_ARGS); \ pytest_rc=$$?; \