Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

ci(milvus): add a job that installs the milvus extra so its tests actually run (#5772)

LearningCircuit9b015b10d9b0
diff --git a/.github/workflows/milvus-tests.yml b/.github/workflows/milvus-tests.yml
new file mode 100644
index 0000000000..f99e3959b2
--- /dev/null
+++ b/.github/workflows/milvus-tests.yml
@@ -0,0 +1,410 @@
+name: Milvus Vector Store Tests
+
+# Why this job exists (#5764).
+#
+# A bare `pdm install` does not install the default group alone: it installs
+# the groups recorded in `pdm.lock` (`[metadata] groups`, today
+# `["default", "dev", "mcp"]`). The shared `ldr-test` image runs
+# `pdm install --no-editable` with the lockfile present (Dockerfile, stage
+# `ldr-test`), so once `milvus` is relocked into `pdm.lock` the docker test
+# matrix installs the extra as well and `docker-tests.yml` runs
+# `tests/vector_stores/` unskipped.
+#
+# Two things this job adds on top of `docker-tests`:
+#
+# (a) Coverage that does not depend on `pdm.lock` recording the group. The
+# install step deliberately does NOT pass `-G milvus`. `pdm install -G
+# <group>` runs `GroupSelection.validate()` (pdm/cli/filters.py), which
+# raises `PdmUsageError: Requested groups not in lockfile: milvus`
+# unconditionally once the group is declared in `pyproject.toml` but
+# absent from the lock — so `-G` would tie this job to the lock rather
+# than free it from it. The job runs plain `pdm install --no-editable`
+# instead — no `-G` and no `--dev`: `--dev` leaves
+# `GroupSelection.is_unset` False and so skips the "install exactly the
+# groups the lock records" shortcut (pdm/cli/filters.py), which would
+# drop `mcp`. It then installs the extra's own requirement strings, read
+# out of `pyproject.toml`, with the *host* pip aimed at pdm's
+# interpreter: `pip --python "$(pdm info --python)" install -r ...`. pdm
+# creates its virtualenv with `venv.with_pip` false
+# (pdm/project/config.py), i.e. `virtualenv --no-pip --no-setuptools
+# --no-wheel`, so there is no pip *inside* that environment to call —
+# `pdm run python -m pip` would exit 1 with "No module named pip". The
+# host pip's `--python` needs no pip in the target. That works in all
+# three states: group undeclared, declared but not locked, declared and
+# locked.
+# That second install is a plain pip resolve against the environment pdm
+# just built, not a locked one: there is no `milvus` extra at head, so
+# the actual overlap with `pdm.lock`'s pins is unknown until #5331 lands
+# it; pip resolves the extra's requirement strings independently and may
+# replace whatever pinned versions do overlap — `setuptools`, a hard
+# pymilvus dependency, is already in the lock — and warns rather than
+# failing on a conflict. That is acceptable for a job whose purpose is
+# exercising Milvus, and it is why the shared `ldr-test` image, not this
+# job, remains the authoritative install.
+# Declaring `milvus` in `pyproject.toml` also changes the lock's
+# `content_hash`, so until the lock is refreshed `pdm install` sees a
+# stale lockfile (`check_lockfile` returns "reuse") and re-resolves and
+# rewrites `pdm.lock` over the network before syncing — network work
+# inside this job's `timeout-minutes`. It re-resolves the lock's own
+# groups, so that rewrite does not pull `milvus` in. The same re-lock
+# happens inside the Docker `ldr-test` build too (Dockerfile:140 `FROM
+# builder-base AS ldr-test`, :261 `pdm install --no-editable`), not only
+# in this job.
+# When the lock is refreshed, use `pdm lock -G:all`. Plain
+# `pdm lock -G milvus` rewrites `[metadata] groups` without `mcp`, which
+# would break .github/workflows/mcp-tests.yml.
+#
+# (b) A step that fails when no Milvus test case ran, behind a dedicated
+# path-filtered status that reports on `vector_stores`,
+# `pyproject.toml` and `pdm.lock` changes alone. `docker-tests` runs the
+# whole suite and reports green when the Milvus tests skip; the
+# `assert-ran` step below reads the junit report per test module, so
+# "installed nothing" and "skipped every Milvus test" both become
+# failures. It is not a proof that a particular Milvus test ran: one
+# unguarded test in the module satisfies it.
+#
+# #5331 is expected to add the backend, the `milvus` optional-dependency
+# group, and tests that guard themselves with
+# `pytest.mark.skipif(find_spec("pymilvus") is None ...)`. Guards of that
+# shape skip silently when the extra is missing, which is how a green suite
+# can cover nothing (#5764).
+#
+# .github/workflows/mcp-tests.yml has the same shape for the `mcp` group.
+#
+# The test step sets `LDR_TESTING_WITH_MOCKS: "false"` deliberately, rather
+# than dropping the variable: `tests/conftest.py` defaults it to `"true"`
+# when unset, so removing the `env:` block would change nothing. Under
+# `"true"` that conftest skips every `@pytest.mark.integration` test, and a
+# test that spins up a real milvus-lite instance is exactly what carries that
+# marker — the one thing this job exists to run. Only `tests/vector_stores/`
+# is collected, and nothing there is marked `integration` or `requires_llm`
+# today, so the setting is inert until #5331 lands.
+
+on:
+ push:
+ branches: [ main ]
+ paths:
+ - 'src/local_deep_research/vector_stores/**'
+ - 'tests/vector_stores/**'
+ - 'pyproject.toml'
+ - 'pdm.lock'
+ - '.github/workflows/milvus-tests.yml'
+ pull_request:
+ branches: [ main ]
+ paths:
+ - 'src/local_deep_research/vector_stores/**'
+ - 'tests/vector_stores/**'
+ - 'pyproject.toml'
+ - 'pdm.lock'
+ - '.github/workflows/milvus-tests.yml'
+ workflow_dispatch:
+
+# No concurrency group — intentionally omitted, for the same reason as
+# mcp-tests.yml (see the note there: #3554, reverted in #3599).
+
+permissions:
+ contents: read
+
+jobs:
+ milvus-tests:
+ name: Milvus Vector Store Tests
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+
+ steps:
+ - name: Harden the runner (Audit all outbound calls)
+ uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
+ with:
+ egress-policy: audit
+
+ - name: Checkout code
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Set up Python
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: '3.12'
+
+ # The Milvus backend and its `milvus` optional-dependency group land in
+ # #5331. Until they do, the install step has no requirement strings to
+ # install and the test step has nothing Milvus-specific to collect — a
+ # silently empty run is precisely the failure mode #5764 is about, which
+ # is why this gate checks all three prerequisites are present before
+ # anything relies on them. Skip only when the feature is entirely
+ # absent; a partial setup must fail instead of silently losing coverage.
+ - name: Check if Milvus backend exists
+ id: check-milvus
+ run: |
+ python - <<'PY'
+ import os
+ from pathlib import Path
+ import sys
+ import tomllib
+
+ # These three names are matched exactly, and the rule is
+ # all-or-nothing: a rename of the backend module, the test module or
+ # the extra must update them here, or the gate reports "entirely
+ # absent" and this job silently runs nothing (#5764 in a narrower
+ # form). A module can land either as `<name>.py` or as a package
+ # directory holding `<name>/__init__.py`, and
+ # `Path("<name>.py").exists()` is False in the package case — so both
+ # shapes are checked explicitly rather than relying on one path test.
+ # Both shapes must be a *file*: a PEP 420 namespace directory
+ # (`<name>/` with no `__init__.py`) is deliberately not accepted, so a
+ # backend shipped that way fails this gate loudly instead of being
+ # skipped past.
+ def module_present(stem):
+ return Path(stem + ".py").is_file() or Path(stem, "__init__.py").is_file()
+
+ config = tomllib.loads(Path("pyproject.toml").read_text())
+ extras = config.get("project", {}).get("optional-dependencies", {})
+ present = {
+ "backend": module_present(
+ "src/local_deep_research/vector_stores/implementations/milvus_store"
+ ),
+ "tests": module_present("tests/vector_stores/test_milvus_store"),
+ "milvus extra": "milvus" in extras,
+ }
+ if any(present.values()) and not all(present.values()):
+ missing = ", ".join(name for name, exists in present.items() if not exists)
+ sys.exit("Incomplete Milvus setup; missing: " + missing)
+ exists = all(present.values())
+ if exists:
+ requirements = extras["milvus"]
+ if not isinstance(requirements, list) or not requirements or not all(
+ isinstance(item, str) and item.strip() for item in requirements
+ ):
+ sys.exit("The milvus extra must contain dependency requirements")
+ with open(os.environ["GITHUB_OUTPUT"], "a") as output:
+ output.write(f"milvus_exists={str(exists).lower()}\n")
+ print("Milvus prerequisites present" if exists else "Milvus feature entirely absent; skipping")
+ PY
+
+ - name: Install dependencies
+ id: install
+ if: steps.check-milvus.outputs.milvus_exists == 'true'
+ run: |
+ python -m pip install pip==26.2
+ pip install pdm==2.26.2
+
+ # Bare locked install — no `-G milvus` and no `--dev`. See (a) in
+ # the header: `-G` on a declared-but-unlocked group is a hard
+ # `PdmUsageError`, which would make this job's coverage conditional
+ # on the lock, and `--dev` turns off the "install exactly the groups
+ # the lock records" shortcut and would drop `mcp`.
+ pdm install --no-editable
+
+ python - <<'PY'
+ from pathlib import Path
+ import tomllib
+
+ config = tomllib.loads(Path("pyproject.toml").read_text())
+ requirements = config["project"]["optional-dependencies"]["milvus"]
+ Path("milvus-requirements.txt").write_text(
+ "".join(item + "\n" for item in requirements)
+ )
+ print("milvus extra requirements:\n " + "\n ".join(requirements))
+ PY
+
+ # Then the extra itself, from its own requirement strings, with the
+ # host pip installed above aimed at pdm's interpreter. pdm creates
+ # its virtualenv with `venv.with_pip` false (pdm/project/config.py
+ # -> `virtualenv --no-pip --no-setuptools --no-wheel`), so
+ # `pdm run python -m pip` exits 1 with "No module named pip"; the
+ # host pip's `--python` needs no pip in the target. `--python` is a
+ # general option, so it must precede the `install` subcommand —
+ # `pip install --python ...` is rejected outright. `pdm info
+ # --python` prints just that interpreter path on stdout.
+ #
+ # pip resolves these requirements against the environment pdm just
+ # built and evaluates PEP 508 markers (so a milvus-lite requirement
+ # carrying `sys_platform != "win32"` behaves the same way it would
+ # under pdm), and it needs no `[metadata] groups` entry to do it.
+ # It is an unlocked resolve: it may replace versions `pdm.lock`
+ # pins (`numpy`, `pandas`, `pyarrow`), which is acceptable here and
+ # is why `ldr-test` stays the authoritative install.
+ PDM_PY="$(pdm info --python)"
+ pip --python "$PDM_PY" install -r milvus-requirements.txt
+
+ # The whole point of this job is exercising Milvus. If the extra failed
+ # to install, the skipif guards in the tests would quietly skip and the
+ # job would report green — exactly the failure mode #5764 is about. Fail
+ # loudly here instead. This check lives in the job, not in the test
+ # module, so a local run without the extra still skips as intended.
+ - name: Verify the Milvus extra actually installed
+ id: verify
+ if: steps.check-milvus.outputs.milvus_exists == 'true'
+ run: |
+ pdm run python - <<'PY'
+ import importlib
+ from pathlib import Path
+ import re
+ import tomllib
+
+ # `pymilvus` is the client any Milvus backend needs, so it is
+ # required unconditionally. `milvus_lite` — the embedded server — is
+ # required only when the extra actually requires a distribution named
+ # `milvus-lite`/`milvus_lite`. Hard-requiring it would block #5331
+ # for an unrelated reason if its extra turns out to be plain
+ # `pymilvus` with milvus-lite left opt-in.
+ config = tomllib.loads(Path("pyproject.toml").read_text())
+ requirements = config["project"]["optional-dependencies"]["milvus"]
+
+ # Compare the requirement's *name* token, not the whole string: a
+ # direct URL such as
+ # `pymilvus @ https://example.com/milvus-lite-shim.whl` contains
+ # "milvus-lite" but does not require that distribution. The name ends
+ # at the first extras bracket, URL marker, environment marker,
+ # version specifier or space.
+ def requirement_name(item):
+ token = re.split(r"[\[@;=<>~!,\s]", item.strip(), maxsplit=1)[0]
+ return token.strip().lower().replace("_", "-")
+
+ wants_lite = any(requirement_name(item) == "milvus-lite" for item in requirements)
+
+ modules = ["pymilvus"]
+ if wants_lite:
+ modules.append("milvus_lite")
+ for name in modules:
+ importlib.import_module(name)
+ print("Imported successfully: " + ", ".join(modules))
+ PY
+
+ # Runs the whole vector_stores suite, not just test_milvus_store.py: the
+ # facade and config-resolution tests also grow Milvus branches, and they
+ # are cheap. Because the suite is mostly non-Milvus tests that always
+ # run, the next step checks the junit report per test module rather than
+ # in aggregate — a whole-directory count cannot tell "the Milvus tests
+ # passed" from "the Milvus tests all skipped".
+ - name: Run vector store tests with the Milvus extra
+ id: tests
+ if: steps.check-milvus.outputs.milvus_exists == 'true'
+ run: |
+ pdm run pytest tests/vector_stores/ -v --tb=short -ra -n auto \
+ --junitxml=milvus-junit.xml
+ env:
+ LDR_TESTING_WITH_MOCKS: "false"
+
+ # `pytest` exits 0 on an all-skipped run, and `tests/vector_stores/`
+ # holds ~174 tests that always run, so any whole-suite count stays green
+ # while every Milvus test skips — #5764 again, inside the step meant to
+ # prevent it. This step therefore looks at the individual `<testcase>`
+ # elements belonging to Milvus modules. Pure stdlib, so it needs no
+ # interpreter beyond the runner's.
+ #
+ # `!cancelled()` overrides the implicit `success()`, so a failed `tests`
+ # step still reaches this check instead of skipping it: a pytest run that
+ # dies before writing a usable report must be reported as a missing
+ # report, not silently passed over. It therefore also runs after a failed
+ # `install` or `verify`, where it adds a second failure reading
+ # "milvus-junit.xml was not written" — a redundant signal, not a
+ # replacement: the real cause stays visible in the step list and in the
+ # summary table below.
+ - name: Assert the Milvus tests actually ran
+ id: assert-ran
+ if: steps.check-milvus.outputs.milvus_exists == 'true' && !cancelled()
+ run: |
+ python - <<'PY'
+ from pathlib import Path
+ import sys
+ import xml.etree.ElementTree as ET
+
+ report = Path("milvus-junit.xml")
+ if not report.is_file():
+ sys.exit("milvus-junit.xml was not written; pytest produced no report")
+ try:
+ root = ET.parse(report).getroot()
+ except ET.ParseError as exc:
+ sys.exit(f"milvus-junit.xml is not parseable XML: {exc}")
+
+ # pytest tags every `<testcase>` with `classname`, the dotted module
+ # path of the test (`tests.vector_stores.test_milvus_store.TestFoo`).
+ # Under the default `junit_family = xunit2` that is the only locating
+ # attribute emitted; the legacy families add `file` as well, so both
+ # are checked and either one matching is enough.
+ cases = [
+ case
+ for case in root.iter("testcase")
+ if "milvus" in (case.get("classname", "") + "\n" + case.get("file", "")).lower()
+ ]
+ # A module that fails to import is not reported in the shape above:
+ # pytest's `mangle_test_address` returns a single element for a
+ # collection failure, so `classname` is empty and the dotted module
+ # path lands in `name` instead. Detect that separately, or it reads
+ # as "nothing was collected", which points at the wrong cause.
+ collection_errors = [
+ case
+ for case in root.iter("testcase")
+ if not case.get("classname")
+ and case.find("error") is not None
+ and "milvus" in case.get("name", "").lower()
+ ]
+ if not cases:
+ if collection_errors:
+ sys.exit(
+ "Milvus test collection failed: "
+ + ", ".join(case.get("name", "?") for case in collection_errors)
+ )
+ sys.exit(
+ "No Milvus test cases in the junit report — the milvus extra "
+ "was installed but nothing that tests it was collected"
+ )
+
+ # An errored case did not run either: its body never completed, so
+ # counting it as coverage would overstate what the job proved. The
+ # `tests` step already fails the job on an error; this only keeps the
+ # message honest.
+ ran, skipped, errored = [], [], []
+ for case in cases:
+ if case.find("error") is not None:
+ errored.append(case)
+ elif case.find("skipped") is not None:
+ skipped.append(case)
+ else:
+ ran.append(case)
+ if not ran:
+ sys.exit(
+ f"No Milvus test case ran: of {len(cases)} collected, "
+ f"{len(skipped)} skipped and {len(errored)} errored — "
+ "installing the milvus extra bought no coverage"
+ )
+ print(
+ f"{len(ran)} of {len(cases)} Milvus test cases ran "
+ f"({len(skipped)} skipped, {len(errored)} errored)"
+ )
+ PY
+
+ - name: Skip notice
+ if: steps.check-milvus.outputs.milvus_exists != 'true'
+ run: |
+ echo "::notice::Milvus vector store not yet implemented. Tests will run once #5331 is merged."
+
+ - name: Generate test summary
+ if: always()
+ env:
+ MILVUS_EXISTS: ${{ steps.check-milvus.outputs.milvus_exists }}
+ DETECTION_OUTCOME: ${{ steps.check-milvus.outcome }}
+ INSTALL_OUTCOME: ${{ steps.install.outcome }}
+ VERIFY_OUTCOME: ${{ steps.verify.outcome }}
+ TEST_OUTCOME: ${{ steps.tests.outcome }}
+ RAN_OUTCOME: ${{ steps.assert-ran.outcome }}
+ run: |
+ {
+ echo "## Milvus Vector Store Test Summary"
+ echo ""
+ if [ "$DETECTION_OUTCOME" != "success" ]; then
+ echo "Milvus prerequisite detection did not succeed: $DETECTION_OUTCOME"
+ elif [ "$MILVUS_EXISTS" != "true" ]; then
+ echo "Milvus backend, tests, and optional-dependency group are entirely absent."
+ echo "Tests will run automatically once #5331 is merged."
+ else
+ echo "| Step | Outcome |"
+ echo "|---|---|"
+ echo "| Install Milvus extra | $INSTALL_OUTCOME |"
+ echo "| Import the Milvus client modules | $VERIFY_OUTCOME |"
+ echo "| Vector store tests | $TEST_OUTCOME |"
+ echo "| Milvus tests actually ran (not all skipped) | $RAN_OUTCOME |"
+ fi
+ } >> "$GITHUB_STEP_SUMMARY"
diff --git a/docs/ci/workflow-status.md b/docs/ci/workflow-status.md
index f5cb5f23fb..d06bb47bb2 100644
--- a/docs/ci/workflow-status.md
+++ b/docs/ci/workflow-status.md
@@ -144,3 +144,21 @@
| `ldr-research-reusable.yml` | never | workflow_call | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ldr-research-reusable.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ldr-research-reusable.yml) |
<!-- END GENERATED -->
+
+## Pending regeneration
+
+Workflows added since the last dashboard regeneration. Regenerating
+(`pdm run python scripts/generate_workflow_status.py`) needs an
+authenticated `gh`, and it rewrites every "last activity" bucket on the
+page — noise a single-workflow PR shouldn't carry. This is the
+placeholder region that `check-workflow-status.yml` documents for that
+case. It sits outside the generated markers, so a regeneration preserves
+it verbatim: delete the row below by hand once the real one appears in
+the table above.
+
+- `milvus-tests.yml` — never run yet; push:main, PR, manual. Path-filtered
+ to `src/local_deep_research/vector_stores/**`, `tests/vector_stores/**`,
+ `pyproject.toml`, `pdm.lock`, `.github/workflows/milvus-tests.yml`.
+ Self-gates until the Milvus backend and the `milvus` optional-dependency
+ group land (#5331). Partial setups fail; only an entirely absent feature
+ is skipped.