mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-06-14 08:17:49 +00:00
Some checks failed
Release Drafter / ✏️ Draft release (push) Failing after 13s
test-cache / test-setup-cache (false, ubuntu-latest) (push) Successful in 59s
test-cache / test-setup-cache (true, ubuntu-latest) (push) Successful in 45s
CodeQL / Analyze (TypeScript) (push) Failing after 2m21s
test-cache / test-setup-cache-dependency-glob (push) Failing after 4s
test-cache / test-restore-cache-dependency-glob (push) Has been skipped
test-cache / test-no-python-version (push) Failing after 6s
Check dist/ / check-dist (push) Successful in 2m37s
test / test-default-version (ubuntu-latest) (push) Failing after 6s
test / test-specific-version (0.3) (push) Failing after 4s
test-cache / test-setup-cache-requirements-txt (push) Successful in 49s
test / test-specific-version (0.3.0) (push) Failing after 5s
test / test-specific-version (0.3.x) (push) Failing after 4s
test / test-specific-version (>=0.3.0) (push) Failing after 3s
test / test-semver-range (push) Failing after 4s
test / test-pyproject-file-version (push) Failing after 3s
test / test-uv-file-version (push) Failing after 4s
test / test-checksum (4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd, ubuntu-latest) (push) Failing after 3s
test / test-with-explicit-token (push) Failing after 4s
test / test-specific-version (0.3.2) (push) Successful in 46s
test / test-uvx (push) Failing after 5s
test / test-python-version (macos-latest) (push) Failing after 5s
test / test-python-version (ubuntu-latest) (push) Failing after 3s
test / test-python-version (windows-latest) (push) Failing after 4s
test / test-malformed-pyproject-file-fallback (push) Failing after 4s
test / test-musl (push) Failing after 6s
test / test-tool-install (ubuntu-latest) (push) Successful in 1m4s
test / build (push) Successful in 3m19s
test-cache / test-setup-cache (auto, ubuntu-latest) (push) Failing after 6m47s
test-cache-windows / test-setup-cache (push) Has been cancelled
test-cache / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test-cache / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test-cache / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test-cache / test-setup-cache-local (push) Has been cancelled
test-cache / test-tilde-expansion-cache-local-path (push) Has been cancelled
test-cache / test-tilde-expansion-cache-dependency-glob (push) Has been cancelled
test-windows / test-default-version (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-checksum (a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218, macos-latest) (push) Has been cancelled
test / test-tool-install (macos-14) (push) Has been cancelled
test / test-tool-install (macos-latest) (push) Has been cancelled
test / test-tool-install (windows-latest) (push) Has been cancelled
test / test-tilde-expansion-tool-dirs (push) Has been cancelled
test-cache-windows / test-restore-cache (push) Has been cancelled
test-cache / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test-cache / test-restore-cache (auto, ubuntu-latest) (push) Has been cancelled
test-cache / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test-cache / test-restore-cache (false, ubuntu-latest) (push) Has been cancelled
test-cache / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test-cache / test-restore-cache (true, ubuntu-latest) (push) Has been cancelled
test-cache / test-restore-cache-requirements-txt (push) Has been cancelled
test-cache / test-restore-cache-local (push) Has been cancelled
test-cache / cleanup-tilde-expansion-tests (push) Has been cancelled
Update known checksums / build (push) Failing after 13s
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import fs from "node:fs";
|
|
import * as core from "@actions/core";
|
|
import * as toml from "smol-toml";
|
|
|
|
export function getUvVersionFromConfigFile(
|
|
filePath: string,
|
|
): string | undefined {
|
|
core.debug(`Trying to find required-version for uv in: ${filePath}`);
|
|
if (!fs.existsSync(filePath)) {
|
|
core.warning(`Could not find file: ${filePath}`);
|
|
return undefined;
|
|
}
|
|
let requiredVersion: string | undefined;
|
|
try {
|
|
requiredVersion = getRequiredVersion(filePath);
|
|
} catch (err) {
|
|
const message = (err as Error).message;
|
|
core.warning(`Error while parsing ${filePath}: ${message}`);
|
|
return undefined;
|
|
}
|
|
|
|
if (requiredVersion?.startsWith("==")) {
|
|
requiredVersion = requiredVersion.slice(2);
|
|
}
|
|
if (requiredVersion !== undefined) {
|
|
core.info(
|
|
`Found required-version for uv in ${filePath}: ${requiredVersion}`,
|
|
);
|
|
}
|
|
return requiredVersion;
|
|
}
|
|
|
|
function getRequiredVersion(filePath: string): string | undefined {
|
|
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
|
|
if (filePath.endsWith("pyproject.toml")) {
|
|
const tomlContent = toml.parse(fileContent) as {
|
|
tool?: { uv?: { "required-version"?: string } };
|
|
};
|
|
return tomlContent?.tool?.uv?.["required-version"];
|
|
}
|
|
const tomlContent = toml.parse(fileContent) as {
|
|
"required-version"?: string;
|
|
};
|
|
return tomlContent["required-version"];
|
|
}
|