5
0
mirror of https://github.com/astral-sh/setup-uv.git synced 2025-12-19 11:04:08 +00:00

Respect UV_CACHE_DIR and cache-dir (#612)

Fixes: #583
This commit is contained in:
Kevin Stillhammer
2025-10-07 16:08:30 +02:00
committed by GitHub
parent f610be5ff9
commit 535dc2664c
13 changed files with 1277 additions and 96 deletions

View File

@@ -8,6 +8,7 @@ import {
resolveVersion,
tryGetFromToolCache,
} from "./download/download-version";
import { getConfigValueFromTomlFile } from "./utils/config-file";
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
import {
activateEnvironment as activateEnvironmentInput,
@@ -53,7 +54,7 @@ async function run(): Promise<void> {
setupPython();
await activateEnvironment();
addMatchers();
setCacheDir(cacheLocalPath);
setCacheDir();
core.setOutput("uv-version", setupResult.version);
core.saveState(STATE_UV_VERSION, setupResult.version);
@@ -224,9 +225,18 @@ async function activateEnvironment(): Promise<void> {
}
}
function setCacheDir(cacheLocalPath: string): void {
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
function setCacheDir(): void {
if (enableCache) {
const cacheDirFromConfig = getConfigValueFromTomlFile("", "cache-dir");
if (cacheDirFromConfig !== undefined) {
core.info(
"Using cache-dir from uv config file, not modifying UV_CACHE_DIR",
);
return;
}
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
}
}
function addMatchers(): void {