chore: make MIN_WINDOWS_ARM64_VERSION constant
This commit is contained in:
parent
24feafd6b4
commit
0e6cdcbc35
62
dist/setup/index.js
generated
vendored
62
dist/setup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
@ -69,12 +69,13 @@ async function getSemverDownloadUrl(options: Input): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const eversion = encodeURIComponent(tag ?? version);
|
const eversion = encodeURIComponent(tag ?? version);
|
||||||
const eos = encodeURIComponent(os ?? getPlatform());
|
const osValue = os ?? getPlatform();
|
||||||
|
const eos = encodeURIComponent(osValue);
|
||||||
|
|
||||||
let archValue = arch ?? process.arch;
|
let archValue = arch ?? process.arch;
|
||||||
let avx2Value = avx2;
|
let avx2Value = avx2;
|
||||||
|
|
||||||
if (eos === "windows" && getArchitecture(archValue) === "aarch64") {
|
if (osValue === "windows" && getArchitecture(archValue) === "aarch64") {
|
||||||
if (!isWindowsArm64Supported(tag ?? version)) {
|
if (!isWindowsArm64Supported(tag ?? version)) {
|
||||||
warnWindowsArm64();
|
warnWindowsArm64();
|
||||||
archValue = "x64";
|
archValue = "x64";
|
||||||
|
|||||||
14
src/utils.ts
14
src/utils.ts
@ -5,6 +5,9 @@ import { createHash } from "node:crypto";
|
|||||||
import { existsSync, readFileSync, renameSync } from "node:fs";
|
import { existsSync, readFileSync, renameSync } from "node:fs";
|
||||||
import { resolve, basename } from "node:path";
|
import { resolve, basename } from "node:path";
|
||||||
|
|
||||||
|
export const MIN_WINDOWS_ARM64_VERSION = "1.3.10";
|
||||||
|
|
||||||
|
|
||||||
export function getCacheKey(url: string): string {
|
export function getCacheKey(url: string): string {
|
||||||
return `bun-${createHash("sha1").update(url).digest("base64")}`;
|
return `bun-${createHash("sha1").update(url).digest("base64")}`;
|
||||||
}
|
}
|
||||||
@ -67,15 +70,18 @@ export function isWindowsArm64Supported(tag: string): boolean {
|
|||||||
|
|
||||||
const version = tag.startsWith("bun-v") ? tag.slice(5) : tag;
|
const version = tag.startsWith("bun-v") ? tag.slice(5) : tag;
|
||||||
|
|
||||||
return validate(version) && compareVersions(version, "1.3.10") >= 0;
|
return (
|
||||||
|
validate(version) &&
|
||||||
|
compareVersions(version, MIN_WINDOWS_ARM64_VERSION) >= 0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function warnWindowsArm64(): void {
|
export function warnWindowsArm64(): void {
|
||||||
warning(
|
warning(
|
||||||
[
|
[
|
||||||
"⚠️ Bun does not provide native arm64 builds for Windows.",
|
"⚠️ On this OS/version, Bun does not provide native arm64 builds for Windows.",
|
||||||
"Using x64 baseline build which will run through Microsoft's x64 emulation layer.",
|
"Using x64 baseline build on this runner/version which will run through Microsoft's x64 emulation layer.",
|
||||||
"This may result in reduced performance and potential compatibility issues.",
|
"This may result in reduced performance and potential compatibility issues on affected versions.",
|
||||||
"💡 For best performance, consider using x64 Windows runners or other platforms with native support.",
|
"💡 For best performance, consider using x64 Windows runners or other platforms with native support.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -161,7 +161,7 @@ describe("getDownloadUrl", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Windows ARM64 Fallback", () => {
|
describe("Windows ARM64 Fallback", () => {
|
||||||
it("should fallback to x64-baseline for versions older than 1.3.10 and log a warning", async () => {
|
it("should fallback to x64-baseline for versions older than MIN_WINDOWS_ARM64_VERSION and log a warning", async () => {
|
||||||
const warningSpy = spyOn(core, "warning");
|
const warningSpy = spyOn(core, "warning");
|
||||||
const url = await getDownloadUrl({
|
const url = await getDownloadUrl({
|
||||||
version: "1.1.0",
|
version: "1.1.0",
|
||||||
@ -174,20 +174,20 @@ describe("getDownloadUrl", () => {
|
|||||||
);
|
);
|
||||||
expect(warningSpy).toHaveBeenCalled();
|
expect(warningSpy).toHaveBeenCalled();
|
||||||
expect(warningSpy.mock.calls[0][0]).toContain(
|
expect(warningSpy.mock.calls[0][0]).toContain(
|
||||||
"Bun does not provide native arm64 builds for Windows",
|
"On this OS/version, Bun does not provide native arm64 builds for Windows",
|
||||||
);
|
);
|
||||||
warningSpy.mockRestore();
|
warningSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use aarch64 for version 1.3.10", async () => {
|
it(`should use aarch64 for version ${utils.MIN_WINDOWS_ARM64_VERSION}`, async () => {
|
||||||
const url = await getDownloadUrl({
|
const url = await getDownloadUrl({
|
||||||
version: "1.3.10",
|
version: utils.MIN_WINDOWS_ARM64_VERSION,
|
||||||
os: "windows",
|
os: "windows",
|
||||||
arch: "arm64",
|
arch: "arm64",
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(url).toBe(
|
expect(url).toBe(
|
||||||
"https://github.com/oven-sh/bun/releases/download/bun-v1.3.10/bun-windows-aarch64.zip",
|
`https://github.com/oven-sh/bun/releases/download/bun-v${utils.MIN_WINDOWS_ARM64_VERSION}/bun-windows-aarch64.zip`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,30 @@
|
|||||||
import { afterEach, describe, expect, it, spyOn } from "bun:test";
|
import { afterEach, describe, expect, it, spyOn } from "bun:test";
|
||||||
import { getArchitecture, getAvx2 } from "../src/utils";
|
import {
|
||||||
import * as core from "@actions/core";
|
getArchitecture,
|
||||||
|
getAvx2,
|
||||||
|
isWindowsArm64Supported,
|
||||||
|
MIN_WINDOWS_ARM64_VERSION,
|
||||||
|
} from "../src/utils";
|
||||||
|
|
||||||
|
describe("isWindowsArm64Supported", () => {
|
||||||
|
it("should return true for 'canary' and 'latest'", () => {
|
||||||
|
expect(isWindowsArm64Supported("canary")).toBe(true);
|
||||||
|
expect(isWindowsArm64Supported("latest")).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return true for versions >= MIN_WINDOWS_ARM64_VERSION", () => {
|
||||||
|
expect(isWindowsArm64Supported(MIN_WINDOWS_ARM64_VERSION)).toBe(true);
|
||||||
|
expect(isWindowsArm64Supported("bun-v" + MIN_WINDOWS_ARM64_VERSION)).toBe(
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
expect(isWindowsArm64Supported("1.4.0")).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for versions < MIN_WINDOWS_ARM64_VERSION", () => {
|
||||||
|
expect(isWindowsArm64Supported("1.0.0")).toBe(false);
|
||||||
|
expect(isWindowsArm64Supported("bun-v1.3.9")).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("getArchitecture", () => {
|
describe("getArchitecture", () => {
|
||||||
let warningSpy: ReturnType<typeof spyOn>;
|
let warningSpy: ReturnType<typeof spyOn>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user