Skip to content

Commit efcb54d

Browse files
authored
Merge pull request #12 from namespacelabs/niklas-uv-cache-mode
Add a UV cache mode.
2 parents 8cbca7f + b34bb5c commit efcb54d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
default: "false"
1414
required: false
1515
cache:
16-
description: "A list of native cache modes. Supported options are 'go,yarn,rust,python,gradle,maven,composer,poetry'"
16+
description: "A list of native cache modes. Supported options are 'go,yarn,rust,python,pnpm,gradle,maven,composer,poetry,uv'"
1717
required: false
1818
outputs:
1919
cache-hit:

dist/index/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27257,7 +27257,7 @@ Are you running in a container? Check out https://namespace.so/docs/actions/nscl
2725727257
}
2725827258
core.info(`Found Namespace cross-invocation cache at ${localCachePath}.`);
2725927259
const useSymlinks = process.env.RUNNER_OS === "macOS";
27260-
core.debug(`Using synlinks: ${useSymlinks} on ${process.env["RUNNER_OS"]}.`);
27260+
core.debug(`Using symlinks: ${useSymlinks} on ${process.env["RUNNER_OS"]}.`);
2726127261
const cachePaths = await resolveCachePaths(localCachePath);
2726227262
const cacheMisses = await restoreLocalCache(cachePaths, useSymlinks);
2726327263
const fullHit = cacheMisses.length === 0;
@@ -27412,6 +27412,13 @@ async function resolveCacheMode(cacheMode) {
2741227412
const poetryCache = await getExecStdout("poetry config cache-dir");
2741327413
return [{ mountTarget: poetryCache, framework: cacheMode }];
2741427414
}
27415+
case "uv": {
27416+
// Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.
27417+
// Neither works with cache volumes, and fall back to `copy`. Select `symlink` to avoid copies.
27418+
core.exportVariable("UV_LINK_MODE", "symlink");
27419+
const uvCache = await getExecStdout("uv cache dir");
27420+
return [{ mountTarget: uvCache, framework: cacheMode }];
27421+
}
2741527422
default:
2741627423
core.warning(`Unknown cache option: ${cacheMode}.`);
2741727424
return [];

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ async function resolveCacheMode(cacheMode: string): Promise<utils.CachePath[]> {
237237
return [{ mountTarget: poetryCache, framework: cacheMode }];
238238
}
239239

240+
case "uv": {
241+
// Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.
242+
// Neither works with cache volumes, and fall back to `copy`. Select `symlink` to avoid copies.
243+
core.exportVariable("UV_LINK_MODE", "symlink");
244+
245+
const uvCache = await getExecStdout("uv cache dir");
246+
return [{ mountTarget: uvCache, framework: cacheMode }];
247+
}
248+
240249
default:
241250
core.warning(`Unknown cache option: ${cacheMode}.`);
242251
return [];

0 commit comments

Comments
 (0)