mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-06-05 03:16:29 +00:00
Add quiet input to suppress info-level log output (#898)
## Summary Adds a new `quiet` input (default: `false`) that suppresses `info`-level log output when set to `true`. Only warnings and errors are shown. Contributes to: #868
This commit is contained in:
committed by
GitHub
parent
e07f2ac4b7
commit
a92cb43098
15
src/cache/restore-cache.ts
vendored
15
src/cache/restore-cache.ts
vendored
@@ -2,6 +2,7 @@ import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
import { hashFiles } from "../hash/hash-files";
|
||||
import type { SetupInputs } from "../utils/inputs";
|
||||
import * as log from "../utils/logging";
|
||||
import { getArch, getOSNameVersion, getPlatform } from "../utils/platforms";
|
||||
|
||||
export const STATE_CACHE_KEY = "cache-key";
|
||||
@@ -19,7 +20,7 @@ export async function restoreCache(
|
||||
core.setOutput("cache-key", cacheKey);
|
||||
|
||||
if (!inputs.restoreCache) {
|
||||
core.info("restore-cache is false. Skipping restore cache step.");
|
||||
log.info("restore-cache is false. Skipping restore cache step.");
|
||||
core.setOutput("python-cache-hit", false);
|
||||
return;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ async function restoreCacheFromKey(
|
||||
stateKey: string,
|
||||
outputKey: string,
|
||||
): Promise<void> {
|
||||
core.info(
|
||||
log.info(
|
||||
`Trying to restore cache from GitHub Actions cache with key: ${cacheKey}`,
|
||||
);
|
||||
let matchedKey: string | undefined;
|
||||
@@ -63,7 +64,7 @@ async function restoreCacheFromKey(
|
||||
matchedKey = await cache.restoreCache([cachePath], cacheKey);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
core.warning(message);
|
||||
log.warning(message);
|
||||
core.setOutput(outputKey, false);
|
||||
return;
|
||||
}
|
||||
@@ -77,7 +78,7 @@ async function computeKeys(
|
||||
): Promise<string> {
|
||||
let cacheDependencyPathHash = "-";
|
||||
if (inputs.cacheDependencyGlob !== "") {
|
||||
core.info(
|
||||
log.info(
|
||||
`Searching files using cache dependency glob: ${inputs.cacheDependencyGlob.split("\n").join(",")}`,
|
||||
);
|
||||
cacheDependencyPathHash += await hashFiles(
|
||||
@@ -85,7 +86,7 @@ async function computeKeys(
|
||||
true,
|
||||
);
|
||||
if (cacheDependencyPathHash === "-") {
|
||||
core.warning(
|
||||
log.warning(
|
||||
`No file matched to [${inputs.cacheDependencyGlob.split("\n").join(",")}]. The cache will never get invalidated. Make sure you have checked out the target repository and configured the cache-dependency-glob input correctly.`,
|
||||
);
|
||||
}
|
||||
@@ -109,12 +110,12 @@ function handleMatchResult(
|
||||
outputKey: string,
|
||||
): void {
|
||||
if (!matchedKey) {
|
||||
core.info(`No GitHub Actions cache found for key: ${primaryKey}`);
|
||||
log.info(`No GitHub Actions cache found for key: ${primaryKey}`);
|
||||
core.setOutput(outputKey, false);
|
||||
return;
|
||||
}
|
||||
|
||||
core.saveState(stateKey, matchedKey);
|
||||
core.info(`cache restored from GitHub Actions cache with key: ${matchedKey}`);
|
||||
log.info(`cache restored from GitHub Actions cache with key: ${matchedKey}`);
|
||||
core.setOutput(outputKey, true);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
TOOL_CACHE_NAME,
|
||||
VERSIONS_MANIFEST_URL,
|
||||
} from "../utils/constants";
|
||||
import * as log from "../utils/logging";
|
||||
import type { Architecture, Platform } from "../utils/platforms";
|
||||
import { validateChecksum } from "./checksum/checksum";
|
||||
import { getArtifact } from "./manifest";
|
||||
@@ -73,7 +74,7 @@ export async function downloadVersion(
|
||||
throw err;
|
||||
}
|
||||
|
||||
core.warning(
|
||||
log.warning(
|
||||
`Failed to download from mirror, falling back to GitHub Releases: ${(err as Error).message}`,
|
||||
);
|
||||
|
||||
@@ -123,7 +124,7 @@ async function downloadArtifact(
|
||||
checksum: string | undefined,
|
||||
githubToken: string | undefined,
|
||||
): Promise<{ version: string; cachedToolDir: string }> {
|
||||
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||
log.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||
const downloadPath = await tc.downloadTool(
|
||||
downloadUrl,
|
||||
undefined,
|
||||
@@ -139,7 +140,7 @@ async function downloadArtifact(
|
||||
// so this may fail if another tar, like gnu tar, ends up being used.
|
||||
uvDir = await tc.extractTar(downloadPath, undefined, "x");
|
||||
} catch (err) {
|
||||
core.info(
|
||||
log.info(
|
||||
`Extracting with tar failed, falling back to zip extraction: ${(err as Error).message}`,
|
||||
);
|
||||
const extension = getExtension(platform);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as core from "@actions/core";
|
||||
import { VERSIONS_MANIFEST_URL } from "../utils/constants";
|
||||
import { fetch } from "../utils/fetch";
|
||||
import * as log from "../utils/logging";
|
||||
import { selectDefaultVariant } from "./variant-selection";
|
||||
|
||||
export interface ManifestArtifact {
|
||||
@@ -33,7 +34,7 @@ export async function fetchManifest(
|
||||
return cachedVersions;
|
||||
}
|
||||
|
||||
core.info(`Fetching manifest data from ${manifestUrl} ...`);
|
||||
log.info(`Fetching manifest data from ${manifestUrl} ...`);
|
||||
const response = await fetch(manifestUrl, {});
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
@@ -111,7 +112,7 @@ export async function getLatestVersion(
|
||||
export async function getAllVersions(
|
||||
manifestUrl: string = VERSIONS_MANIFEST_URL,
|
||||
): Promise<string[]> {
|
||||
core.info(
|
||||
log.info(
|
||||
`Getting available versions from ${manifestSource(manifestUrl)} ...`,
|
||||
);
|
||||
const versions = await fetchManifest(manifestUrl);
|
||||
|
||||
@@ -2,8 +2,8 @@ import * as crypto from "node:crypto";
|
||||
import * as fs from "node:fs";
|
||||
import * as stream from "node:stream";
|
||||
import * as util from "node:util";
|
||||
import * as core from "@actions/core";
|
||||
import { create } from "@actions/glob";
|
||||
import * as log from "../utils/logging";
|
||||
|
||||
/**
|
||||
* Hashes files matching the given glob pattern.
|
||||
@@ -19,7 +19,7 @@ export async function hashFiles(
|
||||
): Promise<string> {
|
||||
const globber = await create(pattern);
|
||||
let hasMatch = false;
|
||||
const writeDelegate = verbose ? core.info : core.debug;
|
||||
const writeDelegate = verbose ? log.info : log.debug;
|
||||
const result = crypto.createHash("sha256");
|
||||
let count = 0;
|
||||
for await (const file of globber.globGenerator()) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "./cache/restore-cache";
|
||||
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
|
||||
import { loadInputs, type SetupInputs } from "./utils/inputs";
|
||||
import * as log from "./utils/logging";
|
||||
|
||||
function formatUnexpectedFailure(error: unknown): string {
|
||||
if (error instanceof Error) {
|
||||
@@ -38,7 +39,7 @@ export async function run(): Promise<void> {
|
||||
if (inputs.saveCache) {
|
||||
await saveCache(inputs);
|
||||
} else {
|
||||
core.info("save-cache is false. Skipping save cache step.");
|
||||
log.info("save-cache is false. Skipping save cache step.");
|
||||
}
|
||||
// https://github.com/nodejs/node/issues/56645#issuecomment-3924958861
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
@@ -61,11 +62,11 @@ async function saveCache(inputs: SetupInputs): Promise<void> {
|
||||
const matchedKey = core.getState(STATE_CACHE_MATCHED_KEY);
|
||||
|
||||
if (!cacheKey) {
|
||||
core.warning("Error retrieving cache key from state.");
|
||||
log.warning("Error retrieving cache key from state.");
|
||||
return;
|
||||
}
|
||||
if (matchedKey === cacheKey) {
|
||||
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
||||
log.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
||||
} else {
|
||||
if (inputs.pruneCache) {
|
||||
await pruneCache();
|
||||
@@ -74,7 +75,7 @@ async function saveCache(inputs: SetupInputs): Promise<void> {
|
||||
const actualCachePath = getUvCachePath(inputs);
|
||||
if (!fs.existsSync(actualCachePath)) {
|
||||
if (inputs.ignoreNothingToCache) {
|
||||
core.info(
|
||||
log.info(
|
||||
"No cacheable uv cache paths were found. Ignoring because ignore-nothing-to-cache is enabled.",
|
||||
);
|
||||
} else {
|
||||
@@ -94,7 +95,7 @@ async function saveCache(inputs: SetupInputs): Promise<void> {
|
||||
|
||||
if (inputs.cachePython) {
|
||||
if (!fs.existsSync(inputs.pythonDir)) {
|
||||
core.warning(
|
||||
log.warning(
|
||||
`Python cache path ${inputs.pythonDir} does not exist on disk. Skipping Python cache save because no managed Python installation was found. If you want uv to install managed Python instead of using a system interpreter, set UV_PYTHON_PREFERENCE=only-managed.`,
|
||||
);
|
||||
return;
|
||||
@@ -121,7 +122,7 @@ async function pruneCache(): Promise<void> {
|
||||
execArgs.push("--force");
|
||||
}
|
||||
|
||||
core.info("Pruning cache...");
|
||||
log.info("Pruning cache...");
|
||||
const uvPath = core.getState(STATE_UV_PATH);
|
||||
await exec.exec(uvPath, execArgs, options);
|
||||
}
|
||||
@@ -136,7 +137,7 @@ function getUvCachePath(inputs: SetupInputs): string {
|
||||
process.env.UV_CACHE_DIR &&
|
||||
process.env.UV_CACHE_DIR !== inputs.cacheLocalPath.path
|
||||
) {
|
||||
core.warning(
|
||||
log.warning(
|
||||
`The environment variable UV_CACHE_DIR has been changed to "${process.env.UV_CACHE_DIR}", by an action or step running after astral-sh/setup-uv. This can lead to unexpected behavior. If you expected this to happen set the cache-local-path input to "${process.env.UV_CACHE_DIR}" instead of "${inputs.cacheLocalPath.path}".`,
|
||||
);
|
||||
return process.env.UV_CACHE_DIR;
|
||||
@@ -153,15 +154,13 @@ async function saveCacheToKey(
|
||||
const matchedKey = core.getState(stateKey);
|
||||
|
||||
if (matchedKey === cacheKey) {
|
||||
core.info(
|
||||
`${cacheName} hit occurred on key ${cacheKey}, not saving cache.`,
|
||||
);
|
||||
log.info(`${cacheName} hit occurred on key ${cacheKey}, not saving cache.`);
|
||||
return;
|
||||
}
|
||||
|
||||
core.info(`Including ${cacheName} path: ${cachePath}`);
|
||||
log.info(`Including ${cacheName} path: ${cachePath}`);
|
||||
await cache.saveCache([cachePath], cacheKey);
|
||||
core.info(`${cacheName} saved with key: ${cacheKey}`);
|
||||
log.info(`${cacheName} saved with key: ${cacheKey}`);
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from "./download/download-version";
|
||||
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
|
||||
import { CacheLocalSource, loadInputs, type SetupInputs } from "./utils/inputs";
|
||||
import * as log from "./utils/logging";
|
||||
import {
|
||||
type Architecture,
|
||||
getArch,
|
||||
@@ -96,7 +97,7 @@ async function run(): Promise<void> {
|
||||
|
||||
core.setOutput("uv-version", setupResult.version);
|
||||
core.saveState(STATE_UV_VERSION, setupResult.version);
|
||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
log.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
|
||||
const detectedPythonVersion = await getPythonVersion(inputs);
|
||||
core.setOutput("python-version", detectedPythonVersion);
|
||||
@@ -115,11 +116,11 @@ async function run(): Promise<void> {
|
||||
function detectEmptyWorkdir(inputs: SetupInputs): void {
|
||||
if (fs.readdirSync(inputs.workingDirectory).length === 0) {
|
||||
if (inputs.ignoreEmptyWorkdir) {
|
||||
core.info(
|
||||
log.info(
|
||||
"Empty workdir detected. Ignoring because ignore-empty-workdir is enabled",
|
||||
);
|
||||
} else {
|
||||
core.warning(
|
||||
log.warning(
|
||||
"Empty workdir detected. This may cause unexpected behavior. You can enable ignore-empty-workdir to mute this warning.",
|
||||
);
|
||||
}
|
||||
@@ -140,7 +141,7 @@ async function setupUv(
|
||||
});
|
||||
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
|
||||
if (toolCacheResult.installedPath) {
|
||||
core.info(`Found uv in tool-cache for ${toolCacheResult.version}`);
|
||||
log.info(`Found uv in tool-cache for ${toolCacheResult.version}`);
|
||||
return {
|
||||
uvDir: toolCacheResult.installedPath,
|
||||
version: toolCacheResult.version,
|
||||
@@ -168,39 +169,39 @@ function addUvToPathAndOutput(cachedPath: string): void {
|
||||
core.saveState(STATE_UV_PATH, `${cachedPath}${path.sep}uv`);
|
||||
core.setOutput("uvx-path", `${cachedPath}${path.sep}uvx`);
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info("UV_NO_MODIFY_PATH is set, not modifying PATH");
|
||||
log.info("UV_NO_MODIFY_PATH is set, not modifying PATH");
|
||||
} else {
|
||||
core.addPath(cachedPath);
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
log.info(`Added ${cachedPath} to the path`);
|
||||
}
|
||||
}
|
||||
|
||||
function addToolBinToPath(inputs: SetupInputs): void {
|
||||
if (inputs.toolBinDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_BIN_DIR", inputs.toolBinDir);
|
||||
core.info(`Set UV_TOOL_BIN_DIR to ${inputs.toolBinDir}`);
|
||||
log.info(`Set UV_TOOL_BIN_DIR to ${inputs.toolBinDir}`);
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info(
|
||||
log.info(
|
||||
`UV_NO_MODIFY_PATH is set, not adding ${inputs.toolBinDir} to path`,
|
||||
);
|
||||
} else {
|
||||
core.addPath(inputs.toolBinDir);
|
||||
core.info(`Added ${inputs.toolBinDir} to the path`);
|
||||
log.info(`Added ${inputs.toolBinDir} to the path`);
|
||||
}
|
||||
} else {
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info("UV_NO_MODIFY_PATH is set, not adding user local bin to path");
|
||||
log.info("UV_NO_MODIFY_PATH is set, not adding user local bin to path");
|
||||
return;
|
||||
}
|
||||
if (process.env.XDG_BIN_HOME !== undefined) {
|
||||
core.addPath(process.env.XDG_BIN_HOME);
|
||||
core.info(`Added ${process.env.XDG_BIN_HOME} to the path`);
|
||||
log.info(`Added ${process.env.XDG_BIN_HOME} to the path`);
|
||||
} else if (process.env.XDG_DATA_HOME !== undefined) {
|
||||
core.addPath(`${process.env.XDG_DATA_HOME}/../bin`);
|
||||
core.info(`Added ${process.env.XDG_DATA_HOME}/../bin to the path`);
|
||||
log.info(`Added ${process.env.XDG_DATA_HOME}/../bin to the path`);
|
||||
} else {
|
||||
core.addPath(`${process.env.HOME}/.local/bin`);
|
||||
core.info(`Added ${process.env.HOME}/.local/bin to the path`);
|
||||
log.info(`Added ${process.env.HOME}/.local/bin to the path`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,25 +209,25 @@ function addToolBinToPath(inputs: SetupInputs): void {
|
||||
function setToolDir(inputs: SetupInputs): void {
|
||||
if (inputs.toolDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_DIR", inputs.toolDir);
|
||||
core.info(`Set UV_TOOL_DIR to ${inputs.toolDir}`);
|
||||
log.info(`Set UV_TOOL_DIR to ${inputs.toolDir}`);
|
||||
}
|
||||
}
|
||||
|
||||
function addPythonDirToPath(inputs: SetupInputs): void {
|
||||
core.exportVariable("UV_PYTHON_INSTALL_DIR", inputs.pythonDir);
|
||||
core.info(`Set UV_PYTHON_INSTALL_DIR to ${inputs.pythonDir}`);
|
||||
log.info(`Set UV_PYTHON_INSTALL_DIR to ${inputs.pythonDir}`);
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info("UV_NO_MODIFY_PATH is set, not adding python dir to path");
|
||||
log.info("UV_NO_MODIFY_PATH is set, not adding python dir to path");
|
||||
} else {
|
||||
core.addPath(inputs.pythonDir);
|
||||
core.info(`Added ${inputs.pythonDir} to the path`);
|
||||
log.info(`Added ${inputs.pythonDir} to the path`);
|
||||
}
|
||||
}
|
||||
|
||||
function setupPython(inputs: SetupInputs): void {
|
||||
if (inputs.pythonVersion !== "") {
|
||||
core.exportVariable("UV_PYTHON", inputs.pythonVersion);
|
||||
core.info(`Set UV_PYTHON to ${inputs.pythonVersion}`);
|
||||
log.info(`Set UV_PYTHON to ${inputs.pythonVersion}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +239,7 @@ async function activateEnvironment(inputs: SetupInputs): Promise<void> {
|
||||
);
|
||||
}
|
||||
|
||||
core.info(`Creating and activating python venv at ${inputs.venvPath}...`);
|
||||
log.info(`Creating and activating python venv at ${inputs.venvPath}...`);
|
||||
const venvArgs = [
|
||||
"venv",
|
||||
inputs.venvPath,
|
||||
@@ -264,13 +265,13 @@ async function activateEnvironment(inputs: SetupInputs): Promise<void> {
|
||||
function setCacheDir(inputs: SetupInputs): void {
|
||||
if (inputs.cacheLocalPath !== undefined) {
|
||||
if (inputs.cacheLocalPath.source === CacheLocalSource.Config) {
|
||||
core.info(
|
||||
log.info(
|
||||
"Using cache-dir from uv config file, not modifying UV_CACHE_DIR",
|
||||
);
|
||||
return;
|
||||
}
|
||||
core.exportVariable("UV_CACHE_DIR", inputs.cacheLocalPath.path);
|
||||
core.info(`Set UV_CACHE_DIR to ${inputs.cacheLocalPath.path}`);
|
||||
log.info(`Set UV_CACHE_DIR to ${inputs.cacheLocalPath.path}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
getLatestVersion,
|
||||
type ManifestVersion,
|
||||
} from "./download/manifest";
|
||||
import * as log from "./utils/logging";
|
||||
|
||||
const VERSION_IN_CHECKSUM_KEY_PATTERN =
|
||||
/-(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)$/;
|
||||
@@ -26,7 +27,7 @@ async function run(): Promise<void> {
|
||||
const latestKnownVersion = getLatestKnownVersionFromChecksums();
|
||||
|
||||
if (semver.lte(latestVersion, latestKnownVersion)) {
|
||||
core.info(
|
||||
log.info(
|
||||
`Latest release (${latestVersion}) is not newer than the latest known version (${latestKnownVersion}). Skipping update.`,
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import path from "node:path";
|
||||
import * as core from "@actions/core";
|
||||
import { getConfigValueFromTomlFile } from "./config-file";
|
||||
import * as log from "./logging";
|
||||
|
||||
export enum CacheLocalSource {
|
||||
Input,
|
||||
@@ -42,6 +43,7 @@ export interface SetupInputs {
|
||||
manifestFile?: string;
|
||||
downloadFromAstralMirror: boolean;
|
||||
addProblemMatchers: boolean;
|
||||
quiet: boolean;
|
||||
resolutionStrategy: ResolutionStrategy;
|
||||
}
|
||||
|
||||
@@ -77,6 +79,7 @@ export function loadInputs(): SetupInputs {
|
||||
const downloadFromAstralMirror =
|
||||
core.getInput("download-from-astral-mirror") === "true";
|
||||
const addProblemMatchers = core.getInput("add-problem-matchers") === "true";
|
||||
const quiet = core.getInput("quiet") === "true";
|
||||
const resolutionStrategy = getResolutionStrategy();
|
||||
|
||||
return {
|
||||
@@ -97,6 +100,7 @@ export function loadInputs(): SetupInputs {
|
||||
pruneCache,
|
||||
pythonDir,
|
||||
pythonVersion,
|
||||
quiet,
|
||||
resolutionStrategy,
|
||||
restoreCache,
|
||||
saveCache,
|
||||
@@ -125,7 +129,7 @@ function getVenvPath(
|
||||
const venvPathInput = core.getInput("venv-path");
|
||||
if (venvPathInput !== "") {
|
||||
if (!activateEnvironment) {
|
||||
core.warning("venv-path is only used when activate-environment is true");
|
||||
log.warning("venv-path is only used when activate-environment is true");
|
||||
}
|
||||
const tildeExpanded = expandTilde(venvPathInput);
|
||||
return normalizePath(resolveRelativePath(workingDirectory, tildeExpanded));
|
||||
@@ -196,7 +200,7 @@ function getCacheLocalPath(
|
||||
return { path: cacheDirFromConfig, source: CacheLocalSource.Config };
|
||||
}
|
||||
if (process.env.UV_CACHE_DIR !== undefined) {
|
||||
core.info(`UV_CACHE_DIR is already set to ${process.env.UV_CACHE_DIR}`);
|
||||
log.info(`UV_CACHE_DIR is already set to ${process.env.UV_CACHE_DIR}`);
|
||||
return { path: process.env.UV_CACHE_DIR, source: CacheLocalSource.Env };
|
||||
}
|
||||
if (enableCache) {
|
||||
@@ -233,12 +237,12 @@ function getCacheDirFromConfig(
|
||||
try {
|
||||
const cacheDir = getConfigValueFromTomlFile(resolvedPath, "cache-dir");
|
||||
if (cacheDir !== undefined) {
|
||||
core.info(`Found cache-dir in ${resolvedPath}: ${cacheDir}`);
|
||||
log.info(`Found cache-dir in ${resolvedPath}: ${cacheDir}`);
|
||||
return cacheDir;
|
||||
}
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
core.warning(`Error while parsing ${filePath}: ${message}`);
|
||||
log.warning(`Error while parsing ${filePath}: ${message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -247,7 +251,7 @@ function getCacheDirFromConfig(
|
||||
|
||||
export function getUvPythonDir(): string {
|
||||
if (process.env.UV_PYTHON_INSTALL_DIR !== undefined) {
|
||||
core.info(
|
||||
log.info(
|
||||
`UV_PYTHON_INSTALL_DIR is already set to ${process.env.UV_PYTHON_INSTALL_DIR}`,
|
||||
);
|
||||
return process.env.UV_PYTHON_INSTALL_DIR;
|
||||
|
||||
21
src/utils/logging.ts
Normal file
21
src/utils/logging.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as core from "@actions/core";
|
||||
|
||||
let quiet: boolean | undefined;
|
||||
|
||||
function isQuiet(): boolean {
|
||||
if (quiet === undefined) {
|
||||
quiet =
|
||||
typeof core.getInput === "function" && core.getInput("quiet") === "true";
|
||||
}
|
||||
return quiet;
|
||||
}
|
||||
|
||||
export function info(msg: string): void {
|
||||
if (!isQuiet()) {
|
||||
core.info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export const warning = core.warning;
|
||||
export const error = core.error;
|
||||
export const debug = core.debug;
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import * as core from "@actions/core";
|
||||
import { getConfigValueFromTomlContent } from "../utils/config-file";
|
||||
import * as log from "../utils/logging";
|
||||
import {
|
||||
getUvVersionFromParsedPyproject,
|
||||
getUvVersionFromRequirementsText,
|
||||
@@ -62,10 +62,10 @@ const VERSION_FILE_PARSERS: VersionFileParser[] = [
|
||||
export function getParsedVersionFile(
|
||||
filePath: string,
|
||||
): ParsedVersionFile | undefined {
|
||||
core.info(`Trying to find version for uv in: ${filePath}`);
|
||||
log.info(`Trying to find version for uv in: ${filePath}`);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
core.info(`Could not find file: ${filePath}`);
|
||||
log.info(`Could not find file: ${filePath}`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -81,15 +81,13 @@ export function getParsedVersionFile(
|
||||
}
|
||||
|
||||
const normalizedSpecifier = normalizeVersionSpecifier(specifier);
|
||||
core.info(`Found version for uv in ${filePath}: ${normalizedSpecifier}`);
|
||||
log.info(`Found version for uv in ${filePath}: ${normalizedSpecifier}`);
|
||||
return {
|
||||
format: parser.format,
|
||||
specifier: normalizedSpecifier,
|
||||
};
|
||||
} catch (error) {
|
||||
core.warning(
|
||||
`Error while parsing ${filePath}: ${(error as Error).message}`,
|
||||
);
|
||||
log.warning(`Error while parsing ${filePath}: ${(error as Error).message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import * as pep440 from "@renovatebot/pep440";
|
||||
import * as semver from "semver";
|
||||
import { getAllVersions, getLatestVersion } from "../download/manifest";
|
||||
import type { ResolutionStrategy } from "../utils/inputs";
|
||||
import * as log from "../utils/logging";
|
||||
import {
|
||||
type ParsedVersionSpecifier,
|
||||
parseVersionSpecifier,
|
||||
@@ -56,7 +57,7 @@ class LatestVersionResolver implements ConcreteVersionResolver {
|
||||
context.parsedSpecifier.kind === "range" &&
|
||||
context.parsedSpecifier.isSimpleMinimumVersionSpecifier
|
||||
) {
|
||||
core.info("Found minimum version specifier, using latest version");
|
||||
log.info("Found minimum version specifier, using latest version");
|
||||
}
|
||||
|
||||
const latestVersion = await getLatestVersion(context.manifestUrl);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as path from "node:path";
|
||||
import * as core from "@actions/core";
|
||||
import * as log from "../utils/logging";
|
||||
import { getParsedVersionFile } from "./file-parser";
|
||||
import { normalizeVersionSpecifier } from "./specifier";
|
||||
import type {
|
||||
@@ -111,7 +111,7 @@ export class WorkspaceVersionResolver implements VersionRequestResolver {
|
||||
};
|
||||
}
|
||||
|
||||
core.info(
|
||||
log.info(
|
||||
"Could not determine uv version from uv.toml or pyproject.toml. Falling back to latest.",
|
||||
);
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user