mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-11-27 01:06:15 +00:00
Add the require-checksums input (#1139)
Adds `require-checksums`, which enforces the "intrinsic or explicitly provided checksum" idea. See #1032. <details> <summary>Automated notes</summary> Add the opt-in input `require-checksums`. When enabled, setup-uv verifies the archive against the workflow's `checksum` input or the digest bundled for the resolved uv version, architecture, and platform. If neither is available, setup fails before downloading the archive. By default, setup-uv continues to accept manifest checksums as it does today. The setting also applies to custom manifests, which can still supply download URLs. On persistent runners, strict mode keys tool-cache entries by the expected archive digest so a previous manifest-verified installation cannot bypass the check. Closes #1032. Builds on #1033. ## Validation - `npm ci --ignore-scripts` and `npm run all` passed under Node 24 (182 tests). - The packaged-action regression test installs a custom build into a temporary runner tool cache. It checks that strict mode rejects a manifest-only version even with a warm cache, reuses a verified installation for the same digest, and rejects a changed digest or a custom build that conflicts with the bundled digest. </details> --------- Signed-off-by: William Woodruff <william@yossarian.net>
This commit is contained in:
1 parent
fc0acc2d6f
commit
de938e707d
16 files changed
+235
-43
No files matched your search
+23
-3
@@ -5,9 +5,14 @@ import * as exec from "@actions/exec";
|
||||
import { restoreCache } from "./cache/restore-cache";
|
||||
import {
|
||||
downloadVersion,
|
||||
getIntrinsicChecksum,
|
||||
tryGetFromToolCache,
|
||||
} from "./download/download-version";
|
||||
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
|
||||
import {
|
||||
STATE_UV_PATH,
|
||||
STATE_UV_VERSION,
|
||||
TOOL_CACHE_NAME,
|
||||
} from "./utils/constants";
|
||||
import { CacheLocalSource, loadInputs, type SetupInputs } from "./utils/inputs";
|
||||
import * as log from "./utils/logging";
|
||||
import {
|
||||
@@ -147,7 +152,21 @@ async function setupUv(
|
||||
versionFile: inputs.versionFile,
|
||||
workingDirectory: inputs.workingDirectory,
|
||||
});
|
||||
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
|
||||
let checksum = inputs.checksum;
|
||||
let toolCacheName = TOOL_CACHE_NAME;
|
||||
if (inputs.requireChecksums) {
|
||||
checksum = getIntrinsicChecksum(
|
||||
`${arch}-${platform}-${resolvedVersion}`,
|
||||
inputs.checksum,
|
||||
);
|
||||
// A regular tool-cache entry may have been verified using a manifest checksum.
|
||||
toolCacheName = `${TOOL_CACHE_NAME}-${checksum}`;
|
||||
}
|
||||
const toolCacheResult = tryGetFromToolCache(
|
||||
arch,
|
||||
resolvedVersion,
|
||||
toolCacheName,
|
||||
);
|
||||
if (toolCacheResult.installedPath) {
|
||||
log.info(`Found uv in tool-cache for ${toolCacheResult.version}`);
|
||||
return {
|
||||
@@ -160,10 +179,11 @@ async function setupUv(
|
||||
platform,
|
||||
arch,
|
||||
resolvedVersion,
|
||||
inputs.checksum,
|
||||
checksum,
|
||||
inputs.githubToken,
|
||||
inputs.manifestFile,
|
||||
inputs.downloadFromAstralMirror,
|
||||
toolCacheName,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user