Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/actions/setup-uv-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Set up uv and managed Python
description: >-
Pins uv (avoids the raw.githubusercontent.com manifest fetch on cache miss)
and proactively installs the requested Python so cached venvs resolve their
interpreter symlinks in jobs that only restore the venv. setup-uv alone
only sets UV_PYTHON, it does not actually fetch the interpreter until uv
first uses it, so jobs that just activate a cached venv blow up with
broken symlinks on cache hit.

inputs:
python-version:
description: The Python version uv should install and use.
required: true
uv-version:
description: The uv version setup-uv should install.
required: true

outputs:
python-version:
description: The Python version uv reports as installed.
value: ${{ steps.uv.outputs.python-version }}

runs:
using: composite
steps:
- name: Set up uv
id: uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: ${{ inputs.uv-version }}
python-version: ${{ inputs.python-version }}
# Persist astral's managed Python across jobs so 'uv venv' / poetry
# env use below is fast on the second job onwards.
cache-python: true
# Jobs that only configure the toolchain (no deps to cache) would
# otherwise abort with "Nothing to cache" on the post step.
ignore-nothing-to-cache: true
- name: Install Python interpreter
shell: bash
env:
PYTHON_VERSION: ${{ inputs.python-version }}
# 'uv python install' on Windows blows up with a reparse-point tag
# mismatch (os error 4394) when cache-python: true already restored
# the install dir, so only install when find says we have nothing yet.
run: |
if ! uv python find "${PYTHON_VERSION}" >/dev/null 2>&1; then
uv python install "${PYTHON_VERSION}"
fi
25 changes: 14 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ concurrency:
env:
POETRY_VIRTUALENVS_IN_PROJECT: "true"
UV_PYTHON_PREFERENCE: only-managed
UV_VERSION: "0.11.16"

jobs:
lint:
Expand Down Expand Up @@ -55,30 +56,29 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Set up uv and Python ${{ matrix.python-version }}
id: python
uses: ./.github/actions/setup-uv-python
with:
enable-cache: true
uv-version: ${{ env.UV_VERSION }}
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: uv tool install poetry
- name: Set up Python
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
allow-prereleases: true
shell: bash
- name: Cache poetry venv
id: cache-venv
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
.venv
src/habluetooth/**/*.so
key: venv-v2-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ matrix.extension }}-${{ hashFiles('poetry.lock', 'pyproject.toml', 'build_ext.py', 'src/habluetooth/**/*.py', 'src/habluetooth/**/*.pxd') }}
key: venv-v3-${{ runner.os }}-py${{ steps.python.outputs.python-version }}-${{ matrix.extension }}-${{ hashFiles('poetry.lock', 'pyproject.toml', 'build_ext.py', 'src/habluetooth/**/*.py', 'src/habluetooth/**/*.pxd') }}
- name: Install Dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
poetry env use "$(uv python find "${PYTHON_VERSION}")"
if [ "${{ matrix.extension }}" = "skip_cython" ]; then
SKIP_CYTHON=1 poetry install --only=main,dev
else
Expand All @@ -94,6 +94,9 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}

benchmark:
# Keep actions/setup-python here so codspeed history stays comparable;
# astral's managed Python ships PGO/LTO/BOLT/mimalloc which would shift
# the baseline.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
Expand Down
Loading