mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-01-31 14:31:25 +08:00
Set the cache-dependency-glob default to **/uv.lock
(#77)
We should aim for a solution with sane defaults that work as most users would expect it. The current default leads to a cache that is never invalidated and thus never updated. This also mirrors the default behaviors for setup-python which use `**/requirements.txt`, `**/Pipfile.lock` or `**/poetry.lock` Also make it clear that the uv cache on the filesystem can be uploaded to the GitHub Actions cache, but they are distinct things. Also make it clear that the local cache path can be changed without using `enable-cache: true`
This commit is contained in:
parent
4456fa154a
commit
8d65000ec9
66
README.md
66
README.md
@ -11,12 +11,12 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
|
||||
## Contents
|
||||
|
||||
- [Usage](#usage)
|
||||
- [Install specific version](#install-specific-version)
|
||||
- [Install latest version](#install-latest-version)
|
||||
- [Install the latest version (default)](#install-the-latest-version-default)
|
||||
- [Install a specific version](#install-a-specific-version)
|
||||
- [Validate checksum](#validate-checksum)
|
||||
- [Enable Caching](#enable-caching)
|
||||
- [Local cache path](#local-cache-path)
|
||||
- [Cache dependency glob](#cache-dependency-glob)
|
||||
- [Local cache path](#local-cache-path)
|
||||
- [GitHub authentication token](#github-authentication-token)
|
||||
- [How it works](#how-it-works)
|
||||
- [FAQ](#faq)
|
||||
@ -67,8 +67,13 @@ are automatically verified by this action. The sha265 hashes can be found on the
|
||||
### Enable caching
|
||||
|
||||
If you enable caching, the [uv cache](https://docs.astral.sh/uv/concepts/cache/) will be cached to
|
||||
the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes. The cache
|
||||
will always be reused on self-hosted runners.
|
||||
the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes.
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> On self-hosted runners this is usually not needed since the cache generated by uv
|
||||
> on the runner's filesystem is not removed after a run.
|
||||
> For more details see [Local cache path](#local-cache-path).
|
||||
|
||||
You can optionally define a custom cache key suffix.
|
||||
|
||||
@ -90,39 +95,21 @@ use it in subsequent steps. For example, to use the cache in the above case:
|
||||
run: echo "Cache was restored"
|
||||
```
|
||||
|
||||
#### Local cache path
|
||||
|
||||
If you want to save the cache to a local path other than the default path (`/tmp/setup-uv-cache`),
|
||||
specify the path with the `cache-local-path` input.
|
||||
|
||||
```yaml
|
||||
- name: Define a custom uv cache path
|
||||
uses: astral-sh/setup-uv@v2
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-local-path: "/path/to/cache"
|
||||
```
|
||||
|
||||
#### Cache dependency glob
|
||||
|
||||
If you want to control when the cache is invalidated, specify a glob pattern with the
|
||||
`cache-dependency-glob` input. The cache will be invalidated if any file matching the glob pattern
|
||||
changes. The glob matches files relative to the repository root.
|
||||
|
||||
```yaml
|
||||
- name: Define a cache dependency glob
|
||||
uses: astral-sh/setup-uv@v2
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
```
|
||||
> [!NOTE]
|
||||
> The default is `**/uv.lock`.
|
||||
|
||||
```yaml
|
||||
- name: Define a cache dependency glob
|
||||
uses: astral-sh/setup-uv@v2
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "**requirements*.txt"
|
||||
cache-dependency-glob: "**/requirements*.txt"
|
||||
```
|
||||
|
||||
```yaml
|
||||
@ -131,13 +118,34 @@ changes. The glob matches files relative to the repository root.
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: |
|
||||
**requirements*.txt
|
||||
**pyproject.toml
|
||||
**/requirements*.txt
|
||||
**/pyproject.toml
|
||||
```
|
||||
|
||||
```yaml
|
||||
- name: Never invalidate the cache
|
||||
uses: astral-sh/setup-uv@v2
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: ""
|
||||
```
|
||||
|
||||
### Local cache path
|
||||
|
||||
This action controls where uv stores its cache on the runner's filesystem.
|
||||
You can change the default (`/tmp/setup-uv-cache`) by
|
||||
specifying the path with the `cache-local-path` input.
|
||||
|
||||
```yaml
|
||||
- name: Define a custom uv cache path
|
||||
uses: astral-sh/setup-uv@v2
|
||||
with:
|
||||
cache-local-path: "/path/to/cache"
|
||||
```
|
||||
|
||||
### GitHub authentication token
|
||||
|
||||
This action uses the GitHub API to fetch the `uv` release artifacts. To avoid hitting the GitHub API
|
||||
This action uses the GitHub API to fetch the uv release artifacts. To avoid hitting the GitHub API
|
||||
rate limit too quickly, an authentication token can be provided via the `github-token` input. By
|
||||
default, the `GITHUB_TOKEN` secret is used, which is automatically provided by GitHub Actions.
|
||||
|
||||
|
@ -20,8 +20,8 @@ inputs:
|
||||
cache-dependency-glob:
|
||||
description:
|
||||
'Glob pattern to match files relative to the repository root to control
|
||||
the cache. e.g. "uv.lock"'
|
||||
required: false
|
||||
the cache.'
|
||||
default: "**/uv.lock"
|
||||
cache-suffix:
|
||||
description: "Suffix for the cache key"
|
||||
required: false
|
||||
|
Loading…
x
Reference in New Issue
Block a user