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 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
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)'));

11 changes: 11 additions & 0 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,6 +38,16 @@ 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}`);

// Delete mpm file if it exists
if (fs.existsSync(mpmDest)) {
try {
fs.unlinkSync(mpmDest);
} catch (err) {
return Promise.reject(Error(`Failed to delete existing mpm file: ${err}`));
}
}

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

if (platform !== "win32") {
Expand Down
Loading