mirror astral-sh/setup-uv @ d0cc045d04ccac9d8b7881df0226f9e82c39688e
CodeQL / Analyze (TypeScript) (push) Failing after 1s
test / lint (push) Failing after 1s
test / test-default-version (ubuntu-latest) (push) Failing after 0s
test / test-specific-version (0.3) (push) Failing after 0s
test / test-specific-version (0.3.0) (push) Failing after 1s
test / test-specific-version (0.3.2) (push) Failing after 0s
test / test-specific-version (0.3.x) (push) Failing after 0s
test / test-specific-version (>=0.3.0) (push) Failing after 1s
test / test-semver-range (ubuntu-latest) (push) Failing after 1s
test / test-pep440-version (push) Failing after 0s
test / test-pyproject-file-version (push) Failing after 0s
test / test-malformed-pyproject-file-fallback (push) Failing after 0s
test / test-version-file-version (push) Failing after 0s
test / test-uv-file-version (push) Failing after 0s
test / test-version-file-hash-version (push) Failing after 0s
test / test-tool-versions-file-version (push) Failing after 0s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 1s
test / test-with-explicit-token (push) Failing after 0s
test / test-uvx (push) Failing after 1s
test / test-tool-install (ubuntu-latest) (push) Failing after 0s
test / test-python-version (ubuntu-latest) (push) Failing after 0s
test / test-activate-environment (ubuntu-latest) (push) Failing after 0s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 0s
test / test-musl (push) Failing after 0s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 0s
test / test-setup-cache-requirements-txt (push) Failing after 0s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 0s
test / test-restore-cache-requirements-txt (push) Skipped
test / test-setup-cache-save-cache-false (push) Failing after 0s
test / test-setup-cache-dependency-glob (push) Failing after 0s
test / test-restore-cache-dependency-glob (push) Skipped
test / test-restore-cache-save-cache-false (push) Skipped
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 1s
test / test-setup-cache-restore-cache-false (push) Failing after 0s
test / test-restore-cache-restore-cache-false (push) Skipped
test / test-no-python-version (push) Failing after 0s
test / test-absolute-path (push) Failing after 0s
test / test-custom-manifest-file (push) Failing after 0s
test / test-relative-path (push) Failing after 0s
test / test-default-version (macos-14) (push) Canceled after 0s
test / test-default-version (macos-latest) (push) Canceled after 0s
test / test-default-version (windows-latest) (push) Canceled after 0s
test / test-semver-range (selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Canceled after 0s
test / test-tool-install (macos-14) (push) Canceled after 0s
test / test-tool-install (macos-latest) (push) Canceled after 0s
test / test-tool-install (windows-latest) (push) Canceled after 0s
test / test-tilde-expansion-tool-dirs (push) Canceled after 0s
test / test-python-version (macos-latest) (push) Canceled after 0s
test / test-python-version (windows-latest) (push) Canceled after 0s
test / test-activate-environment (macos-latest) (push) Canceled after 0s
test / test-activate-environment (windows-latest) (push) Canceled after 0s
test / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-setup-cache (auto, windows-latest) (push) Canceled after 0s
test / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-setup-cache (false, windows-latest) (push) Canceled after 0s
test / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-setup-cache (true, windows-latest) (push) Canceled after 0s
test / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-restore-cache (auto, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (auto, windows-latest) (push) Canceled after 0s
test / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-restore-cache (false, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (false, windows-latest) (push) Canceled after 0s
test / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Canceled after 0s
test / test-restore-cache (true, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (true, windows-latest) (push) Canceled after 0s
test / test-cache-local (map[expected-cache-dir:/home/ubuntu/.cache/uv os:selfhosted-ubuntu-arm64]) (push) Canceled after 0s
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Canceled after 0s
test / test-setup-cache-local (push) Canceled after 0s
test / test-restore-cache-local (push) Canceled after 0s
test / test-tilde-expansion-cache-local-path (push) Canceled after 0s
test / test-tilde-expansion-cache-dependency-glob (push) Canceled after 0s
test / cleanup-tilde-expansion-tests (push) Canceled after 0s
test / all-tests-passed (push) Canceled after 0s
Release Drafter / ✏️ Draft release (push) Canceled after 0s

This commit is contained in:
George Berkshire
2026-08-16 19:45:30 +08:00
commit 39f0e490cd
83 changed files with 347770 additions and 0 deletions
@@ -0,0 +1,115 @@
jest.mock("node:fs");
jest.mock("@actions/core", () => ({
warning: jest.fn(),
}));
import fs from "node:fs";
import * as core from "@actions/core";
import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import { getUvVersionFromToolVersions } from "../../src/version/tool-versions-file";
const mockedFs = fs as jest.Mocked<typeof fs>;
const mockedCore = core as jest.Mocked<typeof core>;
describe("getUvVersionFromToolVersions", () => {
beforeEach(() => {
jest.clearAllMocks();
});
it("should return undefined for non-.tool-versions files", () => {
const result = getUvVersionFromToolVersions("package.json");
expect(result).toBeUndefined();
expect(mockedFs.readFileSync).not.toHaveBeenCalled();
});
it("should return version for valid uv entry", () => {
const fileContent = "python 3.11.0\nuv 0.1.0\nnodejs 18.0.0";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.1.0");
expect(mockedFs.readFileSync).toHaveBeenCalledWith(
".tool-versions",
"utf8",
);
});
it("should return version for uv entry with v prefix", () => {
const fileContent = "uv v0.2.0";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.2.0");
});
it("should handle whitespace around uv entry", () => {
const fileContent = " uv 0.3.0 ";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.3.0");
});
it("should skip commented lines", () => {
const fileContent = "# uv 0.1.0\npython 3.11.0\nuv 0.2.0";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.2.0");
});
it("should return first matching uv version", () => {
const fileContent = "uv 0.1.0\npython 3.11.0\nuv 0.2.0";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.1.0");
});
it("should return undefined when no uv entry found", () => {
const fileContent = "python 3.11.0\nnodejs 18.0.0";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBeUndefined();
});
it("should return undefined for empty file", () => {
mockedFs.readFileSync.mockReturnValue("");
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBeUndefined();
});
it("should warn and return undefined for ref syntax", () => {
const fileContent = "uv ref:main";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions");
expect(result).toBeUndefined();
expect(mockedCore.warning).toHaveBeenCalledWith(
"The ref syntax of .tool-versions is not supported. Please use a released version instead.",
);
});
it("should handle file path with .tool-versions extension", () => {
const fileContent = "uv 0.1.0";
mockedFs.readFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions("path/to/.tool-versions");
expect(result).toBe("0.1.0");
expect(mockedFs.readFileSync).toHaveBeenCalledWith(
"path/to/.tool-versions",
"utf8",
);
});
});