mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-04-10 09:08:31 -04:00
feat: add option to disable cache pruning
This commit is contained in:
parent
cf841c25e2
commit
bd646556e4
4 changed files with 22 additions and 2 deletions
14
README.md
14
README.md
|
@ -166,6 +166,20 @@ It defaults to `setup-uv-cache` in the `TMP` dir, `D:\a\_temp\uv-tool-dir` on Wi
|
|||
cache-local-path: "/path/to/cache"
|
||||
```
|
||||
|
||||
### Disable cache pruning
|
||||
|
||||
By default, the cache is pruned after a run, which means that all pre-built wheels are removed from
|
||||
the cache ([documentation](https://docs.astral.sh/uv/concepts/cache/#caching-in-continuous-integration)).
|
||||
If you want to keep the cache after a run, you can disable cache pruning with the `prune-cache` input.
|
||||
|
||||
```yaml
|
||||
- name: Don't prune the cache before saving it
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
prune-cache: false
|
||||
```
|
||||
|
||||
### GitHub authentication token
|
||||
|
||||
This action uses the GitHub API to fetch the uv release artifacts. To avoid hitting the GitHub API
|
||||
|
|
|
@ -29,6 +29,9 @@ inputs:
|
|||
cache-local-path:
|
||||
description: "Local path to store the cache."
|
||||
default: ""
|
||||
prune-cache:
|
||||
description: "Prune cache before saving."
|
||||
default: true
|
||||
tool-dir:
|
||||
description: "Custom path to set UV_TOOL_DIR to."
|
||||
required: false
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
STATE_CACHE_MATCHED_KEY,
|
||||
STATE_CACHE_KEY,
|
||||
} from "./cache/restore-cache";
|
||||
import { cacheLocalPath, enableCache } from "./utils/inputs";
|
||||
import { cacheLocalPath, enableCache, pruneCache as pruneCacheOption } from "./utils/inputs";
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
try {
|
||||
|
@ -32,7 +32,9 @@ async function saveCache(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
await pruneCache();
|
||||
if (pruneCacheOption) {
|
||||
await pruneCache();
|
||||
}
|
||||
|
||||
core.info(`Saving cache path: ${cacheLocalPath}`);
|
||||
await cache.saveCache([cacheLocalPath], cacheKey);
|
||||
|
|
|
@ -7,6 +7,7 @@ export const enableCache = core.getInput("enable-cache") === "true";
|
|||
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
export const cacheLocalPath = getCacheLocalPath();
|
||||
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
export const pruneCache = (core.getInput("prune-cache") || "true") === "true";
|
||||
export const toolBinDir = getToolBinDir();
|
||||
export const toolDir = getToolDir();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
|
|
Loading…
Add table
Reference in a new issue