Skip to content

Switch CI to astral-managed Python via setup-uv#171760

Draft
bdraco wants to merge 4 commits into
ci-cache-postgres-mariadb-depsfrom
ci-uv-managed-python
Draft

Switch CI to astral-managed Python via setup-uv#171760
bdraco wants to merge 4 commits into
ci-cache-postgres-mariadb-depsfrom
ci-uv-managed-python

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 21, 2026

Proposed change

Stacked on top of #171735. Run CI on astral's uv-managed Python, built with the PEP 744 tail call interpreter plus PGO, LTO, BOLT, and mimalloc. Setup goes through a new .github/actions/setup-uv-python composite that pins uv, installs the interpreter eagerly, and caches it via cache-python: true. Venv bootstrap uses uv venv, CACHE_VERSION is bumped.

Saves roughly 35 min of CPU time per CI run vs the parent PR. The pytest-full matrix groups each drop 90 to 330 s; pylint drops ~100 s; hassfest drops ~16 s. DB jobs are I/O bound so individual runs swing in both directions.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Replace actions/setup-python with astral-sh/setup-uv so every job uses
the python-build-standalone interpreter astral ships, which bakes in
the PEP 744 tail call interpreter on 3.14. setup-uv handles both
installing uv and provisioning the requested Python version, so the
venv bootstrap uses 'uv venv' instead of 'python -m venv' and there is
no longer a separate uv install step on cache miss.

Bumps CACHE_VERSION so the old setup-python venv caches are invalidated;
the venv symlinks would otherwise point at the absent hostedtoolcache
interpreter.
@home-assistant home-assistant Bot added cla-signed code-quality small-pr PRs with less than 30 lines. labels May 21, 2026
bdraco and others added 3 commits May 21, 2026 13:08
Mirrors esphome/esphome#16534. Without an explicit version, setup-uv
fetches uv.ndjson from raw.githubusercontent.com on every cache miss,
which periodically times out and fails the job. Expose the uv version
from requirements.txt via the info job and pass it to every setup-uv
call. Also set ignore-nothing-to-cache: true so jobs that do not touch
uv (e.g. gen-copilot-instructions) no longer fail on the post-step
cache save.
setup-uv only sets UV_PYTHON, it does not actually fetch the
interpreter; uv installs it lazily on the first 'uv venv' or
'uv pip install'. When the venv cache hits, no uv command runs, so
the cached venv's bin/python3 symlink points at an interpreter that
was never installed in this job and the next step that activates the
venv aborts with 'broken symlink'.

Extract setup-uv plus an explicit 'uv python install' into the
.github/actions/setup-uv-python composite action so every job that
restores the venv ends up with a real Python at the expected path.
Enable cache-python in the wrapper so subsequent jobs reuse astral's
download instead of refetching it.
@bdraco bdraco marked this pull request as ready for review May 21, 2026 21:56
@bdraco bdraco requested a review from a team as a code owner May 21, 2026 21:56
@bdraco bdraco marked this pull request as draft May 21, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed code-quality small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant