Add quiet input to suppress info-level log output (#898)
test / test-latest-version (latest) (push) Failing after 35s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 36s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 37s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 40s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 44s
test / test-uv-no-modify-path (push) Failing after 50s
test / test-latest-version (>=0.8) (push) Failing after 49s
test / test-specific-version (map[expected-version:0.1.0 resolution-strategy:lowest version-input:>=0.1.0,<0.2]) (push) Failing after 51s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25]) (push) Failing after 50s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 50s
test / test-default-version (ubuntu-latest) (push) Failing after 51s
test / test-specific-version (map[expected-version:0.1.45 resolution-strategy:highest version-input:>=0.1,<0.2]) (push) Failing after 52s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 53s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25,<0.5]) (push) Failing after 53s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 31s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 33s
test / test-version-file-version (map[expected-version:0.8.3 version-file:__tests__/fixtures/uv-in-requirements-hash-txt-project/requirements.txt]) (push) Failing after 46s
test / test-version-file-version (map[expected-version:0.6.17 version-file:__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt]) (push) Failing after 49s
test / test-malformed-pyproject-file-fallback (push) Failing after 49s
test / test-uvx (push) Failing after 47s
test / test-python-version (ubuntu-latest) (push) Failing after 48s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 52s
test / test-with-explicit-token (push) Failing after 53s
test / test-activate-environment (ubuntu-latest) (push) Failing after 53s
test / test-tool-install (ubuntu-latest) (push) Failing after 54s
test / test-activate-environment-custom-path (ubuntu-latest) (push) Failing after 53s
test / test-debian-unstable (push) Failing after 55s
test / test-musl (push) Failing after 43s
test / test-activate-environment-no-project (push) Failing after 58s
test / test-cache-key-os-version (ubuntu-22.04, ubuntu-22.04) (push) Failing after 55s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 39s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 40s
test / lint (push) Failing after 2m10s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 42s
test / test-setup-cache-requirements-txt (push) Failing after 50s
test / test-setup-cache-dependency-glob (push) Failing after 49s
test / test-restore-cache-requirements-txt (push) Has been skipped
test / test-restore-cache-dependency-glob (push) Has been skipped
test / test-setup-cache-save-cache-false (push) Failing after 51s
test / test-setup-cache-restore-cache-false (push) Failing after 51s
test / test-restore-cache-save-cache-false (push) Has been skipped
test / test-restore-cache-restore-cache-false (push) Has been skipped
test / test-cache-local-cache-disabled (push) Failing after 51s
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 53s
test / test-cache-local-cache-disabled-but-explicit-path (push) Failing after 52s
test / test-custom-manifest-file (push) Failing after 50s
test / test-download-from-astral-mirror-false (push) Failing after 49s
test / test-no-python-version (push) Failing after 53s
test / test-cache-prune-force (push) Failing after 38s
test / test-absolute-path (push) Failing after 43s
test / test-cache-python-missing-managed-install-dir (push) Failing after 32s
test / test-cache-dir-from-file (push) Failing after 40s
test / test-python-install-dir (map[expected-python-dir:/home/runner/work/_temp/uv-python-dir os:ubuntu-latest]) (push) Failing after 24s
test / test-relative-path (push) Failing after 47s
test / test-act (push) Failing after 21s
test / test-cache-python-installs (push) Failing after 26s
test / test-restore-python-installs (push) Has been skipped
test / validate-typings (push) Successful in 49s
CodeQL / Analyze (TypeScript) (push) Failing after 18m18s
test / test-tool-install (windows-latest) (push) Has been cancelled
Release Drafter / ✏️ Draft release (push) Has been cancelled
test / test-default-version (macos-14) (push) Has been cancelled
test / test-default-version (macos-latest) (push) Has been cancelled
test / test-default-version (windows-latest) (push) Has been cancelled
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Has been cancelled
test / test-tool-install (macos-latest) (push) Has been cancelled
test / test-python-version (macos-latest) (push) Has been cancelled
test / test-python-version (windows-latest) (push) Has been cancelled
test / test-activate-environment (macos-latest) (push) Has been cancelled
test / test-activate-environment (windows-latest) (push) Has been cancelled
test / test-cache-key-os-version (macos-14, macos-14) (push) Has been cancelled
test / test-tool-install (macos-14) (push) Has been cancelled
test / test-activate-environment-custom-path (macos-latest) (push) Has been cancelled
test / test-activate-environment-custom-path (windows-latest) (push) Has been cancelled
test / test-cache-key-os-version (macos-15, macos-15) (push) Has been cancelled
test / test-cache-key-os-version (ubuntu-24.04, ubuntu-24.04) (push) Has been cancelled
test / test-cache-key-os-version (windows-2022, windows-2022) (push) Has been cancelled
test / test-cache-key-os-version (windows-2025, windows-2025) (push) Has been cancelled
test / test-setup-cache (auto, windows-latest) (push) Has been cancelled
test / test-setup-cache (false, windows-latest) (push) Has been cancelled
test / test-setup-cache (true, windows-latest) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Has been cancelled
test / test-python-install-dir (map[expected-python-dir:D:\a\_temp\uv-python-dir os:windows-latest]) (push) Has been cancelled
test / test-restore-cache (false, windows-latest) (push) Has been cancelled
test / test-restore-cache (auto, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (auto, windows-latest) (push) Has been cancelled
test / test-restore-cache (false, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (true, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (true, windows-latest) (push) Has been cancelled
test / all-tests-passed (push) Has been cancelled

## 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:
Kevin Stillhammer
2026-05-31 21:13:30 +02:00
committed by GitHub
parent e07f2ac4b7
commit a92cb43098
18 changed files with 705 additions and 612 deletions
+8 -7
View File
@@ -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);
}
+4 -3
View File
@@ -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);
+3 -2
View File
@@ -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 -2
View File
@@ -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()) {
+11 -12
View File
@@ -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();
+22 -21
View File
@@ -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}`);
}
}
+2 -1
View File
@@ -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;
+9 -5
View File
@@ -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
View 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;
+5 -7
View File
@@ -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;
}
}
+2 -1
View File
@@ -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);
+2 -2
View File
@@ -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;