Repository navigation
ci(util): find test files that no CI lane ever runs - #4124
Conversation
A test file nobody runs looks exactly like one that passes — it contributes nothing to any `collected N items` line, so a green PR is green whether the file is healthy or has been broken for months. #4121 found one that had already rotted undetected. check_test_lane_coverage.py parses every workflow and composite action, extracts the test paths each `run:` step actually names, walks tests/ and hub/agents/*/python/tests/, and reports files matched by neither a direct path nor an ancestor directory. Deliberate non-coverage has to be declared in test_lane_allowlist.yml with a one-line reason, so the allowlist is a reviewable decision rather than accumulated silence; a stale entry (file deleted, or a lane now runs it) fails too. Not wired into lint.py or a workflow — it reports 42 offenders today, so gating on it would block every PR until they are triaged.
Approve with suggestionsThis adds a checker that finds test files no CI workflow ever names — the kind that stay green forever because they never run — plus an allowlist where deliberate non-coverage has to be written down with a reason. I ran it and its tests here: the tool works, reports the 42 files the description claims, and its 36 unit tests pass. Two things worth fixing before or shortly after merge, neither of them blocking:
Real-world evidenceNo Both match the PR description exactly, including the count and the claim that no unresolved- 🔍 Technical details🟡 ImportantTest roots miss
All three are pytest-collectible ( If you'd rather not grow the offender count in this PR, the alternative is a line in the module docstring's "Scope and limits" section saying the scan is rooted at A path named in a comment or a non-command position is credited as coverage (
>>> lane_paths_in_script("pytest tests/unit # run tests/integration too", {}, ["tests"])
({'tests/integration', 'tests/unit'}, set())
>>> lane_paths_in_script("echo pytest tests/foo.py", {}, ["tests"])
({'tests/foo.py'}, set())The Two fixes, both cheap: strip everything from an unquoted Same class, second instance ( >>> lane_paths_in_script("pytest tests/ --ignore tests/integration", {}, ["tests"])
({'tests', 'tests/integration'}, set())The 🟢 MinorComposite actions are only found one directory deep ( Dead glob branches in Strengths
|
…blocking (amd#4344) 43 test files ran in no CI lane, so they looked green on every PR whether they worked or not. The checker from amd#4124 could see the gap but blocked nothing, so the count kept growing. After this PR, every test file either runs in a lane or is listed with the reason CI can't run it, and lint fails as soon as a new file is neither. Stacked on amd#4343 — merge that first. It repairs the files this PR starts running. - **23 files that need no Lemonade, live account, or AMD hardware** now run in a new `offline-integration` job in `test_unit.yml`. The job takes about 2 minutes of tests, in parallel with the unit job, so the unit job's 30-minute budget isn't touched. One more email file joins the email unit lane. - **18 files are allowlisted with a reason.** Most need a live Lemonade Server, a real Gmail account, or a self-hosted model runner; two are hand-run scripts. Two of them (`tests/mcp/test_mcp_cli_to_agent_workflow.py`, `test_mcp_sdk_integration.py`) fetch unpinned MCP servers from npm at test time **and are broken today**. Their entries say so, so a reviewer can decide whether to repair or delete them. - **The file-search tests no longer walk the real home directory.** On a developer Mac, `test_search_finds_file` ran past a 2-minute timeout, and most search assertions only checked results "if found". They now search a fake home and assert exact results; `test_files_router.py` takes about 4 s with the real `HOME` set. - **The check is now blocking** in `util/lint.py --all`, which CI already runs. Overlaps: amd#4348 makes the whole of `test_files_router.py` use a fake home, so it touches the same search tests. Whichever PR lands second resolves a small conflict. amd#4038 adds its own lint check in the same spots of `util/lint.py` and `docs/reference/dev.mdx`, so expect a trivial conflict there. amd#3669, amd#3721, and amd#3812 touch other parts of `test_unit.yml`. ## Test plan - [x] Before, on `origin/main`: `python util/check_test_lane_coverage.py` reports 43 files and exits 1 - [x] After: the checker exits 0 (850 files, 18 allowlisted), and `python util/lint.py --test-lanes` fails when a new unwired `tests/test_*.py` is added - [x] The new job's exact file list passes locally in a clean py3.12 venv matching its install step, with homes isolated and Lemonade unreachable: 534 passed, 12 skipped - [x] `test_search_finds_file` hangs past 130 s on this branch before the fix, with the real `HOME` set. After it, the whole of `test_files_router.py` passes in 4 s (75 passed, 1 skipped) - [x] The email lane's full command plus the added file passes: 4971 passed - [x] `actionlint` is clean on the three edited workflows, and `black`, `isort`, and `pylint --errors-only` are clean on `util/lint.py` - [ ] Watch this PR's `Offline Integration Tests` job go green on Linux. `test_backend_install_command_is_accepted` only runs there (it's skipped on macOS), so CI is its first real run Fixes amd#4205 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
The scarce Strix Halo pool was running hardware tests on almost every PR, because those lanes triggered on all of `src/**` and `tests/**`, including docs, the Agent UI frontend, and tests they never run. At the same time, several lanes missed files that decide their result. The worst case: the first-run `gaia init` hardware test didn't trigger on the model-pull client, which is the path amd#1655 broke. Each lane now triggers on what it actually runs, imports, installs or reads, and a new lint check keeps it that way. Replaying the last 14 days of PR and main-push runs through the new filters skips about **35k Strix Halo minutes (28% of PR-lane Halo time, roughly 290 hours a week), 2.8k Strix Point and 3.0k hosted**, net of the runs the fixes add. ## Test plan - [x] `python util/lint.py --all`: every check passes, including the new `CI Path Coverage`. `Tool Descriptions` fails locally only because that shell's `gaia` resolves to a site-packages install; CI uses the editable one. - [x] The 32 test files that read workflow files pass: `pytest $(grep -rl .github/workflows tests/unit hub/agents/*/python/tests)` (968 passed). - [x] `pytest tests/unit/test_check_ci_path_coverage.py tests/unit/test_flagship_ci.py` (83 passed). The last class pins the policy: docs-only runs only the docs lanes, website-only only `website-ci`, TUI runs `build_tui`, and a frontend `.tsx` runs no hardware lane. - [x] Probe PRs amd#5515 (docs-only), amd#5516 (website-only) and amd#5517 (tui-only) fired exactly the predicted lanes; results are in the PR comments. All three are closed and their branches deleted. - [ ] Merges through the merge queue. <details> <summary>🔍 Technical details</summary> **Under-triggering found (a PR changing only this file skipped the lane):** - `test_gaia_init_hw` (Halo, 150 min/run): `src/gaia/llm/lemonade_client.py` and `lemonade_choice.py`, the model-pull path `gaia init --force-models` takes. - Six Strix lanes (agent SDK, CLI Windows, API, embeddings, NPU embedder, RAG, C++ integration) never triggered on `installer/scripts/start-lemonade.ps1`, which they run. `test_npu_embedder` also missed the `install-lemonade` action, so a Lemonade pin bump never ran it. - `.github/actions/setup-venv` is used by about 12 lanes, and almost none listed it. - The root `conftest.py`, `tests/conftest.py` and `pyproject.toml` (pytest config) were missing from most pytest lanes. `setup.py` was missing from `test_sd`. - `test_unit`: about 20 `util/` scripts its tests import (`release_tag.py`, `eval_lane_matrix.py`, …), 9 workflow files read by contract tests (`publish.yml`, `release_components.yml`, …), 13 doc pages checked for drift, `hub/agents/*/python`, `installer/{debian,nsis,README.md}`, `scripts/dev`, and `website/src/scripts/download-target.ts`. - `test_email_agent` / `test_email_agent_unit` / `test_chat_agent`: about 10 `src/gaia` packages their tests import directly (connectors, hub, skills, ui, eval, …) plus fixtures (`tests/fixtures/email/**`). - `test_gaia_agent`: `build_flagship_sidecar.yml` and `docs/guides/starter-skills.mdx`, both read by its tests. `build_tui`: the flagship pins and `util/` scripts its called installer workflows run. - `docs.yml` missed `util/release_tag.py` (imported by `validate_release_notes.py`). `test_electron` missed the root `package.json`/lock its `npm ci` installs. **Over-triggering removed:** | Workflow | Runs on | Before | Now | |---|---|---|---| | `test_lemonade_server` | Halo, 72 min | `src/gaia/llm/**`, `installer/**`, tests | Lemonade pin, `*lemonade*.ps1`, install action, manifests. It runs no GAIA Python. | | `test_examples` (integration) | Halo, 34 min | all of `src/gaia/**` | `examples/**`, the packages examples import, the LLM client stack | | `test_agent_sdk`, `test_gaia_cli_windows` | Halo | `src/**`, `tests/**` | the client stack, plus chat/rag or audio/talk/schedule, plus the tests they run | | `test_embeddings` | Halo, 78 min | `src/gaia/rag/**` (never imported) | client stack + its three tests | | `test_gaia_cli_linux` | hosted | no filter | `src/gaia/**` minus frontend trees, plus its tests | | `test_gaia_agent` | hosted | `tests/**` | the tests it names; frontend trees excluded | | `dependency-review` | hosted | no filter | dependency manifests and Actions references | | `pypi`, `docs` | hosted | push on every branch | push on `main`; `pypi` scoped to what the wheel packages + `README.md` | The "LLM client stack" shared by the hardware lanes is `src/gaia/llm/**`, the 12 daemon modules `lemonade_client` imports, `installer/init_command.py` (the minimum Lemonade version), `utils/**`, and the leaf modules (`config`, `env`, `logger`, `ports`, `version`). **Merge queue:** `main` has no required status checks, and since March the queue merges in about 20s without dispatching `merge_group` runs. A skipped path-filtered check can't leave a PR pending. If a check becomes required, it needs either no filter (like `skill_audit.yml`) or a job-level filter with an always-running summary job. **Guard** (`util/check_ci_path_coverage.py`, `lint.py --ci-paths`). It builds on amd#4124's run-step parser. For each PR-triggered workflow, it derives what the workflow runs, imports, installs and reads, following called workflows and local actions, and fails when the filter misses one. It also fails on a source file no path-scoped lane covers, and on allowlist entries that excuse nothing. `--changed` lists the workflows a change triggers: `git diff --name-only origin/main... | python util/check_ci_path_coverage.py --changed -`. Known limits are stated in its docstring: transitive `src` imports aren't required (the unit and import-every-module lanes cover import-time breakage), and lanes that drive the CLI end to end are scoped by hand. **Estimate method:** 28,342 Actions runs from Oct 7–20, with each PR run mapped to its PR's changed files (fork runs mapped by head branch, main pushes by the squash commit's `(#N)`). Each run was replayed through the old and new filters, then costed at that workflow's mean job minutes per pool from about 4,000 sampled jobs. Release and eval workflows were left untouched. </details>
A test file that no CI lane runs is indistinguishable from one that passes: it never appears in a
collected N itemsline, so every PR goes green whether the file is healthy or has been broken for months. #4121 found one that had already rotted that way, with nothing in CI to notice. This adds the checker that notices — it reports 42 test files today that no workflow names, including the entiretests/mcp/stdio set and 29 files undertests/integration/.Deliberate non-coverage is still allowed, but it now has to be written down.
util/test_lane_allowlist.ymlexempts a file only with a one-line reason (hardware no runner has, a live third-party account, a multi-hour stress run), and the checker fails on a stale entry — one naming a deleted file, or one a lane has since started running. It ships empty on purpose: pre-filling it with all 42 would record accumulated drift as a decision, which is exactly what it isn't.Closes #4121 (the "files no lane names" half — see limits below).
What wiring it up as a gate would newly break
Nothing today, because it is deliberately not wired in — not registered in
util/lint.py(which lists its checkers explicitly, so dropping a file intoutil/does not enlist it) and not called from any workflow. Run it withpython util/check_test_lane_coverage.py.Turning it into a blocking gate right now would fail every PR on 42 offenders: 29 in
tests/integration/, 6 at thetests/root, 5 intests/mcp/, 1 intests/installer/, 1 intests/stress/. Most need a live Lemonade, a real mailbox, or a GPU and belong in the allowlist; a handful (tests/mcp/test_port_map.pyamong them) are pure unit tests that just need adding to an existing lane. That triage is the follow-up, not this PR.Two limits worth knowing before reading the number:
pytest.importorskipfor a dependency that lane never installs — counts as covered here. That is the other half of ci: nothing verifies that a test file is actually run by any CI lane #4121 and needs a separate--collect-onlyguard.workflow_dispatchworkflow passes while never running on a PR.tests/installer/test_custom_agent_mcp_harness.pyis exactly this case, which is why the count is 42 and not the 43 in the issue.Test plan
python -m pytest tests/unit/test_check_test_lane_coverage.py -q→ 36 passed. Each test builds an ephemeral repo intmp_path, so the suite does not move when the real repo's coverage changes.python util/check_test_lane_coverage.py→ exits 1 listing 42 files, and no unresolved-expression errors.grep -rn "test_port_map" .github/returns nothing.tests/installer/test_custom_agent_mcp_harness.pyis named atbuild-installers.yml:1207inside a foldedrun: >block, and is correctly absent from the output.python util/lint.py --black --isortpasses.