Skip to content

ci(util): find test files that no CI lane ever runs - #4124

Merged
kovtcharov-amd merged 1 commit into
mainfrom
ci/test-lane-coverage-checker
Sep 24, 2026
Merged

kovtcharov-amd merged 1 commit into
mainfrom
ci/test-lane-coverage-checker

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

A test file that no CI lane runs is indistinguishable from one that passes: it never appears in a collected N items line, 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 entire tests/mcp/ stdio set and 29 files under tests/integration/.

Deliberate non-coverage is still allowed, but it now has to be written down. util/test_lane_allowlist.yml exempts 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 into util/ does not enlist it) and not called from any workflow. Run it with python 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 the tests/ root, 5 in tests/mcp/, 1 in tests/installer/, 1 in tests/stress/. Most need a live Lemonade, a real mailbox, or a GPU and belong in the allowlist; a handful (tests/mcp/test_port_map.py among 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:

  • Named by a lane ≠ executed there. A file a lane collects and then skips wholesale — a module-scope pytest.importorskip for 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-only guard.
  • Release-only lanes count the same as PR lanes. A file named only by a workflow_dispatch workflow passes while never running on a PR. tests/installer/test_custom_agent_mcp_harness.py is 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 in tmp_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.
  • Spot-check a claimed offender: grep -rn "test_port_map" .github/ returns nothing.
  • Spot-check a non-offender the parser has to work to see: tests/installer/test_custom_agent_mcp_harness.py is named at build-installers.yml:1207 inside a folded run: > block, and is correctly absent from the output.
  • python util/lint.py --black --isort passes.

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.
@github-actions

Copy link
Copy Markdown
Contributor

Approve with suggestions

This 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:

  • The audit has a blind spot of its own. It only walks tests/ and the hub agents' suites, so three microphone/audio tests that live next to the code they test are invisible to it — and no workflow runs those either. The real number is 45, not 42, and the three that got missed are exactly the hardware-bound kind the allowlist exists for.
  • A test path mentioned in a shell comment counts as "covered." The parser decides a command is a test run if the word pytest appears anywhere in it, so a trailing # also run tests/integration on a pytest line silently credits that directory. Nothing in the repo trips this today, but a tool whose whole job is to not be fooled should not be fooled by a comment.

Real-world evidence

No evidence-bundle.md in the tree, so nothing was captured by the automated stage. This is a dev-facing utility with no runtime surface, so the only thing to exercise is the script itself — which I ran directly rather than resting on static review:

$ python util/check_test_lane_coverage.py
[!] 42 test file(s) are run by no CI lane. Each one looks like a pass on every PR whether it works or not. …
    - tests/installer/test_installer_scenarios.py
    - tests/integration/eval/test_sidecar_eval.py
    … (42 total; 29 under tests/integration/, 5 under tests/mcp/)
$ python -m pytest tests/unit/test_check_test_lane_coverage.py -q
36 passed

Both match the PR description exactly, including the count and the claim that no unresolved-${{ }} errors fire on the current workflow set. The test-plan checkboxes are unticked on the PR, but the runs above cover the first two items.

🔍 Technical details

🟡 Important

Test roots miss src/gaia/audio/tests/ — three uncovered files stay invisible (util/check_test_lane_coverage.py:59)

TEST_ROOT_GLOBS covers tests/ and hub/agents/*/python/tests, but the repo has a fourth in-tree suite:

src/gaia/audio/tests/test_talk_basic.py
src/gaia/audio/tests/test_audio_pipeline.py
src/gaia/audio/tests/test_mic_simple.py

All three are pytest-collectible (test_* functions in test_*.py), all three need a real microphone, and grep -rn "audio/tests" .github/ returns nothing — no lane names them. They are the textbook allowlist case, and the checker cannot see them. The only other out-of-root match is eval/tasks/toybox/tests/test_dates.py, which is fixture data for an eval task and should stay excluded.

TEST_ROOT_GLOBS = ("tests", "hub/agents/*/python/tests", "src/gaia/audio/tests")

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 tests/ and the hub suites only — but silently leaving a real test directory out of a coverage audit is the weaker option.

A path named in a comment or a non-command position is credited as coverage (util/check_test_lane_coverage.py:197)

_is_test_invocation returns True if any token in the command is pytest/python*, not if the command's head is. Shell comments are never stripped, so:

>>> 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 TestNonInvocationsAreNotCoverage cases pass only because their test paths sit inside quotes (_tokenise keeps a quoted run whole) — unquoted, echo credits the path. This is the silent-wrong-answer direction the docstring calls out: a file marked covered that nothing runs.

Two fixes, both cheap: strip everything from an unquoted # to end-of-command in _split_commands, and anchor the invocation test to the command head (skipping leading VAR=value assignments and wrapper words like uv run / &, all of which appear in the real workflows).

Same class, second instance (util/check_test_lane_coverage.py:218): value_flags omits --ignore and --deselect, so their spaced form credits the path being excluded —

>>> lane_paths_in_script("pytest tests/ --ignore tests/integration", {}, ["tests"])
({'tests', 'tests/integration'}, set())

The --ignore= form is safe (it starts with -, so it's dropped), and the repo only uses --cov= today, so this is latent rather than active. Worth adding to the set regardless:

    value_flags = {
        "-k",
        "-m",
        "-n",
        "-p",
        "--timeout",
        "--basetemp",
        "--rootdir",
        "--ignore",
        "--ignore-glob",
        "--deselect",
    }

🟢 Minor

Composite actions are only found one directory deep (util/check_test_lane_coverage.py:344) — action_dir.glob("*/action.yml") matches all five actions today, but an action nested at .github/actions/foo/bar/action.yml would be skipped without a word. rglob("action.y*ml") closes it for free, and this checker's own philosophy is that an unreadable lane is a hole in the audit, not something to pass over.

Dead glob branches in _under_any_root (util/check_test_lane_coverage.py:285) — the two if "*" in root branches can't fire: test_roots() expands TEST_ROOT_GLOBS to concrete directories before anything reaches here, and both call sites (including the tests) pass concrete roots. Harmless, but it reads as supported behaviour that no caller uses.

Strengths

  • The limits are stated where they'll be read. The docstring saying "named by a lane ≠ executed there" and "release-only lanes count the same as PR lanes" is what keeps the number from being over-read, and the PR repeats it rather than burying it. The 42 vs 43 discrepancy against ci: nothing verifies that a test file is actually run by any CI lane #4121 being explained rather than papered over is the right instinct.
  • The allowlist ships empty on purpose, and fails on stale entries both ways — an entry naming a deleted file and an entry a lane has since started running are both errors. That is what stops the allowlist from quietly becoming the place uncovered tests go to die.
  • Unresolved ${{ }} is an error, not a skip. Dropping it would understate coverage and manufacture false offenders; reporting it keeps the tool honest about what it couldn't read. Same call on unparseable YAML.
  • The tests build an ephemeral repo per case, so the suite doesn't move when the real repo's coverage changes — and the parser cases (node ids, PowerShell backtick continuation, Windows separators, -k values, tests/unit not covering tests/unit_extra) are chosen from the forms the real workflows actually use rather than invented.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit f1a53d8 Sep 24, 2026
43 of 45 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the ci/test-lane-coverage-checker branch September 24, 2026 17:05
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
…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]>
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 22, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: nothing verifies that a test file is actually run by any CI lane

2 participants