Add optional caching to setup-uv (#822)
This commit is contained in:
@@ -25,6 +25,8 @@ jobs:
|
||||
with:
|
||||
python-version: "3.14"
|
||||
activate-environment: true
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "pyproject.toml"
|
||||
- run: |
|
||||
uv --version
|
||||
python -c "import os, sys; assert sys.version_info[:2] == (3, 14); assert os.environ['VIRTUAL_ENV'].endswith(r'\.venv')"
|
||||
@@ -44,6 +46,8 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
activate-environment: true
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "pyproject.toml"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
||||
+1
-1
@@ -28,4 +28,4 @@
|
||||
# ├── test_summarize_pr.py
|
||||
# └── ...
|
||||
|
||||
__version__ = "0.2.28"
|
||||
__version__ = "0.2.29"
|
||||
|
||||
+8
-4
@@ -9,11 +9,15 @@ Installs the latest [uv](https://docs.astral.sh/uv/) release with retry support
|
||||
with:
|
||||
python-version: "3.14"
|
||||
activate-environment: true
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "pyproject.toml"
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
| Input | Description | Required | Default |
|
||||
| ---------------------- | ----------------------------------------- | -------- | ------- |
|
||||
| `python-version` | Python version for uv commands | No | - |
|
||||
| `activate-environment` | Create and activate a `.venv` environment | No | `false` |
|
||||
| Input | Description | Required | Default |
|
||||
| ----------------------- | ----------------------------------------- | -------- | ------------ |
|
||||
| `python-version` | Python version for uv commands | No | - |
|
||||
| `activate-environment` | Create and activate a `.venv` environment | No | `false` |
|
||||
| `enable-cache` | Cache uv downloads between workflow runs | No | `false` |
|
||||
| `cache-dependency-glob` | Dependency files used to invalidate cache | No | `**/uv.lock` |
|
||||
|
||||
@@ -11,6 +11,14 @@ inputs:
|
||||
description: "Create and activate a .venv environment"
|
||||
required: false
|
||||
default: "false"
|
||||
enable-cache:
|
||||
description: "Cache uv downloads between workflow runs"
|
||||
required: false
|
||||
default: "false"
|
||||
cache-dependency-glob:
|
||||
description: "Dependency files used to invalidate the uv cache"
|
||||
required: false
|
||||
default: "**/uv.lock"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
@@ -49,3 +57,17 @@ runs:
|
||||
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Find uv cache
|
||||
if: inputs.enable-cache == 'true'
|
||||
id: uv-cache
|
||||
shell: bash
|
||||
run: echo "path=$(uv cache dir)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache uv
|
||||
if: inputs.enable-cache == 'true'
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ${{ steps.uv-cache.outputs.path }}
|
||||
key: uv-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ hashFiles(inputs.cache-dependency-glob) }}
|
||||
restore-keys: uv-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-
|
||||
|
||||
Reference in New Issue
Block a user