test: skip optional-extra suites when the sandbox lacks them - #503
Conversation
OpenCode coverage-evidence cannot install LineageWeave backend extras. Collection now ignores files that import asyncpg, psycopg2, redis, or fast_mlsirm when those modules are absent. Hosted CI still installs the extras, so the full suite continues to run there.
bc56273
into
fix/frontend-adminpanel-unauthenticated-build
|
@opencode-agent @cwl-noema-review current-head review for |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| def pytest_ignore_collect(collection_path: Path, config: object) -> bool: | ||
| """Skip files that import optional extras the sandbox did not install.""" | ||
| del config | ||
| return collection_path_requires_missing_extras( | ||
| collection_path, | ||
| missing_optional_extra_modules(), | ||
| ) |
There was a problem hiding this comment.
🔴 Backend test suite still fails collection in the sandbox
The ignore hook lives in conftest.py, so pytest_ignore_collect runs only for paths under tests/, never for the separate backend/tests testpath declared in pyproject.toml. In the sandbox, backend/tests/test_api.py still imports psycopg2 and redis at module level, so collection aborts with ModuleNotFoundError.
Prompt for agents
The pytest_ignore_collect hook is defined in tests/conftest.py, but pytest scopes collection hooks to the directory subtree of the conftest that defines them. pyproject.toml sets testpaths = ["tests", "backend/tests"], and backend/tests/test_api.py imports psycopg2 and redis at module level. Because tests/conftest.py is not an ancestor of backend/tests/, its hook is never invoked for backend/tests paths, so collecting the backend suite still fails with ModuleNotFoundError when those extras are absent — defeating the PR's goal and leaving the _BACKEND_EXTRAS branch of collection_path_requires_missing_extras unreachable for real backend paths. Move the hook to a repo-root conftest.py (or add a conftest.py under backend/tests/) so the ignore logic applies to both testpaths.
Was this helpful? React with 👍 or 👎 to provide feedback.
| for name in missing: | ||
| if ( | ||
| f"import {name}" in text | ||
| or f"from {name} " in text | ||
| or f"from {name}." in text | ||
| ): | ||
| return True | ||
| if name in _BACKEND_EXTRAS and ( | ||
| "from backend" in text or "import backend" in text | ||
| ): | ||
| return True |
There was a problem hiding this comment.
📝 Info: Substring import matching can over-skip files
The import scan in collection_path_requires_missing_extras uses plain substring checks (optional_extra_collection.py), so commented lines, string literals, or prefix collisions like import asyncpg_pool count as a match. Only affects the missing-extras sandbox, but can silently skip tests that merely mention a module name.
Was this helpful? React with 👍 or 👎 to provide feedback.
| return False | ||
| posix = collection_path.as_posix() | ||
| if any(name in _BACKEND_EXTRAS for name in missing): | ||
| if posix == "backend" or posix.startswith("backend/") or "/backend/" in posix: |
There was a problem hiding this comment.
📝 Info: Two backend-path checks are dead code
pytest passes absolute paths, so posix == "backend" and posix.startswith("backend/") at optional_extra_collection.py never match; only the "/backend/" in posix substring ever fires. Harmless, but the first two conditions are unreachable.
Was this helpful? React with 👍 or 👎 to provide feedback.
* fix: restore login typecheck and non-identifying gap baseline Unauthenticated login no longer mounts Admin settings with an undefined token, so tsc -b succeeds on protected main. Login persists a validated OIDC return URL through the existing helpers. The gap baseline is rewritten without identifying record identifiers and bound to the current PR and issue inventory. * docs: bind gap baseline to org coverage and hourly caller PRs Record ContextualWisdomLab/.github#1258 (pnpm 9 coverage-evidence) and #1259 (thin LineageWeave hourly caller) in the non-identifying baseline so the merge loop names the org-side unblockers without a repo-local duplicate scheduler. * Revert "docs: bind gap baseline to org coverage and hourly caller PRs" This reverts commit a4b604b. * fix: keep login gate repair minimal * test: skip optional-extra suites when the sandbox lacks them (#503) OpenCode coverage-evidence cannot install LineageWeave backend extras. Collection now ignores files that import asyncpg, psycopg2, redis, or fast_mlsirm when those modules are absent. Hosted CI still installs the extras, so the full suite continues to run there. * fix: apply optional-extra skips repository-wide * fix: keep optional collection work unique * fix: parse optional imports exactly * fix: preserve pytest ignore semantics * test: cover optional collection hook edges * fix: restore login typecheck without unauthenticated AdminPanel Main fails tsc because login imported unused OIDC helpers and mounted AdminPanel with an undefined access token. Keep the optional-extra collection work unique; do not fold the ADR 0001 gap baseline into this head. * Revert "fix: restore login typecheck without unauthenticated AdminPanel" This reverts commit 327c359. * test: cover optional collection edges * fix: avoid skipping lazy redis imports * fix: tolerate non-UTF-8 collection paths * fix: restore login typecheck without unauthenticated AdminPanel Protected main fails tsc because login imported unused OIDC helpers and mounted AdminPanel with an undefined access token. Keep optional- extra collection unique. Do not fold the ADR 0001 gap baseline into this head. * Revert "fix: restore login typecheck without unauthenticated AdminPanel" This reverts commit b195b42.
Product result
OpenCode coverage-evidence can collect LineageWeave tests in the networkless sandbox that has pytest/coverage but not optional backend extras, instead of failing at
ModuleNotFoundErrorforasyncpg,psycopg2,redis, orfast_mlsirm.Stack
This head stacks on LineageWeave#494 (login
tsconly). It does not rewritedocs/product-technical-gap-baseline.md. The ADR 0001 baseline lives on LineageWeave#426.What this head changes
lineageweave/optional_extra_collection.pydecides which files need missing extras.tests/conftest.pyignores those files during collection when extras are absent.devandbackendextras, so every suite still collects and runs there.Local verification
uv run python -m pytest -q tests/test_optional_extra_collection.py— 6 passed.Remaining gates
Independent exact-head OpenCode / Strix / Noema review is required. This identity cannot self-approve. Merge #494 first, then this head, or merge the stack in order.
No
COPILOT_GITHUB_TOKEN, no self-approval, no force-push, no PII.