Commit Graph

53 Commits

Author SHA1 Message Date
Charlie Marsh
47a7f4fb2e Change prune-cache default to false (#967)
## Summary

This changes the default for `prune-cache` from `true` to `false`,
motivated by [#745](https://github.com/astral-sh/setup-uv/issues/745).
Users that want the existing behavior can continue to set `prune-cache:
true` explicitly.

Some history: I originally added [`uv cache prune
--ci`](https://github.com/astral-sh/uv/pull/5391) after looking at a
workload where the uv cache was ~2.2 GB, almost entirely due to the
enormous pre-built `torch` and `nvidia_cudnn_cu12` wheels ([original
analysis](https://github.com/actions/setup-python/issues/822#issuecomment-2248728264)).
Persisting and restoring thousands of extracted files through the GitHub
Actions cache could be slower than downloading the wheels again. In
contrast, wheels built from source can be very expensive to recreate.
The intent was to remove pre-built wheels while retaining locally-built
wheels.

`setup-uv` subsequently made pruning configurable, but defaulted
`prune-cache` to `true`; it also later enabled caching by default on
GitHub-hosted runners. As a result, the default configuration repeatedly
downloads pre-built wheels from PyPI even on a cache hit. That tradeoff
has become more important as uv adoption has grown: [the PyPI analysis
in
#745](https://github.com/astral-sh/setup-uv/issues/745#issuecomment-3867334064)
estimates that uv accounts for roughly half of reported CI downloads
from PyPI, and roughly 65-75% for `boto3`.

I ran the comparison across a few different workloads:

| Workload | PR | Packages | Cache: keep / prune / prune-ci | Warm
restore+sync: keep / prune / prune-ci | Downloads: prune / prune-ci |
|---|---:|---:|---:|---:|---:|
| Tiny | [#1](https://github.com/astral-sh/setup-uv-benchmarks/pull/1) |
19 | 6 / 6 / 2 MB | 0.3-0.4 / 0.3 / 0.4-0.5 s | 0 / 2 |
| Web | [#2](https://github.com/astral-sh/setup-uv-benchmarks/pull/2) |
65 | 43 / 43 / 7 MB | 0.6-1.0 / 0.5-0.6 / 1.5-1.7 s | 0 / 6 |
| Scientific |
[#3](https://github.com/astral-sh/setup-uv-benchmarks/pull/3) | 118 |
586 / 586 / 8 MB | 8.2-16.0 / 7.0-8.2 / 8.9-12.1 s | 0 / 19 |
| PySpark |
[#4](https://github.com/astral-sh/setup-uv-benchmarks/pull/4) | 19 |
1820 / 1820 / 436 MB | 9.9-21.1 / 10.5-11.0 / 5.0-7.0 s | 0 / 4 |
| CPU PyTorch |
[#5](https://github.com/astral-sh/setup-uv-benchmarks/pull/5) | 14 | 182
/ 182 / 1 MB | 3.0-6.0 / 3.6-4.0 / 5.7-6.4 s | 0 / 6 |
| CPU-PyTorch ML |
[#6](https://github.com/astral-sh/setup-uv-benchmarks/pull/6) | 137 |
346 / 346 / 10 MB | 7.4-18.0 / 8.8-8.9 / 9.7-11.9 s | 0 / 20 |
| CUDA PyTorch |
[#7](https://github.com/astral-sh/setup-uv-benchmarks/pull/7) | 201 |
2316 / 2315 / 16 MB | 30.2-67.9 / 31.0-63.6 / 33.3-36.7 s | 0 / 40 |

The CUDA workload intentionally reproduces the original `torch==2.1.1`
example. Keeping wheels again produces a ~2.3 GB Actions cache. Across
nine warm runs, restoring that cache ranged from slightly faster than
re-downloading to roughly twice as slow; pruning consistently
re-downloaded 40 distributions in ~33-37 seconds ([original
runs](https://github.com/astral-sh/setup-uv-benchmarks/actions/runs/29750292738),
[additional
runs](https://github.com/astral-sh/setup-uv-benchmarks/actions/runs/29761705492)).

I also tried running `uv cache prune --force` without `--ci` across
every workload, to see if it provided a useful middle ground. It did not
meaningfully reduce any of the caches: plain prune took 11-21 ms and
left the extracted cache and file count unchanged, including PySpark. On
these fresh caches, there are no dangling entries to remove; without
`--ci`, the pre-built wheels and unpacked source/build artifacts are
retained. The per-workload runs are linked in the table above.

So the original motivation still holds for very large CUDA or
source-heavy workloads, but it is not representative of the common case.
For smaller workloads, keeping pre-built wheels is generally faster and
avoids repeated PyPI traffic. This changes the default accordingly,
while retaining `prune-cache: true` as an opt-in for workloads where the
smaller cache is worthwhile.

Closes https://github.com/astral-sh/setup-uv/issues/745.
2026-07-20 20:25:19 +02:00
somaz
3faa3174e6 feat: support uv.lock as a version-file source (#918)
Adds `uv.lock` as a supported `version-file` source. When `uv` is locked
as a
dependency in `uv.lock`, the action now installs the exact pinned
version,
closing the gap reported in #682.

This is useful for deterministic CI: the same uv version is used until
the
lockfile is updated, which avoids "CI worked yesterday, fails today"
drift and
reduces supply-chain exposure from auto-installing the latest release.

The implementation mirrors the existing `version-file` parsers — a new
`uv.lock`
entry in the parser registry reads the `[[package]]` whose `name = "uv"`
and
returns its locked `version`. Scoped to explicit `version-file:
uv.lock`;
workspace auto-detection is left as a possible follow-up to avoid
precedence
ambiguity with `uv.toml` / `pyproject.toml`.

Validation (local, Node 23; dist build is esbuild-deterministic):
- `npm run all` → build clean, biome clean, package clean, jest 77/77
- New tests: 3 unit (`uv-lock-file.test.ts`) + 1 integration — exact pin
resolves
  through the full pipeline (`uv.lock` → `0.8.17`)
- dist rebuilt + committed (single bundle, no spurious churn)

related: #682
2026-06-19 07:08:57 +02:00
Kevin Stillhammer
a92cb43098 Add quiet input to suppress info-level log output (#898)
## Summary

Adds a new `quiet` input (default: `false`) that suppresses `info`-level
log output when set to `true`. Only warnings and errors are shown.

Contributes to: #868
2026-05-31 21:13:30 +02:00
Kevin Stillhammer
b9c8c4c7ba feat: add download-from-astral-mirror input (#897)
## Summary

Add a new boolean input `download-from-astral-mirror` (default: `true`)
that controls whether uv is downloaded from the Astral mirror or
directly from GitHub Releases.

When set to `false`, the mirror rewrite is skipped entirely and the
download goes straight to GitHub Releases.

Closes: #870
2026-05-31 11:47:01 +02:00
Kevin Stillhammer
b3e97d2ba1 Add input no-project in combination with activate-environment (#856)
Closes: #854
2026-04-16 15:48:02 +02:00
Kevin Stillhammer
89709315bb Remove deprecrated custom manifest (#813) 2026-03-23 09:15:51 +01:00
Kevin Stillhammer
fd8f376b22 Switch to ESM for source and test, use CommonJS for dist (#806) 2026-03-14 17:43:49 +01:00
Kevin Stillhammer
e06108dd0a Use astral-sh/versions as primary version provider (#802)
Closes: #777
Closes: #325
2026-03-12 22:03:21 +01:00
Kevin Stillhammer
3511ff7054 feat: add venv-path input for activate-environment (#746)
Allow customizing the venv location while preserving working-directory
semantics via --directory.

Supersedes: #736
2026-02-04 08:40:32 +01:00
Kevin Stillhammer
61cb8a9741 add outputs python-version and python-cache-hit (#728)
This commit splits up the "normal" cache containing the dependencies and
the "python" cache containing the python binaries. This will lead to a
one-time invalidation of caches.

Closes: #713
2026-01-06 18:06:29 +01:00
Kevin Stillhammer
58b6d7b303 fix: add OS version to cache key to prevent binary incompatibility (#716)
## Summary

- Adds OS name and version (e.g., `ubuntu-22.04`, `macos-14`,
`windows-2022`) to cache keys to prevent binary incompatibility when
GitHub updates runner images
- Fixes issue where cached uv binaries compiled against older
glibc/library versions fail on newer runner OS versions

## Changes

- Added `getOSNameVersion()` function to `src/utils/platforms.ts` with
OS-specific detection for Linux (via `/etc/os-release`), macOS (Darwin
kernel version mapping), and Windows
- Updated cache key format to include OS version, bumped `CACHE_VERSION`
to `"2"`
- Added `cache-key` output to expose the generated cache key for
debugging
- Added `test-cache-key-os-version` job testing across multiple OS
versions
- Updated `docs/caching.md` with cache key documentation

Closes #703
2025-12-13 17:25:42 +01:00
Allan Lewis
30ce38e206 Correct description of cache-dependency-glob (#676)
As per the sole commit:

> When `working-directory` is set, paths in `cache-dependency-glob` are
relative to it.
2025-11-04 16:38:32 +01:00
Copilot
9c6b5e9fb5 Add resolution-strategy input to support oldest compatible version selection (#631)
Adds a new `resolution-strategy` input that allows users to choose
between installing the highest (default) or lowest compatible version
when resolving version ranges.
2025-10-11 21:02:04 +02:00
Kevin Stillhammer
bd1f875aba Set output venv when activate-environment is used (#627)
Closes: #622
2025-10-11 15:17:25 +02:00
Merlin
6d2eb15b49 Cache python installs (#621)
This pull request introduces support for caching Python installs in the
GitHub Action, allowing users to cache not only dependencies but also
the Python interpreter itself.

This works by setting the `UV_PYTHON_INSTALL_DIR` to a subdirectory of
the dependency cache path so that Python installs are directed there.

Fixes #135

---------

Co-authored-by: Kevin Stillhammer <kevin.stillhammer@gmail.com>
2025-10-09 22:47:24 +02:00
Kevin Stillhammer
3deccc0075 Use node24 instead of node20 (#608) 2025-10-07 08:44:57 +02:00
Kevin Stillhammer
d9ee7e2f26 Remove deprecated input server-url (#607) 2025-10-03 19:48:56 +02:00
James Duley
e554b93b80 Add **/*.py.lock to cache-dependency-glob (#590)
This means uv scripts will be covered by default

Fixes https://github.com/astral-sh/setup-uv/issues/586
2025-09-26 12:26:03 +02:00
Kevin Stillhammer
dc724a12b6 Add inputs restore-cache and save-cache (#568)
Closes: #555
2025-09-14 14:55:08 +02:00
Kevin Stillhammer
e5d42a2b46 Add input add-problem-matchers (#517)
Allows to disable the adding of problem matchers

Closes: #511
2025-08-12 20:33:00 +00:00
Kevin Stillhammer
b75ff7d7b8 Add input version-file (#486)
Closes: #411
2025-07-17 20:22:18 +02:00
Kevin Stillhammer
60cc2b4585 Add input manifest-file (#454)
Adds capability to maintain custom uv builds or to override the default
sources
2025-06-18 20:33:20 +00:00
Zoupers Zou
0e0f4bfefa feat: support custom github url (#414)
Fix #344
2025-05-20 19:36:07 +02:00
Kevin Stillhammer
ef6bcdff59 Fix default cache dependency glob (#388)
The new default in v6 used illegal patterns and therefore didn't match
requirements files

Fixes: #385
2025-04-29 22:42:06 +02:00
Kevin Stillhammer
aadfaf08d6 Change default cache-dependency-glob (#352)
To support more users by default we should support popular dependency
file formats. A quick GitHub search shows ~40k uses of `constraint.txt`
and ~16k uses of `requirements.in`.

Closes: #261
2025-04-24 15:18:27 +02:00
Kevin Stillhammer
ec4c691628 new inputs activate-environment and working-directory (#381)
venv activation was implicit when python-version was supplied. This now
only happens when activate-environment is true. working-directory
controls where we work and thus also where the .venv will be created

Closes: #351
Closes: #271
Closes: #251
Closes: #211
2025-04-24 15:17:35 +02:00
Kevin Stillhammer
22695119d7 Add uv-path and uvx-path output (#341)
Closes: #338
2025-03-21 13:44:23 +01:00
Kevin Stillhammer
a05a582c56 Warn when the workdir is empty (#322)
Closes: #306
2025-03-16 22:15:17 +01:00
Kevin Stillhammer
5ce9ee0011 Detect required-version from config file (#233)
1. If defined use version input
2. If defined use uv-file input
3. If defined use pyproject-file input
4. Search for required-version in uv.toml in repo root
5. Search for required-version in pyproject.toml in repo root
6. Use latest

Closes: #215
2025-01-13 15:24:25 +01:00
Kevin Stillhammer
dd578776bb Auto activate venv when python-version is set (#194)
Closes: #124
2024-12-20 08:24:43 +01:00
Kevin Stillhammer
e3017a763c Default to enable-cache: true on GitHub hosted runners (#193)
Closes: #54
2024-12-13 20:12:42 +01:00
Kevin Stillhammer
be4207d29e Add **/requirements*.txt to default cache-dependency-glob (#185)
Contributes to: https://github.com/astral-sh/setup-uv/issues/181
2024-12-08 17:51:13 +01:00
Kevin Stillhammer
ee4fa33003 Add input python-version (#174) 2024-11-28 20:41:37 +00:00
Kevin Stillhammer
ed171c292b Fail when cache local path does not exist when trying to cache (#163)
Can be disabled by setting `ignore-nothing-to-cache: true`
2024-11-23 16:30:54 +01:00
Merlin
3b9817b1bf feat: add option to disable cache pruning (#134)
This PR adds an input to control whether or not the cache is pruned
before saving.

Closes #122

---------

Co-authored-by: Kevin Stillhammer <kevin.stillhammer@gmail.com>
Co-authored-by: Charlie Marsh <crmarsh416@gmail.com>
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-25 14:11:32 +02:00
Kevin Stillhammer
aeb46491c7 Set tool(-bin) dir and add to PATH (#87)
Fixes: #83
Fixes: #60
2024-09-21 10:14:36 +02:00
github-actions[bot]
8e09161b4b chore: update known checksums for 0.4.11 (#84)
chore: update known checksums for 0.4.11

Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2024-09-18 07:23:29 +00:00
Charlie Marsh
223591d242 Tweak the action branding (#49) 2024-09-17 23:20:15 -04:00
Kevin Stillhammer
9f1f1fece2 Run prettier (#78) 2024-09-16 19:33:16 +00:00
Kevin Stillhammer
8d65000ec9 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`
2024-09-16 21:08:44 +02:00
Lukas Burgholzer
49df72dfcf 🚸 use GitHub token by default (#61)
This PR adjusts the action so that it is no longer necessary to
explicitly specify the GitHub token to circumvent the API rate limit.
To this end, it simply passes the repository's GitHub token (available
via `${{ github.token }}`) as a default for the `github_token` action
input.

This is similar to how this is handled in, e.g.,
https://github.com/peter-evans/create-pull-request; specifically
[here](5354f85616/action.yml (L4-L6)).
2024-09-11 08:18:23 +00:00
Kevin Stillhammer
417c97acee Use D:\a\_tmp\setup-uv-cache as default cacheLocalPath on Windows (#57)
Fixes: #52
2024-09-07 14:11:25 +02:00
Charlie Marsh
bfebbf80cb Change default to "latest" (#37)
## Summary

Also did some light editing of the README.
2024-09-05 09:24:32 -04:00
Charlie Marsh
182c9c7e92 Change Prettier settings (#36)
## Summary

I know this is a little tedious but I'd prefer to use the same settings
as in Ruff.
2024-09-05 08:06:45 -04:00
Charlie Marsh
0fa3b93f6e Run Prettier over Markdown and YAML files (#35)
## Summary

Partly personal preference, but mostly to align with other Astral
projects.
2024-09-04 21:14:10 +00:00
github-actions[bot]
162b8acf39 chore: update checksums (#29)
Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2024-09-04 07:53:44 +02:00
github-actions[bot]
4b68ead320 chore: update checksums (#25)
Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2024-09-03 08:08:19 +02:00
github-actions[bot]
b0c1123987 chore: update checksums (#21)
Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2024-09-01 20:21:25 +02:00
github-actions[bot]
b038954f55 chore: update checksums (#20)
Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2024-08-30 16:58:12 +02:00
github-actions[bot]
606dd5e44e chore: update checksums (#19)
Co-authored-by: eifinger <1481961+eifinger@users.noreply.github.com>
2024-08-30 13:20:47 +02:00