From 1c9631c81cf82db6546bfc42bfcf1e99bdf02a73 Mon Sep 17 00:00:00 2001 From: Tomas Pereira de Vasconcelos Date: Fri, 24 Jul 2026 19:52:30 +0200 Subject: [PATCH 1/3] Use astral-sh/setup-uv in the setup-python composite action --- .github/actions/setup-python/action.yml | 44 +++++-------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index b0ab2917..8af38782 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -6,12 +6,6 @@ inputs: python-version: description: "Python version (e.g. '3.7', '3.8.13', '3.11.0-alpha.1', '3.x')." required: true - install-seed-packages: - description: > - Set to 'true' to install and/or upgrade seed packages (pip, setuptools, and wheel) - before installing other packages. - required: false - default: "false" requirements: description: "Optional list of arguments passed to `uv pip install` (e.g. 'numpy==1.19.5', '-r requirements.txt')." required: false @@ -23,37 +17,17 @@ runs: with: python-version: "${{ inputs.python-version }}" + # Install uv and enable its built-in cache. The cache key takes the + # platform, the uv version, and a hash of the files below into account. + # See https://docs.astral.sh/uv/guides/integration/github/ for details. - name: Install uv - shell: bash - run: pip install --upgrade uv - - # >>>>>>>> Caching uv packages >>>>>>>> - - - name: Get uv cache dir - id: uv-cache - shell: bash - run: echo "dir=$(uv cache dir)" >> $GITHUB_OUTPUT - - - name: Get the current date in format YYYYWW (year and week-of-year) - id: get-date - shell: bash - run: echo "date=$(/bin/date -u "+%Y%U")" >> $GITHUB_OUTPUT - - - name: uv cache - uses: actions/cache@v4 + uses: astral-sh/setup-uv@v9 with: - path: ${{ steps.uv-cache.outputs.dir }} - # The cache's TTL is 7 days (one week) - key: uv-${{ runner.os }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.date }} - # Fall back to the previous week's cache - restore-keys: uv-${{ runner.os }}-${{ inputs.python-version }}- - - # <<<<<<<< Caching uv packages <<<<<<<< - - - name: Install and/or upgrade seed packages - if: ${{ inputs.install-seed-packages == 'true' }} - shell: bash - run: uv pip install --verbose --system --upgrade pip setuptools wheel + enable-cache: true + cache-suffix: "py${{ inputs.python-version }}" + cache-dependency-glob: | + pyproject.toml + requirements/*.txt - name: Install requirements if: ${{ inputs.requirements != '' }} From 141918de6728437aec241a8272166c46609ed634 Mon Sep 17 00:00:00 2001 From: Tomas Pereira de Vasconcelos Date: Fri, 24 Jul 2026 19:53:09 +0200 Subject: [PATCH 2/3] Add changelog entry for PR 386 --- docs/reference/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/changelog.md b/docs/reference/changelog.md index e7bf832f..6fb9d655 100644 --- a/docs/reference/changelog.md +++ b/docs/reference/changelog.md @@ -13,6 +13,7 @@ Unreleased changes - Bump codecov/codecov-action from 5 to 6 ({gh-pr}`371`) - Bump actions/github-script from 8 to 9 ({gh-pr}`373`) - pre-commit autoupdate ({gh-pr}`374`) +- Use the official `astral-sh/setup-uv` action to install and cache `uv` in CI ({gh-pr}`386`) --- From 4de9e700d67439068c2ef952a7251906ae038e1f Mon Sep 17 00:00:00 2001 From: Tomas Pereira de Vasconcelos Date: Fri, 24 Jul 2026 20:08:10 +0200 Subject: [PATCH 3/3] Pin astral-sh/setup-uv to an exact version (immutable releases only) --- .github/actions/setup-python/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index 8af38782..47c3fb6a 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -20,8 +20,10 @@ runs: # Install uv and enable its built-in cache. The cache key takes the # platform, the uv version, and a hash of the files below into account. # See https://docs.astral.sh/uv/guides/integration/github/ for details. + # NOTE: setup-uv publishes immutable releases only (no + # floating major tags), so we pin the full version - name: Install uv - uses: astral-sh/setup-uv@v9 + uses: astral-sh/setup-uv@v9.0.0 with: enable-cache: true cache-suffix: "py${{ inputs.python-version }}"