Skip to content

Commit

Permalink
Handdled multiple try catch issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nbhoski committed Jul 1, 2024
1 parent 9f9e5d5 commit 4e0cc0a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/buildSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function processAndDisplayBuildSummary() {
let filePath: string;

if (!runId) {
filePath = join(runnerTemp as string, `buildSummary_.json`);
filePath = join(runnerTemp as string, `buildSummary.json`);
} else {
filePath = join(runnerTemp as string, `buildSummary_${runId as string}.json`);
}
Expand Down
75 changes: 33 additions & 42 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,43 @@ import * as buildSummary from "./buildSummary";
* Gather action inputs and then run action.
*/
async function run() {
try {

const platform = process.platform;
const architecture = process.arch;
const workspaceDir = process.cwd();

const options: buildtool.RunBuildOptions = {
Tasks: core.getInput("tasks"),
BuildOptions: core.getInput("build-options"),
};

const command = buildtool.generateCommand(options);
const startupOptions = core.getInput("startup-options").split(" ");

const helperScript = await matlab.generateScript(workspaceDir, command);
const execOptions = {
env: {
...process.env,
"MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE": "ciplugins.github.getDefaultPlugins",
}
};

await matlab.runCommand(
helperScript,
platform,
architecture,
(cmd, args) => exec.exec(cmd, args, execOptions),
startupOptions
);
const platform = process.platform;
const architecture = process.arch;
const workspaceDir = process.cwd();

buildSummary.processAndDisplayBuildSummary();
const options: buildtool.RunBuildOptions = {
Tasks: core.getInput("tasks"),
BuildOptions: core.getInput("build-options"),
};

} catch (e) {
try {
buildSummary.processAndDisplayBuildSummary();
} catch (summaryError) {
console.error('An error occurred while reading the build summary file or adding the build summary table:', summaryError);
}
if (e instanceof Error || typeof e === "string") {
core.setFailed(e);
} else {
core.setFailed("An unknown error occurred while runing MATLAB build.");
const command = buildtool.generateCommand(options);
const startupOptions = core.getInput("startup-options").split(" ");

const helperScript = await matlab.generateScript(workspaceDir, command);
const execOptions = {
env: {
...process.env,
"MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE": "ciplugins.github.getDefaultPlugins",
}

}
};

await matlab.runCommand(
helperScript,
platform,
architecture,
(cmd, args) => exec.exec(cmd, args, execOptions),
startupOptions
);

}

run();
run().catch(e => {
core.setFailed(e);
}).finally(() => {
try {
buildSummary.processAndDisplayBuildSummary();
} catch (ex) {
console.error('An error occurred while reading the build summary file or adding the build summary table:', ex);
}
});

0 comments on commit 4e0cc0a

Please sign in to comment.