mirror of
https://github.com/oven-sh/setup-bun.git
synced 2026-05-20 23:30:14 +02:00
fix: use native Windows ARM64 binary for Bun >= 1.3.10 (#165)
Bun v1.3.10 ships native Windows ARM64 binaries. Update getArchitecture() and getAvx2() to be version-aware so that windows-11-arm runners download bun-windows-aarch64.zip instead of falling back to bun-windows-x64-baseline.zip. The x64 fallback is preserved for older versions that lack ARM64 assets. Closes #164 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+85
-32
@@ -1,7 +1,32 @@
|
||||
import { afterEach, describe, expect, it, spyOn } from "bun:test";
|
||||
import { getArchitecture, getAvx2 } from "../src/utils";
|
||||
import { getArchitecture, getAvx2, hasNativeWindowsArm64 } from "../src/utils";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
describe("hasNativeWindowsArm64", () => {
|
||||
it("should return true for version >= 1.3.10", () => {
|
||||
expect(hasNativeWindowsArm64("bun-v1.3.10")).toBe(true);
|
||||
expect(hasNativeWindowsArm64("bun-v1.3.11")).toBe(true);
|
||||
expect(hasNativeWindowsArm64("bun-v1.4.0")).toBe(true);
|
||||
expect(hasNativeWindowsArm64("bun-v2.0.0")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for version < 1.3.10", () => {
|
||||
expect(hasNativeWindowsArm64("bun-v1.3.9")).toBe(false);
|
||||
expect(hasNativeWindowsArm64("bun-v1.2.0")).toBe(false);
|
||||
expect(hasNativeWindowsArm64("bun-v1.0.0")).toBe(false);
|
||||
expect(hasNativeWindowsArm64("bun-v0.5.0")).toBe(false);
|
||||
});
|
||||
|
||||
it("should return true for non-semver versions like canary", () => {
|
||||
expect(hasNativeWindowsArm64("canary")).toBe(true);
|
||||
expect(hasNativeWindowsArm64("latest")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for undefined version", () => {
|
||||
expect(hasNativeWindowsArm64(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getArchitecture", () => {
|
||||
let warningSpy: ReturnType<typeof spyOn>;
|
||||
|
||||
@@ -9,30 +34,54 @@ describe("getArchitecture", () => {
|
||||
warningSpy?.mockRestore();
|
||||
});
|
||||
|
||||
it("should return x64 for Windows with arm64 architecture", () => {
|
||||
it("should return aarch64 for Windows arm64 with Bun >= 1.3.10", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "arm64", "bun-v1.3.10");
|
||||
|
||||
expect(result).toBe("aarch64");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should return aarch64 for Windows aarch64 with Bun >= 1.3.10", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "aarch64", "bun-v1.4.0");
|
||||
|
||||
expect(result).toBe("aarch64");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should return x64 for Windows arm64 with Bun < 1.3.10", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "arm64", "bun-v1.2.0");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"⚠️ This version of Bun does not provide native arm64 builds for Windows."
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should return x64 for Windows aarch64 with Bun < 1.3.10", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "aarch64", "bun-v1.0.0");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"⚠️ This version of Bun does not provide native arm64 builds for Windows."
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should return x64 for Windows arm64 with no version (fallback)", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "arm64");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"⚠️ Bun does not provide native arm64 builds for Windows."
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should return x64 for Windows with aarch64 architecture", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "aarch64");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"⚠️ Bun does not provide native arm64 builds for Windows."
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should return aarch64 for non-Windows platforms with arm64", () => {
|
||||
@@ -77,24 +126,28 @@ describe("getArchitecture", () => {
|
||||
});
|
||||
|
||||
describe("getAvx2", () => {
|
||||
it("should return false when called with os: 'windows' and arch: 'arm64'", () => {
|
||||
const result = getAvx2("windows", "arm64");
|
||||
expect(result).toBe(false);
|
||||
it("should return false for Windows arm64 with Bun < 1.3.10", () => {
|
||||
expect(getAvx2("windows", "arm64", undefined, "bun-v1.2.0")).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when called with os: 'windows' and arch: 'aarch64'", () => {
|
||||
const result = getAvx2("windows", "aarch64");
|
||||
expect(result).toBe(false);
|
||||
it("should return false for Windows aarch64 with Bun < 1.3.10", () => {
|
||||
expect(getAvx2("windows", "aarch64", undefined, "bun-v1.0.0")).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when called with os: 'windows', arch: 'arm64', and avx2: true", () => {
|
||||
const result = getAvx2("windows", "arm64", true);
|
||||
expect(result).toBe(false);
|
||||
it("should return false for Windows arm64 with no version (fallback)", () => {
|
||||
expect(getAvx2("windows", "arm64")).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when called with os: 'windows', arch: 'aarch64', and avx2: false", () => {
|
||||
const result = getAvx2("windows", "aarch64", false);
|
||||
expect(result).toBe(false);
|
||||
it("should return false for Windows aarch64 with no version (fallback)", () => {
|
||||
expect(getAvx2("windows", "aarch64")).toBe(false);
|
||||
});
|
||||
|
||||
it("should return true for Windows arm64 with Bun >= 1.3.10", () => {
|
||||
expect(getAvx2("windows", "arm64", undefined, "bun-v1.3.10")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for Windows aarch64 with Bun >= 1.3.10", () => {
|
||||
expect(getAvx2("windows", "aarch64", undefined, "bun-v1.4.0")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return the provided avx2 value (true) when specified and not on Windows ARM64", () => {
|
||||
|
||||
Reference in New Issue
Block a user