From 04ad3823b93d651f8ec4f13b1ea84c05f5a2329a Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Mon, 27 Jul 2026 13:35:50 +0300 Subject: [PATCH] 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. --- .github/workflows/build-docs.yml | 2 +- .github/workflows/build-publish-slim.yml | 2 +- .github/workflows/build-publish.yml | 2 +- .github/workflows/test.yml | 8 ++++---- tests/test_config.py | 16 ++++++++++++++++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index df1f835f..c11e4966 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -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 diff --git a/.github/workflows/build-publish-slim.yml b/.github/workflows/build-publish-slim.yml index 98c3364f..864805b0 100644 --- a/.github/workflows/build-publish-slim.yml +++ b/.github/workflows/build-publish-slim.yml @@ -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 diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 6855c1a7..ae458c27 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08a32aba..a67d820f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/tests/test_config.py b/tests/test_config.py index 21a07fc6..3bcdef6d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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