Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves the error which occurs when calling setup-matlab twice in single workflow #135

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ jobs:
with:
release: ${{ matrix.release }}
products: ${{ matrix.products }}
- name: Call setup MATLAB again with different release # should not error as in issue 130
uses: ./
with:
release: R2023b
- name: Check MATLAB version
uses: matlab-actions/run-command@v2
with:
command: matlabVer = ver('matlab'); assert(strcmp(matlabVer.Release,'(R2023b)'));

19 changes: 13 additions & 6 deletions src/mpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as exec from "@actions/exec";
import * as tc from "@actions/tool-cache";
import {rmRF} from "@actions/io";
import * as path from "path";
import * as fs from 'fs';
import * as matlab from "./matlab";
import properties from "./properties.json";

Expand Down Expand Up @@ -37,15 +38,21 @@ export async function setup(platform: string, architecture: string): Promise<str
return Promise.reject(Error("Unable to find runner temporary directory."));
}
let mpmDest = path.join(runner_temp, `mpm${ext}`);
let mpm: string = await tc.downloadTool(mpmUrl, mpmDest);
if (!fs.existsSync(mpmDest)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If MPM already exists on the system, it might be better to delete it and redownload rather than skip downloading. I'm just thinking about self-hosted runners where they may have downloaded MPM a long time ago and its now a very out-of-date version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I updated the logic to delete the MPM file. Incidentally it also resolves the macos-14, R2023a job failure as well.

let mpm: string = await tc.downloadTool(mpmUrl, mpmDest);

if (platform !== "win32") {
const exitCode = await exec.exec(`chmod +x "${mpm}"`);
if (exitCode !== 0) {
return Promise.reject(Error("Unable to set up mpm."));
if (platform !== "win32") {
const exitCode = await exec.exec(`chmod +x "${mpm}"`);
if (exitCode !== 0) {
return Promise.reject(Error("Unable to set up mpm."));
}
}

return mpm;
}
else{
return mpmDest
}
return mpm
}

export async function install(mpmPath: string, release: matlab.Release, products: string[], destination: string) {
Expand Down
Loading