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
46 changes: 11 additions & 35 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,37 +17,19 @@ 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.
# NOTE: setup-uv publishes immutable releases only (no
# floating major tags), so we pin the full version
- 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.0.0
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 != '' }}
Expand Down
1 change: 1 addition & 0 deletions docs/reference/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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`)

---

Expand Down
Loading