2024-09-05 08:06:45 -04:00
|
|
|
import * as core from "@actions/core";
|
2024-09-30 02:55:24 -04:00
|
|
|
import path from "node:path";
|
2024-08-23 23:58:26 +02:00
|
|
|
|
2024-09-05 08:06:45 -04:00
|
|
|
export const version = core.getInput("version");
|
2025-01-13 15:24:25 +01:00
|
|
|
export const pyProjectFile = core.getInput("pyproject-file");
|
|
|
|
export const uvFile = core.getInput("uv-file");
|
2024-11-28 21:41:37 +01:00
|
|
|
export const pythonVersion = core.getInput("python-version");
|
2024-09-05 08:06:45 -04:00
|
|
|
export const checkSum = core.getInput("checksum");
|
2024-12-13 20:12:42 +01:00
|
|
|
export const enableCache = getEnableCache();
|
2024-09-05 08:06:45 -04:00
|
|
|
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
2024-09-07 14:11:25 +02:00
|
|
|
export const cacheLocalPath = getCacheLocalPath();
|
2024-09-05 08:06:45 -04:00
|
|
|
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
2024-10-25 08:11:32 -04:00
|
|
|
export const pruneCache = core.getInput("prune-cache") === "true";
|
2024-11-23 16:30:54 +01:00
|
|
|
export const ignoreNothingToCache =
|
|
|
|
core.getInput("ignore-nothing-to-cache") === "true";
|
2024-09-21 10:14:36 +02:00
|
|
|
export const toolBinDir = getToolBinDir();
|
|
|
|
export const toolDir = getToolDir();
|
|
|
|
export const githubToken = core.getInput("github-token");
|
|
|
|
|
2024-12-13 20:12:42 +01:00
|
|
|
function getEnableCache(): boolean {
|
|
|
|
const enableCacheInput = core.getInput("enable-cache");
|
|
|
|
if (enableCacheInput === "auto") {
|
|
|
|
return process.env.RUNNER_ENVIRONMENT === "github-hosted";
|
|
|
|
}
|
|
|
|
return enableCacheInput === "true";
|
|
|
|
}
|
|
|
|
|
2024-09-21 10:14:36 +02:00
|
|
|
function getToolBinDir(): string | undefined {
|
|
|
|
const toolBinDirInput = core.getInput("tool-bin-dir");
|
|
|
|
if (toolBinDirInput !== "") {
|
2024-11-23 09:21:51 +01:00
|
|
|
return expandTilde(toolBinDirInput);
|
2024-09-21 10:14:36 +02:00
|
|
|
}
|
|
|
|
if (process.platform === "win32") {
|
|
|
|
if (process.env.RUNNER_TEMP !== undefined) {
|
|
|
|
return `${process.env.RUNNER_TEMP}${path.sep}uv-tool-bin-dir`;
|
|
|
|
}
|
|
|
|
throw Error(
|
|
|
|
"Could not determine UV_TOOL_BIN_DIR. Please make sure RUNNER_TEMP is set or provide the tool-bin-dir input",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getToolDir(): string | undefined {
|
|
|
|
const toolDirInput = core.getInput("tool-dir");
|
|
|
|
if (toolDirInput !== "") {
|
2024-11-23 09:21:51 +01:00
|
|
|
return expandTilde(toolDirInput);
|
2024-09-21 10:14:36 +02:00
|
|
|
}
|
|
|
|
if (process.platform === "win32") {
|
|
|
|
if (process.env.RUNNER_TEMP !== undefined) {
|
|
|
|
return `${process.env.RUNNER_TEMP}${path.sep}uv-tool-dir`;
|
|
|
|
}
|
|
|
|
throw Error(
|
|
|
|
"Could not determine UV_TOOL_DIR. Please make sure RUNNER_TEMP is set or provide the tool-dir input",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
2024-09-07 14:11:25 +02:00
|
|
|
|
|
|
|
function getCacheLocalPath(): string {
|
|
|
|
const cacheLocalPathInput = core.getInput("cache-local-path");
|
|
|
|
if (cacheLocalPathInput !== "") {
|
2024-11-23 09:21:51 +01:00
|
|
|
return expandTilde(cacheLocalPathInput);
|
2024-09-07 14:11:25 +02:00
|
|
|
}
|
|
|
|
if (process.env.RUNNER_TEMP !== undefined) {
|
|
|
|
return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`;
|
|
|
|
}
|
2024-09-21 10:14:36 +02:00
|
|
|
throw Error(
|
|
|
|
"Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input",
|
|
|
|
);
|
2024-09-07 14:11:25 +02:00
|
|
|
}
|
2024-11-23 09:21:51 +01:00
|
|
|
|
|
|
|
function expandTilde(input: string): string {
|
|
|
|
if (input.startsWith("~")) {
|
|
|
|
return `${process.env.HOME}${input.substring(1)}`;
|
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|