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:
Kevin Stillhammer 2024-12-22 12:12:29 +01:00 committed by GitHub
parent 180f8b4439
commit 12c852e6ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View file

@ -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> {

View file

@ -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) {