Skip to content

Commit

Permalink
Remove uv version from cache key (#206)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eifinger authored Dec 22, 2024
1 parent 180f8b4 commit 12c852e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions dist/save-cache/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/cache/restore-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/setup-uv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 12c852e

Please sign in to comment.