mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-05-17 22:54:45 +00:00
Remove uv version from cache key (#206)
This approach was copied from setup-rye but uv now has the capability to determine if a cache version is compatible. By removing it we will less frequently invalidate the cache and thus save bandwidth Closes: #203
This commit is contained in:
parent
180f8b4439
commit
12c852e6ba
4 changed files with 14 additions and 14 deletions
8
src/cache/restore-cache.ts
vendored
8
src/cache/restore-cache.ts
vendored
|
@ -14,8 +14,8 @@ export const STATE_CACHE_KEY = "cache-key";
|
|||
export const STATE_CACHE_MATCHED_KEY = "cache-matched-key";
|
||||
const CACHE_VERSION = "1";
|
||||
|
||||
export async function restoreCache(version: string): Promise<void> {
|
||||
const cacheKey = await computeKeys(version);
|
||||
export async function restoreCache(): Promise<void> {
|
||||
const cacheKey = await computeKeys();
|
||||
|
||||
let matchedKey: string | undefined;
|
||||
core.info(
|
||||
|
@ -35,7 +35,7 @@ export async function restoreCache(version: string): Promise<void> {
|
|||
handleMatchResult(matchedKey, cacheKey);
|
||||
}
|
||||
|
||||
async function computeKeys(version: string): Promise<string> {
|
||||
async function computeKeys(): Promise<string> {
|
||||
let cacheDependencyPathHash = "-";
|
||||
if (cacheDependencyGlob !== "") {
|
||||
core.info(
|
||||
|
@ -53,7 +53,7 @@ async function computeKeys(version: string): Promise<string> {
|
|||
}
|
||||
const suffix = cacheSuffix ? `-${cacheSuffix}` : "";
|
||||
const pythonVersion = await getPythonVersion();
|
||||
return `setup-uv-${CACHE_VERSION}-${getArch()}-${getPlatform()}-${version}-${pythonVersion}${cacheDependencyPathHash}${suffix}`;
|
||||
return `setup-uv-${CACHE_VERSION}-${getArch()}-${getPlatform()}-${pythonVersion}${cacheDependencyPathHash}${suffix}`;
|
||||
}
|
||||
|
||||
async function getPythonVersion(): Promise<string> {
|
||||
|
|
|
@ -55,7 +55,7 @@ async function run(): Promise<void> {
|
|||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
|
||||
if (enableCache) {
|
||||
await restoreCache(setupResult.version);
|
||||
await restoreCache();
|
||||
}
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue