mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-03-10 08:42:21 +00:00
committed by
GitHub
parent
a3b3eaea92
commit
02182fa02a
39
dist/save-cache/index.js
generated
vendored
39
dist/save-cache/index.js
generated
vendored
@@ -90852,11 +90852,25 @@ async function saveCache() {
|
||||
await pruneCache();
|
||||
}
|
||||
const actualCachePath = getUvCachePath();
|
||||
await saveCacheToKey(cacheKey, actualCachePath, restore_cache_1.STATE_CACHE_MATCHED_KEY, "uv cache", `Cache path ${actualCachePath} does not exist on disk. This likely indicates that there are no dependencies to cache. Consider disabling the cache input if it is not needed.`);
|
||||
if (!fs.existsSync(actualCachePath)) {
|
||||
if (inputs_1.ignoreNothingToCache) {
|
||||
core.info("No cacheable uv cache paths were found. Ignoring because ignore-nothing-to-cache is enabled.");
|
||||
}
|
||||
else {
|
||||
throw new Error(`Cache path ${actualCachePath} does not exist on disk. This likely indicates that there are no dependencies to cache. Consider disabling the cache input if it is not needed.`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await saveCacheToKey(cacheKey, actualCachePath, restore_cache_1.STATE_CACHE_MATCHED_KEY, "uv cache");
|
||||
}
|
||||
}
|
||||
if (inputs_1.cachePython) {
|
||||
if (!fs.existsSync(inputs_1.pythonDir)) {
|
||||
core.warning(`Python cache path ${inputs_1.pythonDir} does not exist on disk. Skipping Python cache save because no managed Python installation was found. If you want uv to install managed Python instead of using a system interpreter, set UV_PYTHON_PREFERENCE=only-managed.`);
|
||||
return;
|
||||
}
|
||||
const pythonCacheKey = `${cacheKey}-python`;
|
||||
await saveCacheToKey(pythonCacheKey, inputs_1.pythonDir, restore_cache_1.STATE_PYTHON_CACHE_MATCHED_KEY, "Python cache", `Python cache path ${inputs_1.pythonDir} does not exist on disk. This likely indicates that there are no Python installations to cache. Consider disabling the cache input if it is not needed.`);
|
||||
await saveCacheToKey(pythonCacheKey, inputs_1.pythonDir, restore_cache_1.STATE_PYTHON_CACHE_MATCHED_KEY, "Python cache");
|
||||
}
|
||||
}
|
||||
async function pruneCache() {
|
||||
@@ -90883,30 +90897,15 @@ function getUvCachePath() {
|
||||
}
|
||||
return inputs_1.cacheLocalPath.path;
|
||||
}
|
||||
async function saveCacheToKey(cacheKey, cachePath, stateKey, cacheName, pathNotExistErrorMessage) {
|
||||
async function saveCacheToKey(cacheKey, cachePath, stateKey, cacheName) {
|
||||
const matchedKey = core.getState(stateKey);
|
||||
if (matchedKey === cacheKey) {
|
||||
core.info(`${cacheName} hit occurred on key ${cacheKey}, not saving cache.`);
|
||||
return;
|
||||
}
|
||||
core.info(`Including ${cacheName} path: ${cachePath}`);
|
||||
if (!fs.existsSync(cachePath) && !inputs_1.ignoreNothingToCache) {
|
||||
throw new Error(pathNotExistErrorMessage);
|
||||
}
|
||||
try {
|
||||
await cache.saveCache([cachePath], cacheKey);
|
||||
core.info(`${cacheName} saved with key: ${cacheKey}`);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error &&
|
||||
e.message ===
|
||||
"Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.") {
|
||||
core.info(`No cacheable ${cacheName} paths were found. Ignoring because ignore-nothing-to-save is enabled.`);
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
await cache.saveCache([cachePath], cacheKey);
|
||||
core.info(`${cacheName} saved with key: ${cacheKey}`);
|
||||
}
|
||||
run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user