Skip to content

Commit

Permalink
Merge pull request #12 from namespacelabs/niklas-uv-cache-mode
Browse files Browse the repository at this point in the history
Add a UV cache mode.
  • Loading branch information
n-g authored Jan 3, 2025
2 parents 8cbca7f + b34bb5c commit efcb54d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
default: "false"
required: false
cache:
description: "A list of native cache modes. Supported options are 'go,yarn,rust,python,gradle,maven,composer,poetry'"
description: "A list of native cache modes. Supported options are 'go,yarn,rust,python,pnpm,gradle,maven,composer,poetry,uv'"
required: false
outputs:
cache-hit:
Expand Down
9 changes: 8 additions & 1 deletion dist/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27257,7 +27257,7 @@ Are you running in a container? Check out https://namespace.so/docs/actions/nscl
}
core.info(`Found Namespace cross-invocation cache at ${localCachePath}.`);
const useSymlinks = process.env.RUNNER_OS === "macOS";
core.debug(`Using synlinks: ${useSymlinks} on ${process.env["RUNNER_OS"]}.`);
core.debug(`Using symlinks: ${useSymlinks} on ${process.env["RUNNER_OS"]}.`);
const cachePaths = await resolveCachePaths(localCachePath);
const cacheMisses = await restoreLocalCache(cachePaths, useSymlinks);
const fullHit = cacheMisses.length === 0;
Expand Down Expand Up @@ -27412,6 +27412,13 @@ async function resolveCacheMode(cacheMode) {
const poetryCache = await getExecStdout("poetry config cache-dir");
return [{ mountTarget: poetryCache, framework: cacheMode }];
}
case "uv": {
// Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.
// Neither works with cache volumes, and fall back to `copy`. Select `symlink` to avoid copies.
core.exportVariable("UV_LINK_MODE", "symlink");
const uvCache = await getExecStdout("uv cache dir");
return [{ mountTarget: uvCache, framework: cacheMode }];
}
default:
core.warning(`Unknown cache option: ${cacheMode}.`);
return [];
Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ async function resolveCacheMode(cacheMode: string): Promise<utils.CachePath[]> {
return [{ mountTarget: poetryCache, framework: cacheMode }];
}

case "uv": {
// Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.
// Neither works with cache volumes, and fall back to `copy`. Select `symlink` to avoid copies.
core.exportVariable("UV_LINK_MODE", "symlink");

const uvCache = await getExecStdout("uv cache dir");
return [{ mountTarget: uvCache, framework: cacheMode }];
}

default:
core.warning(`Unknown cache option: ${cacheMode}.`);
return [];
Expand Down

0 comments on commit efcb54d

Please sign in to comment.