Skip to content

Commit 8d65000

Browse files
authored
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`
1 parent 4456fa1 commit 8d65000

2 files changed

Lines changed: 36 additions & 28 deletions

File tree

README.md

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
1111
## Contents
1212

1313
- [Usage](#usage)
14-
- [Install specific version](#install-specific-version)
15-
- [Install latest version](#install-latest-version)
14+
- [Install the latest version (default)](#install-the-latest-version-default)
15+
- [Install a specific version](#install-a-specific-version)
1616
- [Validate checksum](#validate-checksum)
1717
- [Enable Caching](#enable-caching)
18-
- [Local cache path](#local-cache-path)
1918
- [Cache dependency glob](#cache-dependency-glob)
19+
- [Local cache path](#local-cache-path)
2020
- [GitHub authentication token](#github-authentication-token)
2121
- [How it works](#how-it-works)
2222
- [FAQ](#faq)
@@ -67,8 +67,13 @@ are automatically verified by this action. The sha265 hashes can be found on the
6767
### Enable caching
6868

6969
If you enable caching, the [uv cache](https://docs.astral.sh/uv/concepts/cache/) will be cached to
70-
the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes. The cache
71-
will always be reused on self-hosted runners.
70+
the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes.
71+
72+
> [!TIP]
73+
>
74+
> On self-hosted runners this is usually not needed since the cache generated by uv
75+
> on the runner's filesystem is not removed after a run.
76+
> For more details see [Local cache path](#local-cache-path).
7277

7378
You can optionally define a custom cache key suffix.
7479

@@ -90,54 +95,57 @@ use it in subsequent steps. For example, to use the cache in the above case:
9095
run: echo "Cache was restored"
9196
```
9297

93-
#### Local cache path
94-
95-
If you want to save the cache to a local path other than the default path (`/tmp/setup-uv-cache`),
96-
specify the path with the `cache-local-path` input.
97-
98-
```yaml
99-
- name: Define a custom uv cache path
100-
uses: astral-sh/setup-uv@v2
101-
with:
102-
enable-cache: true
103-
cache-local-path: "/path/to/cache"
104-
```
105-
10698
#### Cache dependency glob
10799

108100
If you want to control when the cache is invalidated, specify a glob pattern with the
109101
`cache-dependency-glob` input. The cache will be invalidated if any file matching the glob pattern
110102
changes. The glob matches files relative to the repository root.
111103

104+
> [!NOTE]
105+
> The default is `**/uv.lock`.
106+
112107
```yaml
113108
- name: Define a cache dependency glob
114109
uses: astral-sh/setup-uv@v2
115110
with:
116111
enable-cache: true
117-
cache-dependency-glob: "uv.lock"
112+
cache-dependency-glob: "**/requirements*.txt"
118113
```
119114

120115
```yaml
121-
- name: Define a cache dependency glob
116+
- name: Define a list of cache dependency globs
122117
uses: astral-sh/setup-uv@v2
123118
with:
124119
enable-cache: true
125-
cache-dependency-glob: "**requirements*.txt"
120+
cache-dependency-glob: |
121+
**/requirements*.txt
122+
**/pyproject.toml
126123
```
127124

128125
```yaml
129-
- name: Define a list of cache dependency globs
126+
- name: Never invalidate the cache
130127
uses: astral-sh/setup-uv@v2
131128
with:
132129
enable-cache: true
133-
cache-dependency-glob: |
134-
**requirements*.txt
135-
**pyproject.toml
130+
cache-dependency-glob: ""
131+
```
132+
133+
### Local cache path
134+
135+
This action controls where uv stores its cache on the runner's filesystem.
136+
You can change the default (`/tmp/setup-uv-cache`) by
137+
specifying the path with the `cache-local-path` input.
138+
139+
```yaml
140+
- name: Define a custom uv cache path
141+
uses: astral-sh/setup-uv@v2
142+
with:
143+
cache-local-path: "/path/to/cache"
136144
```
137145

138146
### GitHub authentication token
139147

140-
This action uses the GitHub API to fetch the `uv` release artifacts. To avoid hitting the GitHub API
148+
This action uses the GitHub API to fetch the uv release artifacts. To avoid hitting the GitHub API
141149
rate limit too quickly, an authentication token can be provided via the `github-token` input. By
142150
default, the `GITHUB_TOKEN` secret is used, which is automatically provided by GitHub Actions.
143151

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ inputs:
2020
cache-dependency-glob:
2121
description:
2222
'Glob pattern to match files relative to the repository root to control
23-
the cache. e.g. "uv.lock"'
24-
required: false
23+
the cache.'
24+
default: "**/uv.lock"
2525
cache-suffix:
2626
description: "Suffix for the cache key"
2727
required: false

0 commit comments

Comments
 (0)