5
0
mirror of https://github.com/astral-sh/setup-uv.git synced 2025-12-23 11:01:03 +00:00

Use --force when pruning cache (#611)

To prevent waiting forever on other running uv processes
This commit is contained in:
Kevin Stillhammer
2025-10-07 09:42:14 +02:00
committed by GitHub
parent 3deccc0075
commit f610be5ff9
7 changed files with 817 additions and 5 deletions

View File

@@ -2,11 +2,12 @@ import * as fs from "node:fs";
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as pep440 from "@renovatebot/pep440";
import {
STATE_CACHE_KEY,
STATE_CACHE_MATCHED_KEY,
} from "./cache/restore-cache";
import { STATE_UV_PATH } from "./utils/constants";
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
import {
cacheLocalPath,
enableCache,
@@ -86,10 +87,15 @@ async function saveCache(): Promise<void> {
}
async function pruneCache(): Promise<void> {
const forceSupported = pep440.gte(core.getState(STATE_UV_VERSION), "0.8.24");
const options: exec.ExecOptions = {
silent: false,
};
const execArgs = ["cache", "prune", "--ci"];
if (forceSupported) {
execArgs.push("--force");
}
core.info("Pruning cache...");
const uvPath = core.getState(STATE_UV_PATH);

View File

@@ -8,7 +8,7 @@ import {
resolveVersion,
tryGetFromToolCache,
} from "./download/download-version";
import { STATE_UV_PATH } from "./utils/constants";
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
import {
activateEnvironment as activateEnvironmentInput,
addProblemMatchers,
@@ -56,6 +56,7 @@ async function run(): Promise<void> {
setCacheDir(cacheLocalPath);
core.setOutput("uv-version", setupResult.version);
core.saveState(STATE_UV_VERSION, setupResult.version);
core.info(`Successfully installed uv version ${setupResult.version}`);
if (enableCache) {

View File

@@ -2,3 +2,4 @@ export const REPO = "uv";
export const OWNER = "astral-sh";
export const TOOL_CACHE_NAME = "uv";
export const STATE_UV_PATH = "uv-path";
export const STATE_UV_VERSION = "uv-version";