Cover the lazy config init and restore the uv cache in CI

get_config() builds its instance on first use, so the branch was covered
only when a worker happened to call it before set_config(). Under xdist that
depends on how cases shard across workers, which varies with the core count:
covered locally, uncovered on the two-core runner. Assert it directly.

setup-uv v4 bundles a cache client the GitHub cache service now rejects with
400, so the uv cache never restored and every wheel was redownloaded. Bump
to v9 across all four workflows (build-docs was already drifting at v5).

setup-python read requires-python (">=3.12") and installed 3.14, which uv
then ignored in favour of .python-version (3.13) and downloaded itself.
Point it at .python-version so the interpreter it installs is the one used.
This commit is contained in:
Yiorgis Gozadinos 2026-07-27 13:35:50 +03:00
parent e186720a5e
commit 04ad3823b9
No known key found for this signature in database
5 changed files with 23 additions and 7 deletions

View file

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- uses: astral-sh/setup-uv@v9
- run: uv sync --group dev
- run: uv run zensical build
- uses: actions/configure-pages@v5

View file

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: astral-sh/setup-uv@v9
with:
enable-cache: true
- name: Set up Python

View file

@ -12,7 +12,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: astral-sh/setup-uv@v9
with:
enable-cache: true
- name: Set up Python

View file

@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: astral-sh/setup-uv@v9
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
python-version-file: ".python-version"
- name: Install dependencies
run: uv sync --all-extras
- name: Lint
@ -52,13 +52,13 @@ jobs:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: astral-sh/setup-uv@v9
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
python-version-file: ".python-version"
- name: Install dependencies
run: uv sync --all-extras
- name: Cache HuggingFace models

View file

@ -541,3 +541,19 @@ def test_load_default_config_falls_back_to_builtin_defaults(monkeypatch):
config = _load_default_config()
assert config.model_dump() == AppConfig().model_dump()
def test_get_config_initialises_lazily_then_reuses(monkeypatch):
"""get_config() builds the instance on first use and caches it.
Asserted explicitly rather than relying on some test happening to be the
first caller in its worker process: under xdist that depends on how cases
shard across workers, which varies with the core count.
"""
from haiku.rag import config as config_module
monkeypatch.setattr(config_module, "_config", None)
first = config_module.get_config()
assert isinstance(first, AppConfig)
assert config_module.get_config() is first