Compare commits

..

3 Commits

Author SHA1 Message Date
Kevin Stillhammer
fd8f376b22 Switch to ESM for source and test, use CommonJS for dist (#806)
Some checks failed
Release Drafter / ✏️ Draft release (push) Waiting to run
test / test-tool-install (macos-latest) (push) Waiting to run
test / test-tool-install (windows-latest) (push) Waiting to run
test / test-default-version (macos-14) (push) Waiting to run
test / test-default-version (macos-latest) (push) Waiting to run
test / test-default-version (windows-latest) (push) Waiting to run
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Waiting to run
test / test-tool-install (macos-14) (push) Waiting to run
test / test-python-version (macos-latest) (push) Waiting to run
test / test-python-version (windows-latest) (push) Waiting to run
test / test-activate-environment (macos-latest) (push) Waiting to run
test / test-activate-environment (windows-latest) (push) Waiting to run
test / test-activate-environment-custom-path (macos-latest) (push) Waiting to run
test / test-activate-environment-custom-path (windows-latest) (push) Waiting to run
test / test-cache-key-os-version (macos-14, macos-14) (push) Waiting to run
test / test-cache-key-os-version (macos-15, macos-15) (push) Waiting to run
test / test-cache-key-os-version (ubuntu-24.04, ubuntu-24.04) (push) Waiting to run
test / test-cache-key-os-version (windows-2022, windows-2022) (push) Waiting to run
test / test-cache-key-os-version (windows-2025, windows-2025) (push) Waiting to run
test / test-setup-cache (auto, windows-latest) (push) Waiting to run
test / test-setup-cache (false, windows-latest) (push) Waiting to run
test / test-setup-cache (true, windows-latest) (push) Waiting to run
test / test-restore-cache (auto, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (false, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (auto, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (false, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (true, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (true, windows-latest) (push) Blocked by required conditions
CodeQL / Analyze (TypeScript) (push) Failing after 7s
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Waiting to run
test / lint (push) Failing after 3s
test / test-python-install-dir (map[expected-python-dir:D:\a\_temp\uv-python-dir os:windows-latest]) (push) Waiting to run
test / all-tests-passed (push) Blocked by required conditions
test / test-uv-no-modify-path (push) Failing after 3s
test / test-default-version (ubuntu-latest) (push) Failing after 3s
test / test-specific-version (map[expected-version:0.1.0 resolution-strategy:lowest version-input:>=0.1.0,<0.2]) (push) Failing after 3s
test / test-specific-version (map[expected-version:0.1.45 resolution-strategy:highest version-input:>=0.1,<0.2]) (push) Failing after 3s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 5s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 6s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 5s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 5s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25,<0.5]) (push) Failing after 5s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25]) (push) Failing after 9s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 9s
test / test-latest-version (>=0.8) (push) Failing after 9s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 9s
test / test-latest-version (latest) (push) Failing after 9s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 9s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 10s
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 11s
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 11s
test / test-malformed-pyproject-file-fallback (push) Failing after 12s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 12s
test / test-with-explicit-token (push) Failing after 11s
test / test-uvx (push) Failing after 12s
test / test-tool-install (ubuntu-latest) (push) Failing after 12s
test / test-python-version (ubuntu-latest) (push) Failing after 13s
test / test-activate-environment (ubuntu-latest) (push) Failing after 13s
test / test-activate-environment-custom-path (ubuntu-latest) (push) Failing after 13s
test / test-cache-key-os-version (ubuntu-22.04, ubuntu-22.04) (push) Failing after 13s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 13s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 13s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 14s
test / test-restore-cache-requirements-txt (push) Has been skipped
test / test-setup-cache-requirements-txt (push) Failing after 15s
test / test-setup-cache-dependency-glob (push) Failing after 20s
test / test-restore-cache-dependency-glob (push) Has been skipped
test / test-setup-cache-save-cache-false (push) Failing after 22s
test / test-restore-cache-save-cache-false (push) Has been skipped
test / test-debian-unstable (push) Failing after 32s
test / test-musl (push) Failing after 33s
test / test-setup-cache-restore-cache-false (push) Failing after 26s
test / test-restore-cache-restore-cache-false (push) Has been skipped
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 27s
test / test-cache-local-cache-disabled (push) Failing after 27s
test / test-cache-local-cache-disabled-but-explicit-path (push) Failing after 27s
test / test-no-python-version (push) Failing after 28s
test / test-custom-manifest-file (push) Failing after 29s
test / test-absolute-path (push) Failing after 30s
test / test-relative-path (push) Failing after 30s
test / test-cache-prune-force (push) Failing after 30s
test / test-cache-dir-from-file (push) Failing after 33s
test / test-cache-python-missing-managed-install-dir (push) Failing after 34s
test / test-restore-python-installs (push) Has been skipped
test / test-cache-python-installs (push) Failing after 34s
test / test-python-install-dir (map[expected-python-dir:/home/runner/work/_temp/uv-python-dir os:ubuntu-latest]) (push) Failing after 34s
test / test-act (push) Failing after 35s
test / validate-typings (push) Failing after 36s
2026-03-14 17:43:49 +01:00
Kevin Stillhammer
f9070de1ea Bump deps (#805) 2026-03-14 12:54:28 +01:00
github-actions[bot]
cadb67bdc9 chore: update known checksums for 0.10.10 (#804)
Some checks failed
CodeQL / Analyze (TypeScript) (push) Failing after 4s
test / lint (push) Failing after 4s
test / test-default-version (ubuntu-latest) (push) Failing after 4s
test / test-specific-version (map[expected-version:0.1.0 resolution-strategy:lowest version-input:>=0.1.0,<0.2]) (push) Failing after 4s
test / test-uv-no-modify-path (push) Failing after 4s
test / test-specific-version (map[expected-version:0.1.45 resolution-strategy:highest version-input:>=0.1,<0.2]) (push) Failing after 4s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 4s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 4s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 4s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 3s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25,<0.5]) (push) Failing after 3s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25]) (push) Failing after 3s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 3s
test / test-latest-version (>=0.8) (push) Failing after 3s
test / test-latest-version (latest) (push) Failing after 3s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 3s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 3s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 2s
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 2s
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 3s
test / test-malformed-pyproject-file-fallback (push) Failing after 3s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 8s
test / test-with-explicit-token (push) Failing after 12s
test / test-uvx (push) Failing after 18s
test / test-tool-install (ubuntu-latest) (push) Failing after 19s
test / test-python-version (ubuntu-latest) (push) Failing after 20s
test / test-activate-environment (ubuntu-latest) (push) Failing after 21s
test / test-activate-environment-custom-path (ubuntu-latest) (push) Failing after 22s
test / test-cache-key-os-version (ubuntu-22.04, ubuntu-22.04) (push) Failing after 22s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 24s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 29s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 30s
test / test-setup-cache-requirements-txt (push) Failing after 31s
test / test-restore-cache-requirements-txt (push) Has been skipped
test / test-setup-cache-dependency-glob (push) Failing after 32s
test / test-restore-cache-dependency-glob (push) Has been skipped
test / test-setup-cache-save-cache-false (push) Failing after 34s
test / test-restore-cache-save-cache-false (push) Has been skipped
test / test-setup-cache-restore-cache-false (push) Failing after 36s
test / test-restore-cache-restore-cache-false (push) Has been skipped
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 36s
test / test-cache-local-cache-disabled (push) Failing after 37s
test / test-debian-unstable (push) Failing after 50s
test / test-musl (push) Failing after 52s
test / test-cache-local-cache-disabled-but-explicit-path (push) Failing after 43s
test / test-no-python-version (push) Failing after 45s
test / test-custom-manifest-file (push) Failing after 45s
test / test-absolute-path (push) Failing after 47s
test / test-relative-path (push) Failing after 48s
test / test-cache-prune-force (push) Failing after 49s
test / test-cache-dir-from-file (push) Failing after 49s
test / test-cache-python-missing-managed-install-dir (push) Failing after 50s
test / test-cache-python-installs (push) Failing after 51s
test / test-restore-python-installs (push) Has been skipped
test / test-python-install-dir (map[expected-python-dir:/home/runner/work/_temp/uv-python-dir os:ubuntu-latest]) (push) Failing after 51s
test / test-act (push) Failing after 52s
test / validate-typings (push) Failing after 53s
Release Drafter / ✏️ Draft release (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-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Has been cancelled
test / test-tool-install (macos-14) (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-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-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-14, macos-14) (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-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 (false, windows-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 / 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 / all-tests-passed (push) Has been cancelled
chore: update known checksums for 0.10.10

Co-authored-by: eifinger <eifinger@users.noreply.github.com>
2026-03-14 09:45:38 +01:00
26 changed files with 212378 additions and 231211 deletions

View File

@@ -47,7 +47,7 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6 uses: github/codeql-action/init@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
source-root: src source-root: src
@@ -59,7 +59,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6 uses: github/codeql-action/autobuild@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 https://git.io/JvXDl
@@ -73,4 +73,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6 uses: github/codeql-action/analyze@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2

View File

@@ -38,7 +38,7 @@ jobs:
npm run all npm run all
- name: Check all jobs are in all-tests-passed.needs - name: Check all jobs are in all-tests-passed.needs
run: | run: |
tsc check-all-tests-passed-needs.ts tsc --module nodenext --moduleResolution nodenext --target es2022 check-all-tests-passed-needs.ts
node check-all-tests-passed-needs.js node check-all-tests-passed-needs.js
working-directory: .github/scripts working-directory: .github/scripts
- name: Make sure no changes from linters are detected - name: Make sure no changes from linters are detected

View File

@@ -20,11 +20,12 @@ jobs:
persist-credentials: true persist-credentials: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with: with:
node-version: "20" node-version-file: .nvmrc
cache: npm
- name: Update known checksums - name: Update known checksums
id: update-known-checksums id: update-known-checksums
run: run:
node dist/update-known-checksums/index.js node dist/update-known-checksums/index.cjs
src/download/checksum/known-checksums.ts src/download/checksum/known-checksums.ts
- name: Check for changes - name: Check for changes
id: changes-exist id: changes-exist

View File

@@ -10,4 +10,9 @@ This repository is a TypeScript-based GitHub Action for installing `uv` in GitHu
- User-facing changes are usually multi-file changes. If you add or change inputs, outputs, or behavior, update `action.yml`, the implementation in `src/`, tests in `__tests__/`, relevant docs/README, and then re-package. - User-facing changes are usually multi-file changes. If you add or change inputs, outputs, or behavior, update `action.yml`, the implementation in `src/`, tests in `__tests__/`, relevant docs/README, and then re-package.
- The easiest areas to regress are version resolution and caching. When touching them, add or update tests for precedence, cache invalidation, and cross-platform path behavior. - The easiest areas to regress are version resolution and caching. When touching them, add or update tests for precedence, cache invalidation, and cross-platform path behavior.
- Workflow edits have extra CI-only checks (`actionlint` and `zizmor`); `npm run all` does not cover them. - Workflow edits have extra CI-only checks (`actionlint` and `zizmor`); `npm run all` does not cover them.
- Source is authored with bundler-friendly TypeScript, but published action artifacts in `dist/` are bundled as CommonJS for maximum GitHub Actions runtime compatibility with `@actions/*` dependencies.
- Keep these concerns separate when changing module formats:
- `src/` and tests may use modern ESM-friendly TypeScript patterns.
- `dist/` should prioritize runtime reliability over format purity.
- Do not switch published bundles to ESM without validating the actual committed artifacts under the target Node runtime.
- Before finishing, make sure validation does not leave generated or formatting-only diffs behind. - Before finishing, make sure validation does not leave generated or formatting-only diffs behind.

View File

@@ -1,9 +1,10 @@
import { beforeEach, describe, expect, it, jest } from "@jest/globals"; import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import * as semver from "semver";
const mockInfo = jest.fn(); const mockInfo = jest.fn();
const mockWarning = jest.fn(); const mockWarning = jest.fn();
jest.mock("@actions/core", () => ({ jest.unstable_mockModule("@actions/core", () => ({
debug: jest.fn(), debug: jest.fn(),
info: mockInfo, info: mockInfo,
warning: mockWarning, warning: mockWarning,
@@ -18,20 +19,17 @@ const mockExtractZip = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockCacheDir = jest.fn<any>(); const mockCacheDir = jest.fn<any>();
jest.mock("@actions/tool-cache", () => { jest.unstable_mockModule("@actions/tool-cache", () => ({
const actual = jest.requireActual("@actions/tool-cache") as Record<
string,
unknown
>;
return {
...actual,
cacheDir: mockCacheDir, cacheDir: mockCacheDir,
downloadTool: mockDownloadTool, downloadTool: mockDownloadTool,
evaluateVersions: (versions: string[], range: string) =>
semver.maxSatisfying(versions, range) ?? "",
extractTar: mockExtractTar, extractTar: mockExtractTar,
extractZip: mockExtractZip, extractZip: mockExtractZip,
}; find: () => "",
}); findAllVersions: () => [],
isExplicitVersion: (version: string) => semver.valid(version) !== null,
}));
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetLatestVersionFromNdjson = jest.fn<any>(); const mockGetLatestVersionFromNdjson = jest.fn<any>();
@@ -40,7 +38,7 @@ const mockGetAllVersionsFromNdjson = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetArtifactFromNdjson = jest.fn<any>(); const mockGetArtifactFromNdjson = jest.fn<any>();
jest.mock("../../src/download/versions-client", () => ({ jest.unstable_mockModule("../../src/download/versions-client", () => ({
getAllVersions: mockGetAllVersionsFromNdjson, getAllVersions: mockGetAllVersionsFromNdjson,
getArtifact: mockGetArtifactFromNdjson, getArtifact: mockGetArtifactFromNdjson,
getLatestVersion: mockGetLatestVersionFromNdjson, getLatestVersion: mockGetLatestVersionFromNdjson,
@@ -53,7 +51,7 @@ const mockGetLatestVersionInManifest = jest.fn<any>();
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockGetManifestArtifact = jest.fn<any>(); const mockGetManifestArtifact = jest.fn<any>();
jest.mock("../../src/download/version-manifest", () => ({ jest.unstable_mockModule("../../src/download/version-manifest", () => ({
getAllVersions: mockGetAllManifestVersions, getAllVersions: mockGetAllManifestVersions,
getLatestKnownVersion: mockGetLatestVersionInManifest, getLatestKnownVersion: mockGetLatestVersionInManifest,
getManifestArtifact: mockGetManifestArtifact, getManifestArtifact: mockGetManifestArtifact,
@@ -62,15 +60,15 @@ jest.mock("../../src/download/version-manifest", () => ({
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockValidateChecksum = jest.fn<any>(); const mockValidateChecksum = jest.fn<any>();
jest.mock("../../src/download/checksum/checksum", () => ({ jest.unstable_mockModule("../../src/download/checksum/checksum", () => ({
validateChecksum: mockValidateChecksum, validateChecksum: mockValidateChecksum,
})); }));
import { const {
downloadVersionFromManifest, downloadVersionFromManifest,
downloadVersionFromNdjson, downloadVersionFromNdjson,
resolveVersion, resolveVersion,
} from "../../src/download/download-version"; } = await import("../../src/download/download-version");
describe("download-version", () => { describe("download-version", () => {
beforeEach(() => { beforeEach(() => {

View File

@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, jest } from "@jest/globals";
const mockWarning = jest.fn(); const mockWarning = jest.fn();
jest.mock("@actions/core", () => ({ jest.unstable_mockModule("@actions/core", () => ({
debug: jest.fn(), debug: jest.fn(),
info: jest.fn(), info: jest.fn(),
warning: mockWarning, warning: mockWarning,
@@ -10,16 +10,16 @@ jest.mock("@actions/core", () => ({
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockFetch = jest.fn<any>(); const mockFetch = jest.fn<any>();
jest.mock("../../src/utils/fetch", () => ({ jest.unstable_mockModule("../../src/utils/fetch", () => ({
fetch: mockFetch, fetch: mockFetch,
})); }));
import { const {
clearManifestCache, clearManifestCache,
getAllVersions, getAllVersions,
getLatestKnownVersion, getLatestKnownVersion,
getManifestArtifact, getManifestArtifact,
} from "../../src/download/version-manifest"; } = await import("../../src/download/version-manifest");
const legacyManifestResponse = JSON.stringify([ const legacyManifestResponse = JSON.stringify([
{ {

View File

@@ -2,18 +2,19 @@ import { beforeEach, describe, expect, it, jest } from "@jest/globals";
// biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests. // biome-ignore lint/suspicious/noExplicitAny: Mock requires flexible typing in tests.
const mockFetch = jest.fn<any>(); const mockFetch = jest.fn<any>();
jest.mock("../../src/utils/fetch", () => ({
jest.unstable_mockModule("../../src/utils/fetch", () => ({
fetch: mockFetch, fetch: mockFetch,
})); }));
import { const {
clearCache, clearCache,
fetchVersionData, fetchVersionData,
getAllVersions, getAllVersions,
getArtifact, getArtifact,
getLatestVersion, getLatestVersion,
parseVersionData, parseVersionData,
} from "../../src/download/versions-client"; } = await import("../../src/download/versions-client");
const sampleNdjsonResponse = `{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f"},{"platform":"x86_64-pc-windows-msvc","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip","archive_format":"zip","sha256":"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036"}]} const sampleNdjsonResponse = `{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f"},{"platform":"x86_64-pc-windows-msvc","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip","archive_format":"zip","sha256":"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036"}]}
{"version":"0.9.25","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.25/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"606b3c6949d971709f2526fa0d9f0fd23ccf60e09f117999b406b424af18a6a6"}]}`; {"version":"0.9.25","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.25/uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"606b3c6949d971709f2526fa0d9f0fd23ccf60e09f117999b406b424af18a6a6"}]}`;

View File

@@ -1,14 +1,3 @@
jest.mock("@actions/core", () => {
return {
debug: jest.fn(),
getBooleanInput: jest.fn(
(name: string) => (mockInputs[name] ?? "") === "true",
),
getInput: jest.fn((name: string) => mockInputs[name] ?? ""),
warning: jest.fn(),
};
});
import { import {
afterEach, afterEach,
beforeEach, beforeEach,
@@ -22,6 +11,26 @@ import {
let mockInputs: Record<string, string> = {}; let mockInputs: Record<string, string> = {};
const ORIGINAL_HOME = process.env.HOME; const ORIGINAL_HOME = process.env.HOME;
const mockDebug = jest.fn();
const mockGetBooleanInput = jest.fn(
(name: string) => (mockInputs[name] ?? "") === "true",
);
const mockGetInput = jest.fn((name: string) => mockInputs[name] ?? "");
const mockInfo = jest.fn();
const mockWarning = jest.fn();
jest.unstable_mockModule("@actions/core", () => ({
debug: mockDebug,
getBooleanInput: mockGetBooleanInput,
getInput: mockGetInput,
info: mockInfo,
warning: mockWarning,
}));
async function importInputsModule() {
return await import("../../src/utils/inputs");
}
describe("cacheDependencyGlob", () => { describe("cacheDependencyGlob", () => {
beforeEach(() => { beforeEach(() => {
jest.resetModules(); jest.resetModules();
@@ -36,21 +45,21 @@ describe("cacheDependencyGlob", () => {
it("returns empty string when input not provided", async () => { it("returns empty string when input not provided", async () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
const { cacheDependencyGlob } = await import("../../src/utils/inputs"); const { cacheDependencyGlob } = await importInputsModule();
expect(cacheDependencyGlob).toBe(""); expect(cacheDependencyGlob).toBe("");
}); });
it("resolves a single relative path", async () => { it("resolves a single relative path", async () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["cache-dependency-glob"] = "requirements.txt"; mockInputs["cache-dependency-glob"] = "requirements.txt";
const { cacheDependencyGlob } = await import("../../src/utils/inputs"); const { cacheDependencyGlob } = await importInputsModule();
expect(cacheDependencyGlob).toBe("/workspace/requirements.txt"); expect(cacheDependencyGlob).toBe("/workspace/requirements.txt");
}); });
it("strips leading ./ from relative path", async () => { it("strips leading ./ from relative path", async () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["cache-dependency-glob"] = "./uv.lock"; mockInputs["cache-dependency-glob"] = "./uv.lock";
const { cacheDependencyGlob } = await import("../../src/utils/inputs"); const { cacheDependencyGlob } = await importInputsModule();
expect(cacheDependencyGlob).toBe("/workspace/uv.lock"); expect(cacheDependencyGlob).toBe("/workspace/uv.lock");
}); });
@@ -58,7 +67,7 @@ describe("cacheDependencyGlob", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["cache-dependency-glob"] = mockInputs["cache-dependency-glob"] =
" ~/.cache/file1\n ./rel/file2 \nfile3.txt"; " ~/.cache/file1\n ./rel/file2 \nfile3.txt";
const { cacheDependencyGlob } = await import("../../src/utils/inputs"); const { cacheDependencyGlob } = await importInputsModule();
expect(cacheDependencyGlob).toBe( expect(cacheDependencyGlob).toBe(
[ [
"/home/testuser/.cache/file1", // expanded tilde, absolute path unchanged "/home/testuser/.cache/file1", // expanded tilde, absolute path unchanged
@@ -71,7 +80,7 @@ describe("cacheDependencyGlob", () => {
it("keeps absolute path unchanged in multiline input", async () => { it("keeps absolute path unchanged in multiline input", async () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["cache-dependency-glob"] = "/abs/path.lock\nrelative.lock"; mockInputs["cache-dependency-glob"] = "/abs/path.lock\nrelative.lock";
const { cacheDependencyGlob } = await import("../../src/utils/inputs"); const { cacheDependencyGlob } = await importInputsModule();
expect(cacheDependencyGlob).toBe( expect(cacheDependencyGlob).toBe(
["/abs/path.lock", "/workspace/relative.lock"].join("\n"), ["/abs/path.lock", "/workspace/relative.lock"].join("\n"),
); );
@@ -80,7 +89,7 @@ describe("cacheDependencyGlob", () => {
it("handles exclusions in relative paths correct", async () => { it("handles exclusions in relative paths correct", async () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["cache-dependency-glob"] = "!/abs/path.lock\n!relative.lock"; mockInputs["cache-dependency-glob"] = "!/abs/path.lock\n!relative.lock";
const { cacheDependencyGlob } = await import("../../src/utils/inputs"); const { cacheDependencyGlob } = await importInputsModule();
expect(cacheDependencyGlob).toBe( expect(cacheDependencyGlob).toBe(
["!/abs/path.lock", "!/workspace/relative.lock"].join("\n"), ["!/abs/path.lock", "!/workspace/relative.lock"].join("\n"),
); );
@@ -104,7 +113,7 @@ describe("tool directories", () => {
mockInputs["tool-bin-dir"] = "~/tool-bin-dir"; mockInputs["tool-bin-dir"] = "~/tool-bin-dir";
mockInputs["tool-dir"] = "~/tool-dir"; mockInputs["tool-dir"] = "~/tool-dir";
const { toolBinDir, toolDir } = await import("../../src/utils/inputs"); const { toolBinDir, toolDir } = await importInputsModule();
expect(toolBinDir).toBe("/home/testuser/tool-bin-dir"); expect(toolBinDir).toBe("/home/testuser/tool-bin-dir");
expect(toolDir).toBe("/home/testuser/tool-dir"); expect(toolDir).toBe("/home/testuser/tool-dir");
@@ -127,9 +136,7 @@ describe("cacheLocalPath", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["cache-local-path"] = "~/uv-cache/cache-local-path"; mockInputs["cache-local-path"] = "~/uv-cache/cache-local-path";
const { CacheLocalSource, cacheLocalPath } = await import( const { CacheLocalSource, cacheLocalPath } = await importInputsModule();
"../../src/utils/inputs"
);
expect(cacheLocalPath).toEqual({ expect(cacheLocalPath).toEqual({
path: "/home/testuser/uv-cache/cache-local-path", path: "/home/testuser/uv-cache/cache-local-path",
@@ -152,7 +159,7 @@ describe("venvPath", () => {
it("defaults to .venv in the working directory", async () => { it("defaults to .venv in the working directory", async () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
const { venvPath } = await import("../../src/utils/inputs"); const { venvPath } = await importInputsModule();
expect(venvPath).toBe("/workspace/.venv"); expect(venvPath).toBe("/workspace/.venv");
}); });
@@ -160,7 +167,7 @@ describe("venvPath", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["activate-environment"] = "true"; mockInputs["activate-environment"] = "true";
mockInputs["venv-path"] = "custom-venv"; mockInputs["venv-path"] = "custom-venv";
const { venvPath } = await import("../../src/utils/inputs"); const { venvPath } = await importInputsModule();
expect(venvPath).toBe("/workspace/custom-venv"); expect(venvPath).toBe("/workspace/custom-venv");
}); });
@@ -168,7 +175,7 @@ describe("venvPath", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["activate-environment"] = "true"; mockInputs["activate-environment"] = "true";
mockInputs["venv-path"] = "custom-venv/"; mockInputs["venv-path"] = "custom-venv/";
const { venvPath } = await import("../../src/utils/inputs"); const { venvPath } = await importInputsModule();
expect(venvPath).toBe("/workspace/custom-venv"); expect(venvPath).toBe("/workspace/custom-venv");
}); });
@@ -176,7 +183,7 @@ describe("venvPath", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["activate-environment"] = "true"; mockInputs["activate-environment"] = "true";
mockInputs["venv-path"] = "/tmp/custom-venv"; mockInputs["venv-path"] = "/tmp/custom-venv";
const { venvPath } = await import("../../src/utils/inputs"); const { venvPath } = await importInputsModule();
expect(venvPath).toBe("/tmp/custom-venv"); expect(venvPath).toBe("/tmp/custom-venv");
}); });
@@ -184,7 +191,7 @@ describe("venvPath", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["activate-environment"] = "true"; mockInputs["activate-environment"] = "true";
mockInputs["venv-path"] = "~/.venv"; mockInputs["venv-path"] = "~/.venv";
const { venvPath } = await import("../../src/utils/inputs"); const { venvPath } = await importInputsModule();
expect(venvPath).toBe("/home/testuser/.venv"); expect(venvPath).toBe("/home/testuser/.venv");
}); });
@@ -192,18 +199,11 @@ describe("venvPath", () => {
mockInputs["working-directory"] = "/workspace"; mockInputs["working-directory"] = "/workspace";
mockInputs["venv-path"] = "custom-venv"; mockInputs["venv-path"] = "custom-venv";
const { activateEnvironment, venvPath } = await import( const { activateEnvironment, venvPath } = await importInputsModule();
"../../src/utils/inputs"
);
expect(activateEnvironment).toBe(false); expect(activateEnvironment).toBe(false);
expect(venvPath).toBe("/workspace/custom-venv"); expect(venvPath).toBe("/workspace/custom-venv");
expect(mockWarning).toHaveBeenCalledWith(
const mockedCore = jest.requireMock("@actions/core") as {
warning: jest.Mock;
};
expect(mockedCore.warning).toHaveBeenCalledWith(
"venv-path is only used when activate-environment is true", "venv-path is only used when activate-environment is true",
); );
}); });

View File

@@ -1,113 +1,121 @@
jest.mock("node:fs"); import { beforeEach, describe, expect, it, jest } from "@jest/globals";
jest.mock("@actions/core", () => ({
warning: jest.fn(), const mockReadFileSync = jest.fn();
const mockWarning = jest.fn();
jest.unstable_mockModule("node:fs", () => ({
default: {
readFileSync: mockReadFileSync,
},
})); }));
import fs from "node:fs"; jest.unstable_mockModule("@actions/core", () => ({
import * as core from "@actions/core"; warning: mockWarning,
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>; async function getVersionFromToolVersions(filePath: string) {
const mockedCore = core as jest.Mocked<typeof core>; const { getUvVersionFromToolVersions } = await import(
"../../src/version/tool-versions-file"
);
return getUvVersionFromToolVersions(filePath);
}
describe("getUvVersionFromToolVersions", () => { describe("getUvVersionFromToolVersions", () => {
beforeEach(() => { beforeEach(() => {
jest.resetModules();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
it("should return undefined for non-.tool-versions files", () => { it("should return undefined for non-.tool-versions files", async () => {
const result = getUvVersionFromToolVersions("package.json"); const result = await getVersionFromToolVersions("package.json");
expect(result).toBeUndefined(); expect(result).toBeUndefined();
expect(mockedFs.readFileSync).not.toHaveBeenCalled(); expect(mockReadFileSync).not.toHaveBeenCalled();
}); });
it("should return version for valid uv entry", () => { it("should return version for valid uv entry", async () => {
const fileContent = "python 3.11.0\nuv 0.1.0\nnodejs 18.0.0"; const fileContent = "python 3.11.0\nuv 0.1.0\nnodejs 18.0.0";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.1.0"); expect(result).toBe("0.1.0");
expect(mockedFs.readFileSync).toHaveBeenCalledWith( expect(mockReadFileSync).toHaveBeenCalledWith(".tool-versions", "utf8");
".tool-versions",
"utf8",
);
}); });
it("should return version for uv entry with v prefix", () => { it("should return version for uv entry with v prefix", async () => {
const fileContent = "uv v0.2.0"; const fileContent = "uv v0.2.0";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.2.0"); expect(result).toBe("0.2.0");
}); });
it("should handle whitespace around uv entry", () => { it("should handle whitespace around uv entry", async () => {
const fileContent = " uv 0.3.0 "; const fileContent = " uv 0.3.0 ";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.3.0"); expect(result).toBe("0.3.0");
}); });
it("should skip commented lines", () => { it("should skip commented lines", async () => {
const fileContent = "# uv 0.1.0\npython 3.11.0\nuv 0.2.0"; const fileContent = "# uv 0.1.0\npython 3.11.0\nuv 0.2.0";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.2.0"); expect(result).toBe("0.2.0");
}); });
it("should return first matching uv version", () => { it("should return first matching uv version", async () => {
const fileContent = "uv 0.1.0\npython 3.11.0\nuv 0.2.0"; const fileContent = "uv 0.1.0\npython 3.11.0\nuv 0.2.0";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBe("0.1.0"); expect(result).toBe("0.1.0");
}); });
it("should return undefined when no uv entry found", () => { it("should return undefined when no uv entry found", async () => {
const fileContent = "python 3.11.0\nnodejs 18.0.0"; const fileContent = "python 3.11.0\nnodejs 18.0.0";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBeUndefined(); expect(result).toBeUndefined();
}); });
it("should return undefined for empty file", () => { it("should return undefined for empty file", async () => {
mockedFs.readFileSync.mockReturnValue(""); mockReadFileSync.mockReturnValue("");
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBeUndefined(); expect(result).toBeUndefined();
}); });
it("should warn and return undefined for ref syntax", () => { it("should warn and return undefined for ref syntax", async () => {
const fileContent = "uv ref:main"; const fileContent = "uv ref:main";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions(".tool-versions"); const result = await getVersionFromToolVersions(".tool-versions");
expect(result).toBeUndefined(); expect(result).toBeUndefined();
expect(mockedCore.warning).toHaveBeenCalledWith( expect(mockWarning).toHaveBeenCalledWith(
"The ref syntax of .tool-versions is not supported. Please use a released version instead.", "The ref syntax of .tool-versions is not supported. Please use a released version instead.",
); );
}); });
it("should handle file path with .tool-versions extension", () => { it("should handle file path with .tool-versions extension", async () => {
const fileContent = "uv 0.1.0"; const fileContent = "uv 0.1.0";
mockedFs.readFileSync.mockReturnValue(fileContent); mockReadFileSync.mockReturnValue(fileContent);
const result = getUvVersionFromToolVersions("path/to/.tool-versions"); const result = await getVersionFromToolVersions("path/to/.tool-versions");
expect(result).toBe("0.1.0"); expect(result).toBe("0.1.0");
expect(mockedFs.readFileSync).toHaveBeenCalledWith( expect(mockReadFileSync).toHaveBeenCalledWith(
"path/to/.tool-versions", "path/to/.tool-versions",
"utf8", "utf8",
); );

View File

@@ -102,8 +102,8 @@ outputs:
description: "A boolean value to indicate the Python cache entry was found" description: "A boolean value to indicate the Python cache entry was found"
runs: runs:
using: "node24" using: "node24"
main: "dist/setup/index.js" main: "dist/setup/index.cjs"
post: "dist/save-cache/index.js" post: "dist/save-cache/index.cjs"
post-if: success() post-if: success()
branding: branding:
icon: "package" icon: "package"

View File

@@ -1,5 +1,5 @@
{ {
"$schema": "https://biomejs.dev/schemas/2.3.7/schema.json", "$schema": "https://biomejs.dev/schemas/2.4.7/schema.json",
"assist": { "assist": {
"actions": { "actions": {
"source": { "source": {

63325
dist/save-cache/index.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

94304
dist/save-cache/index.js generated vendored

File diff suppressed because one or more lines are too long

97175
dist/setup/index.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

100695
dist/setup/index.js generated vendored

File diff suppressed because one or more lines are too long

49537
dist/update-known-checksums/index.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

33985
dist/update-known-checksums/index.js generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ["js", "ts"],
testMatch: ["**/*.test.ts"],
transform: {
"^.+\\.ts$": "ts-jest",
},
verbose: true,
};

14
jest.config.mjs Normal file
View File

@@ -0,0 +1,14 @@
import { createDefaultEsmPreset } from "ts-jest";
const esmPreset = createDefaultEsmPreset({
tsconfig: "./tsconfig.json",
});
export default {
...esmPreset,
clearMocks: true,
moduleFileExtensions: ["js", "mjs", "ts"],
testEnvironment: "node",
testMatch: ["**/*.test.ts"],
verbose: true,
};

4156
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,16 +2,18 @@
"name": "setup-uv", "name": "setup-uv",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"type": "module",
"description": "Set up your GitHub Actions workflow with a specific version of uv", "description": "Set up your GitHub Actions workflow with a specific version of uv",
"main": "dist/index.js", "main": "dist/setup/index.cjs",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc --noEmit",
"check": "biome check --write", "check": "biome check --write",
"package": "ncc build -o dist/setup src/setup-uv.ts && ncc build -o dist/save-cache src/save-cache.ts && ncc build -o dist/update-known-checksums src/update-known-checksums.ts", "package": "node scripts/build-dist.mjs",
"test": "jest", "test:unit": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
"test": "npm run build && npm run test:unit",
"act": "act pull_request -W .github/workflows/test.yml --container-architecture linux/amd64 -s GITHUB_TOKEN=\"$(gh auth token)\"", "act": "act pull_request -W .github/workflows/test.yml --container-architecture linux/amd64 -s GITHUB_TOKEN=\"$(gh auth token)\"",
"update-known-checksums": "RUNNER_TEMP=known_versions node dist/update-known-checksums/index.js src/download/checksum/known-checksums.ts", "update-known-checksums": "RUNNER_TEMP=known_versions node dist/update-known-checksums/index.cjs src/download/checksum/known-checksums.ts",
"all": "npm run build && npm run check && npm run package && npm test" "all": "npm run build && npm run check && npm run package && npm run test:unit"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -26,25 +28,26 @@
"author": "@eifinger", "author": "@eifinger",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^4.1.0", "@actions/cache": "^6.0.0",
"@actions/core": "^1.11.1", "@actions/core": "^3.0.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^3.0.0",
"@actions/glob": "^0.5.0", "@actions/glob": "^0.6.1",
"@actions/io": "^1.1.3", "@actions/io": "^3.0.2",
"@actions/tool-cache": "^2.0.2", "@actions/tool-cache": "^4.0.0",
"@renovatebot/pep440": "^4.2.1", "@renovatebot/pep440": "^4.2.2",
"smol-toml": "^1.6.0", "smol-toml": "^1.6.0",
"undici": "5.28.5" "undici": "^7.24.2"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "2.3.8", "@biomejs/biome": "^2.4.7",
"@types/js-yaml": "^4.0.9", "@types/js-yaml": "^4.0.9",
"@types/node": "^24.10.1", "@types/node": "^25.5.0",
"@types/semver": "^7.7.1", "@types/semver": "^7.7.1",
"@vercel/ncc": "^0.38.4", "@vercel/ncc": "^0.38.4",
"jest": "^30.2.0", "esbuild": "^0.27.4",
"js-yaml": "^4.1.0", "jest": "^30.3.0",
"ts-jest": "^29.4.5", "js-yaml": "^4.1.1",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3" "typescript": "^5.9.3"
} }
} }

33
scripts/build-dist.mjs Normal file
View File

@@ -0,0 +1,33 @@
import { rm } from "node:fs/promises";
import { build } from "esbuild";
const builds = [
{
entryPoints: ["src/setup-uv.ts"],
outfile: "dist/setup/index.cjs",
staleOutfiles: ["dist/setup/index.mjs"],
},
{
entryPoints: ["src/save-cache.ts"],
outfile: "dist/save-cache/index.cjs",
staleOutfiles: ["dist/save-cache/index.mjs"],
},
{
entryPoints: ["src/update-known-checksums.ts"],
outfile: "dist/update-known-checksums/index.cjs",
staleOutfiles: ["dist/update-known-checksums/index.mjs"],
},
];
for (const { staleOutfiles, ...options } of builds) {
await Promise.all(
staleOutfiles.map((outfile) => rm(outfile, { force: true })),
);
await build({
bundle: true,
format: "cjs",
platform: "node",
target: "node24",
...options,
});
}

View File

@@ -1,5 +1,39 @@
// AUTOGENERATED_DO_NOT_EDIT // AUTOGENERATED_DO_NOT_EDIT
export const KNOWN_CHECKSUMS: { [key: string]: string } = { export const KNOWN_CHECKSUMS: { [key: string]: string } = {
"aarch64-apple-darwin-0.10.10":
"8a09f0ef51ee7f7170731b4cb8bde5bf9ba6da5304f49a7df6cdab42a1f37b5d",
"aarch64-pc-windows-msvc-0.10.10":
"2c6fe113f14574bc27f085751c68d3485589fcc3c3c64ed85dd1eecc2f87cffc",
"aarch64-unknown-linux-gnu-0.10.10":
"2b80457b950deda12e8d5dc3b9b7494ac143eae47f1fb11b1c6e5a8495a6421e",
"aarch64-unknown-linux-musl-0.10.10":
"d08c08b82cdcaf2bd3d928ffe844d3558dda53f90066db6ef9174157cc763252",
"arm-unknown-linux-musleabihf-0.10.10":
"ccc3c4dd5eeea4b2be829ef9bc0b8d9882389c0f303f7ec5ba668065d57e2673",
"armv7-unknown-linux-gnueabihf-0.10.10":
"032786622b52f8d0232b5ad16e25342a64f9e43576652db7bf607231021902f3",
"armv7-unknown-linux-musleabihf-0.10.10":
"f6f67b190eb28b473917c97210f89fd11d9b9393d774acd093ea738fcee68864",
"i686-pc-windows-msvc-0.10.10":
"980d7ea368cc4883f572bb85c285a647eddfc23539064d2bfaf8fbfefcc2112b",
"i686-unknown-linux-gnu-0.10.10":
"5260fbef838f8cfec44697064a5cfae08a27c6ab7ed7feab7fc946827e896952",
"i686-unknown-linux-musl-0.10.10":
"a6683ade964f8d8623098ca0c96b4311d8388b44a56a386cd795974f39fb5bd2",
"powerpc64le-unknown-linux-gnu-0.10.10":
"78939dc4fc905aca8af4be19b6c6ecc306f04c6ca9f98d144372595d9397fd0d",
"riscv64gc-unknown-linux-gnu-0.10.10":
"5eff670bf80fce9d9e50df5b4d46c415a9c0324eadf7059d97c76f89ffc33c3f",
"s390x-unknown-linux-gnu-0.10.10":
"a32d2be5600f7f42f82596ffe9d3115f020974ca7fb4f15251c5625c5481ea5e",
"x86_64-apple-darwin-0.10.10":
"dd18420591d625f9b4ca2b57a7a6fe3cce43910f02e02d90e47a4101428de14a",
"x86_64-pc-windows-msvc-0.10.10":
"d31a30f1dfb96e630a08d5a9b3f3f551254b7ed6e9b7e495f46a4232661c7252",
"x86_64-unknown-linux-gnu-0.10.10":
"3e1027f26ce8c7e4c32e2277a7fed2cb410f2f1f9320d3df97653d40e21f415b",
"x86_64-unknown-linux-musl-0.10.10":
"74544e8755fbc27559e22e29fd561bdc48f91b8bd8323e760a1130f32433bea4",
"aarch64-apple-darwin-0.10.9": "aarch64-apple-darwin-0.10.9":
"a92f61e9ac9b0f29668c15f56152e4a60143fca148ff5bfadb86718472c3f376", "a92f61e9ac9b0f29668c15f56152e4a60143fca148ff5bfadb86718472c3f376",
"aarch64-pc-windows-msvc-0.10.9": "aarch64-pc-windows-msvc-0.10.9":

View File

@@ -38,6 +38,8 @@ import {
} from "./utils/platforms"; } from "./utils/platforms";
import { getUvVersionFromFile } from "./version/resolve"; import { getUvVersionFromFile } from "./version/resolve";
const sourceDir = __dirname;
async function getPythonVersion(): Promise<string> { async function getPythonVersion(): Promise<string> {
if (pythonVersion !== "") { if (pythonVersion !== "") {
return pythonVersion; return pythonVersion;
@@ -308,7 +310,7 @@ function setCacheDir(): void {
function addMatchers(): void { function addMatchers(): void {
if (addProblemMatchers) { if (addProblemMatchers) {
const matchersPath = path.join(__dirname, `..${path.sep}..`, ".github"); const matchersPath = path.join(sourceDir, "..", "..", ".github");
core.info(`##[add-matcher]${path.join(matchersPath, "python.json")}`); core.info(`##[add-matcher]${path.join(matchersPath, "python.json")}`);
} }
} }

View File

@@ -18,7 +18,7 @@ async function run(): Promise<void> {
const checksumFilePath = process.argv.slice(2)[0]; const checksumFilePath = process.argv.slice(2)[0];
if (!checksumFilePath) { if (!checksumFilePath) {
throw new Error( throw new Error(
"Missing checksum file path. Usage: node dist/update-known-checksums/index.js <checksum-file-path>", "Missing checksum file path. Usage: node dist/update-known-checksums/index.cjs <checksum-file-path>",
); );
} }

View File

@@ -1,12 +1,12 @@
{ {
"compilerOptions": { "compilerOptions": {
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, "esModuleInterop": true,
"module": "nodenext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, "isolatedModules": true,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, "module": "esnext",
"outDir": "./lib" /* Redirect output structure to the directory. */, "moduleResolution": "bundler",
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, "noImplicitAny": true,
"strict": true /* Enable all strict type-checking options. */, "strict": true,
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2022"
}, },
"exclude": ["node_modules", "**/*.test.ts"] "include": ["src/**/*.ts"]
} }