mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-07-03 19:09:30 +00:00
feat: add download-from-astral-mirror input
Add a new boolean input (default: true) that controls whether uv is downloaded from the Astral mirror or directly from GitHub Releases. When set to false, the mirror rewrite is skipped entirely.
This commit is contained in:
parent
ddb93f091f
commit
4fa8fca033
10 changed files with 66 additions and 4 deletions
15
.github/workflows/test.yml
vendored
15
.github/workflows/test.yml
vendored
|
|
@ -861,6 +861,20 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test-download-from-astral-mirror-false:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install with download-from-astral-mirror disabled
|
||||||
|
id: setup-uv
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
download-from-astral-mirror: false
|
||||||
|
- name: Verify uv is installed
|
||||||
|
run: uv --version
|
||||||
|
|
||||||
test-absolute-path:
|
test-absolute-path:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -1119,6 +1133,7 @@ jobs:
|
||||||
- test-restore-cache-restore-cache-false
|
- test-restore-cache-restore-cache-false
|
||||||
- test-no-python-version
|
- test-no-python-version
|
||||||
- test-custom-manifest-file
|
- test-custom-manifest-file
|
||||||
|
- test-download-from-astral-mirror-false
|
||||||
- test-absolute-path
|
- test-absolute-path
|
||||||
- test-relative-path
|
- test-relative-path
|
||||||
- test-cache-prune-force
|
- test-cache-prune-force
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,9 @@ Have a look under [Advanced Configuration](#advanced-configuration) for detailed
|
||||||
# URL to a custom manifest file in the astral-sh/versions format
|
# URL to a custom manifest file in the astral-sh/versions format
|
||||||
manifest-file: ""
|
manifest-file: ""
|
||||||
|
|
||||||
|
# Download uv from the Astral mirror instead of directly from GitHub Releases
|
||||||
|
download-from-astral-mirror: "true"
|
||||||
|
|
||||||
# Add problem matchers
|
# Add problem matchers
|
||||||
add-problem-matchers: "true"
|
add-problem-matchers: "true"
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,32 @@ describe("download-version", () => {
|
||||||
"0.9.26",
|
"0.9.26",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skips the Astral mirror when downloadFromAstralMirror is false", async () => {
|
||||||
|
mockGetArtifact.mockResolvedValue({
|
||||||
|
archiveFormat: "tar.gz",
|
||||||
|
checksum: "abc123",
|
||||||
|
downloadUrl:
|
||||||
|
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz",
|
||||||
|
});
|
||||||
|
|
||||||
|
await downloadVersion(
|
||||||
|
"unknown-linux-gnu",
|
||||||
|
"x86_64",
|
||||||
|
"0.9.26",
|
||||||
|
undefined,
|
||||||
|
"token",
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(mockDownloadTool).toHaveBeenCalledWith(
|
||||||
|
"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-unknown-linux-gnu.tar.gz",
|
||||||
|
undefined,
|
||||||
|
"token",
|
||||||
|
);
|
||||||
|
expect(mockDownloadTool).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("rewriteToMirror", () => {
|
describe("rewriteToMirror", () => {
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ inputs:
|
||||||
type: string
|
type: string
|
||||||
manifest-file:
|
manifest-file:
|
||||||
type: string
|
type: string
|
||||||
|
download-from-astral-mirror:
|
||||||
|
type: boolean
|
||||||
add-problem-matchers:
|
add-problem-matchers:
|
||||||
type: boolean
|
type: boolean
|
||||||
resolution-strategy:
|
resolution-strategy:
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,9 @@ inputs:
|
||||||
manifest-file:
|
manifest-file:
|
||||||
description: "URL to a custom manifest file in the astral-sh/versions format."
|
description: "URL to a custom manifest file in the astral-sh/versions format."
|
||||||
required: false
|
required: false
|
||||||
|
download-from-astral-mirror:
|
||||||
|
description: "Download uv from the Astral mirror instead of directly from GitHub Releases."
|
||||||
|
default: "true"
|
||||||
add-problem-matchers:
|
add-problem-matchers:
|
||||||
description: "Add problem matchers."
|
description: "Add problem matchers."
|
||||||
default: "true"
|
default: "true"
|
||||||
|
|
|
||||||
2
dist/save-cache/index.cjs
generated
vendored
2
dist/save-cache/index.cjs
generated
vendored
|
|
@ -62990,6 +62990,7 @@ function loadInputs() {
|
||||||
const pythonDir = getUvPythonDir();
|
const pythonDir = getUvPythonDir();
|
||||||
const githubToken = getInput("github-token");
|
const githubToken = getInput("github-token");
|
||||||
const manifestFile = getManifestFile();
|
const manifestFile = getManifestFile();
|
||||||
|
const downloadFromAstralMirror = getInput("download-from-astral-mirror") === "true";
|
||||||
const addProblemMatchers = getInput("add-problem-matchers") === "true";
|
const addProblemMatchers = getInput("add-problem-matchers") === "true";
|
||||||
const resolutionStrategy = getResolutionStrategy();
|
const resolutionStrategy = getResolutionStrategy();
|
||||||
return {
|
return {
|
||||||
|
|
@ -63000,6 +63001,7 @@ function loadInputs() {
|
||||||
cachePython,
|
cachePython,
|
||||||
cacheSuffix,
|
cacheSuffix,
|
||||||
checksum,
|
checksum,
|
||||||
|
downloadFromAstralMirror,
|
||||||
enableCache,
|
enableCache,
|
||||||
githubToken,
|
githubToken,
|
||||||
ignoreEmptyWorkdir,
|
ignoreEmptyWorkdir,
|
||||||
|
|
|
||||||
9
dist/setup/index.cjs
generated
vendored
9
dist/setup/index.cjs
generated
vendored
|
|
@ -97057,7 +97057,7 @@ function tryGetFromToolCache(arch3, version3) {
|
||||||
const installedPath = find(TOOL_CACHE_NAME, resolvedVersion, arch3);
|
const installedPath = find(TOOL_CACHE_NAME, resolvedVersion, arch3);
|
||||||
return { installedPath, version: resolvedVersion };
|
return { installedPath, version: resolvedVersion };
|
||||||
}
|
}
|
||||||
async function downloadVersion(platform2, arch3, version3, checksum, githubToken, manifestUrl) {
|
async function downloadVersion(platform2, arch3, version3, checksum, githubToken, manifestUrl, downloadFromAstralMirror = true) {
|
||||||
const artifact = await getArtifact(version3, arch3, platform2, manifestUrl);
|
const artifact = await getArtifact(version3, arch3, platform2, manifestUrl);
|
||||||
if (!artifact) {
|
if (!artifact) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
@ -97065,7 +97065,7 @@ async function downloadVersion(platform2, arch3, version3, checksum, githubToken
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const resolvedChecksum = manifestUrl === void 0 ? checksum : resolveChecksum(checksum, artifact.checksum);
|
const resolvedChecksum = manifestUrl === void 0 ? checksum : resolveChecksum(checksum, artifact.checksum);
|
||||||
const mirrorUrl = rewriteToMirror(artifact.downloadUrl);
|
const mirrorUrl = downloadFromAstralMirror ? rewriteToMirror(artifact.downloadUrl) : void 0;
|
||||||
const downloadUrl = mirrorUrl ?? artifact.downloadUrl;
|
const downloadUrl = mirrorUrl ?? artifact.downloadUrl;
|
||||||
try {
|
try {
|
||||||
return await downloadArtifact(
|
return await downloadArtifact(
|
||||||
|
|
@ -97184,6 +97184,7 @@ function loadInputs() {
|
||||||
const pythonDir = getUvPythonDir();
|
const pythonDir = getUvPythonDir();
|
||||||
const githubToken = getInput("github-token");
|
const githubToken = getInput("github-token");
|
||||||
const manifestFile = getManifestFile();
|
const manifestFile = getManifestFile();
|
||||||
|
const downloadFromAstralMirror = getInput("download-from-astral-mirror") === "true";
|
||||||
const addProblemMatchers = getInput("add-problem-matchers") === "true";
|
const addProblemMatchers = getInput("add-problem-matchers") === "true";
|
||||||
const resolutionStrategy = getResolutionStrategy();
|
const resolutionStrategy = getResolutionStrategy();
|
||||||
return {
|
return {
|
||||||
|
|
@ -97194,6 +97195,7 @@ function loadInputs() {
|
||||||
cachePython,
|
cachePython,
|
||||||
cacheSuffix,
|
cacheSuffix,
|
||||||
checksum,
|
checksum,
|
||||||
|
downloadFromAstralMirror,
|
||||||
enableCache,
|
enableCache,
|
||||||
githubToken,
|
githubToken,
|
||||||
ignoreEmptyWorkdir,
|
ignoreEmptyWorkdir,
|
||||||
|
|
@ -97518,7 +97520,8 @@ async function setupUv(inputs, platform2, arch3) {
|
||||||
resolvedVersion,
|
resolvedVersion,
|
||||||
inputs.checksum,
|
inputs.checksum,
|
||||||
inputs.githubToken,
|
inputs.githubToken,
|
||||||
inputs.manifestFile
|
inputs.manifestFile,
|
||||||
|
inputs.downloadFromAstralMirror
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
uvDir: downloadResult.cachedToolDir,
|
uvDir: downloadResult.cachedToolDir,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ export async function downloadVersion(
|
||||||
checksum: string | undefined,
|
checksum: string | undefined,
|
||||||
githubToken: string,
|
githubToken: string,
|
||||||
manifestUrl?: string,
|
manifestUrl?: string,
|
||||||
|
downloadFromAstralMirror = true,
|
||||||
): Promise<{ version: string; cachedToolDir: string }> {
|
): Promise<{ version: string; cachedToolDir: string }> {
|
||||||
const artifact = await getArtifact(version, arch, platform, manifestUrl);
|
const artifact = await getArtifact(version, arch, platform, manifestUrl);
|
||||||
|
|
||||||
|
|
@ -52,7 +53,9 @@ export async function downloadVersion(
|
||||||
? checksum
|
? checksum
|
||||||
: resolveChecksum(checksum, artifact.checksum);
|
: resolveChecksum(checksum, artifact.checksum);
|
||||||
|
|
||||||
const mirrorUrl = rewriteToMirror(artifact.downloadUrl);
|
const mirrorUrl = downloadFromAstralMirror
|
||||||
|
? rewriteToMirror(artifact.downloadUrl)
|
||||||
|
: undefined;
|
||||||
const downloadUrl = mirrorUrl ?? artifact.downloadUrl;
|
const downloadUrl = mirrorUrl ?? artifact.downloadUrl;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ async function setupUv(
|
||||||
inputs.checksum,
|
inputs.checksum,
|
||||||
inputs.githubToken,
|
inputs.githubToken,
|
||||||
inputs.manifestFile,
|
inputs.manifestFile,
|
||||||
|
inputs.downloadFromAstralMirror,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ export interface SetupInputs {
|
||||||
pythonDir: string;
|
pythonDir: string;
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
manifestFile?: string;
|
manifestFile?: string;
|
||||||
|
downloadFromAstralMirror: boolean;
|
||||||
addProblemMatchers: boolean;
|
addProblemMatchers: boolean;
|
||||||
resolutionStrategy: ResolutionStrategy;
|
resolutionStrategy: ResolutionStrategy;
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +74,8 @@ export function loadInputs(): SetupInputs {
|
||||||
const pythonDir = getUvPythonDir();
|
const pythonDir = getUvPythonDir();
|
||||||
const githubToken = core.getInput("github-token");
|
const githubToken = core.getInput("github-token");
|
||||||
const manifestFile = getManifestFile();
|
const manifestFile = getManifestFile();
|
||||||
|
const downloadFromAstralMirror =
|
||||||
|
core.getInput("download-from-astral-mirror") === "true";
|
||||||
const addProblemMatchers = core.getInput("add-problem-matchers") === "true";
|
const addProblemMatchers = core.getInput("add-problem-matchers") === "true";
|
||||||
const resolutionStrategy = getResolutionStrategy();
|
const resolutionStrategy = getResolutionStrategy();
|
||||||
|
|
||||||
|
|
@ -84,6 +87,7 @@ export function loadInputs(): SetupInputs {
|
||||||
cachePython,
|
cachePython,
|
||||||
cacheSuffix,
|
cacheSuffix,
|
||||||
checksum,
|
checksum,
|
||||||
|
downloadFromAstralMirror,
|
||||||
enableCache,
|
enableCache,
|
||||||
githubToken,
|
githubToken,
|
||||||
ignoreEmptyWorkdir,
|
ignoreEmptyWorkdir,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue