Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
products: Symbolic_Math_Toolbox
check-matlab: matlabVer = ver('matlab'); assert(~isempty(matlabVer));
check-toolbox: symbolicVer = ver('symbolic'); assert(~isempty(symbolicVer));
- os: macos-14
release: R2023a
products: Symbolic_Math_Toolbox
check-matlab: matlabVer = ver('matlab'); assert(strcmp(matlabVer.Release,'(R2023a)'));
check-toolbox: symbolicVer = ver('symbolic'); assert(strcmp(symbolicVer.Release,'(R2023a)'));
steps:
- uses: actions/download-artifact@v4
with:
Expand Down
11 changes: 8 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,28 @@ export async function install(platform: string, architecture: string, release: s
);

await core.group("Setting up MATLAB", async () => {
let matlabArch = architecture;
if (platform === "darwin" && architecture === "arm64" && releaseInfo.name < "r2023b") {
matlabArch = "x64";
}

let [destination, alreadyExists]: [string, boolean] = await matlab.getToolcacheDir(platform, releaseInfo);
let cacheHit = false;

if (useCache) {
const supportFilesDir = matlab.getSupportPackagesPath(platform, releaseInfo.name);
cacheHit = await cache.restoreMATLAB(releaseInfo, platform, architecture, products, destination, supportFilesDir);
cacheHit = await cache.restoreMATLAB(releaseInfo, platform, matlabArch, products, destination, supportFilesDir);
}

if (!alreadyExists && !cacheHit) {
const mpmPath: string = await mpm.setup(platform, architecture);
const mpmPath: string = await mpm.setup(platform, matlabArch);
await mpm.install(mpmPath, releaseInfo, products, destination);
}

core.addPath(path.join(destination, "bin"));
core.setOutput('matlabroot', destination);

await matlab.setupBatch(platform, architecture);
await matlab.setupBatch(platform, matlabArch);
});

return;
Expand Down
12 changes: 12 additions & 0 deletions src/install.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,16 @@ describe("install procedure", () => {
expect(mpmSetupMock).toHaveBeenCalledTimes(1);
expect(mpmInstallMock).toHaveBeenCalledTimes(1);
});

it("installs Intel version on Apple silicon prior to R2023b", async () => {
matlabGetReleaseInfoMock.mockResolvedValue({
name: "r2023a",
version: "9.14.0",
updateNumber: "latest"
});
await expect(install.install("darwin", "arm64", "r2023a", products, true)).resolves.toBeUndefined();
expect(matlabInstallSystemDependenciesMock).toHaveBeenCalledWith("darwin", "arm64", "r2023a");
expect(matlabSetupBatchMock).toHaveBeenCalledWith("darwin", "x64");
expect(mpmSetupMock).toHaveBeenCalledWith("darwin", "x64");
});
});
13 changes: 12 additions & 1 deletion src/matlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,18 @@ export async function installSystemDependencies(platform: string, architecture:
if (platform === "linux") {
return script.downloadAndRunScript(platform, properties.matlabDepsUrl, [release]);
} else if (platform === "darwin" && architecture === "arm64") {
return installAppleSiliconJdk();
if (release < "r2023b") {
return installAppleSiliconRosetta();
} else {
return installAppleSiliconJdk();
}
}
}

async function installAppleSiliconRosetta() {
const exitCode = await exec.exec(`sudo softwareupdate --install-rosetta --agree-to-license`);
if (exitCode !== 0) {
return Promise.reject(Error("Unable to install Rosetta 2."));
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/matlab.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe("matlab tests", () => {
let tcDownloadToolMock: jest.Mock;
let execMock: jest.Mock;
const arch = "x64";
const release = "R2023b";
const release = "r2023b";

beforeEach(() => {
downloadAndRunScriptMock = script.downloadAndRunScript as jest.Mock;
Expand Down Expand Up @@ -330,6 +330,15 @@ describe("matlab tests", () => {
expect(tcDownloadToolMock).toHaveBeenCalledWith(properties.appleSiliconJdkUrl, expect.anything());
expect(execMock).toHaveBeenCalledWith(`sudo installer -pkg "java.jdk" -target /`);
});

it(`works on mac with apple silicon <R2023b`, async () => {
const platform = "darwin";
execMock.mockResolvedValue(0);
await expect(
matlab.installSystemDependencies(platform, "arm64", "r2023a")
).resolves.toBeUndefined();
expect(execMock).toHaveBeenCalledWith(`sudo softwareupdate --install-rosetta --agree-to-license`);
});
});

it("rejects when the apple silicon JDK download fails", async () => {
Expand Down