From 2fe0f044a782d2331a0236ef0bf8ae25da4e03a4 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:57:22 +0530 Subject: [PATCH 1/4] Fixed issue #35 --- src/buildSummary.ts | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index 95c02b9..72585a0 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -16,21 +16,13 @@ export function getBuildSummaryTable(tasks: Task[]): string[][] { const header: string[] = ['MATLAB Build Task', 'Status', 'Description', 'Duration (HH:MM:SS)']; let taskSummaryTableRows: string[][] = [header]; - tasks.forEach((task, index) => { - let taskDetails: string[] = []; - taskDetails.push(task.name); - if (task.failed) { - taskDetails.push('🔴 FAILED'); - } else if (task.skipped) { - taskDetails.push('🔵 SKIPPED'); - } else { - taskDetails.push('🟢 SUCCESS'); - } - taskDetails.push(task.description); - taskDetails.push(task.duration); - - taskSummaryTableRows.push(taskDetails); - }); + if(!Array.isArray(tasks)){ + taskSummaryTableRows = getTaskSummaryRows(tasks, taskSummaryTableRows); + } else { + tasks.forEach((task, index) => { + taskSummaryTableRows = getTaskSummaryRows(task, taskSummaryTableRows); + }); + } return taskSummaryTableRows; } @@ -61,3 +53,24 @@ export function processAndDisplayBuildSummary() { writeSummary(taskSummaryTableRows); } +export function addTasks(tasks: Task): string[] { + let taskDetails: string[] = []; + taskDetails.push(tasks.name); + if (tasks.failed) { + taskDetails.push('🔴 FAILED'); + } else if (tasks.skipped) { + taskDetails.push('🔵 SKIPPED'); + } else { + taskDetails.push('🟢 SUCCESS'); + } + taskDetails.push(tasks.description); + taskDetails.push(tasks.duration); + return taskDetails; +} + +export function getTaskSummaryRows(task: Task, taskSummaryTableRows: string[][]): string[][] { + let taskDetails: string[] = []; + taskDetails = addTasks(task); + taskSummaryTableRows.push(taskDetails); + return taskSummaryTableRows; +} From 8b40c1634e4408e1543493fca4e6f77520d4d8b2 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:15:02 +0530 Subject: [PATCH 2/4] Fixed issue #36 --- src/buildSummary.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index 72585a0..a93bc2d 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -1,7 +1,7 @@ // Copyright 2024 The MathWorks, Inc. import * as core from "@actions/core"; import { join } from 'path'; -import { readFileSync } from 'fs'; +import { readFileSync, unlinkSync} from 'fs'; export interface Task { name: string; @@ -41,14 +41,20 @@ export function processAndDisplayBuildSummary() { const runId = process.env.GITHUB_RUN_ID || ''; const runnerTemp = process.env.RUNNER_TEMP || ''; + const filePath: string = join(runnerTemp, `buildSummary${runId}.json`); let taskSummaryTableRows; try { - const filePath: string = join(runnerTemp, `buildSummary${runId}.json`); const data = JSON.parse(readFileSync(filePath, { encoding: 'utf8' })); taskSummaryTableRows = getBuildSummaryTable(data); } catch (e) { console.error('An error occurred while reading the build summary file:', e); return; + } finally { + try { + unlinkSync(filePath); + } catch (e) { + console.error(`An error occurred while trying to delete the file ${filePath}:`, e); + } } writeSummary(taskSummaryTableRows); } From 6993282a66bc2710b3317f00f6d4d81732d34cf4 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:07:07 +0530 Subject: [PATCH 3/4] Updated method names --- src/buildSummary.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index a93bc2d..2a05215 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -53,13 +53,13 @@ export function processAndDisplayBuildSummary() { try { unlinkSync(filePath); } catch (e) { - console.error(`An error occurred while trying to delete the file ${filePath}:`, e); + console.error(`An error occurred while trying to delete the build summary file ${filePath}:`, e); } } writeSummary(taskSummaryTableRows); } -export function addTasks(tasks: Task): string[] { +export function getTaskDetails(tasks: Task): string[] { let taskDetails: string[] = []; taskDetails.push(tasks.name); if (tasks.failed) { @@ -76,7 +76,7 @@ export function addTasks(tasks: Task): string[] { export function getTaskSummaryRows(task: Task, taskSummaryTableRows: string[][]): string[][] { let taskDetails: string[] = []; - taskDetails = addTasks(task); + taskDetails = getTaskDetails(task); taskSummaryTableRows.push(taskDetails); return taskSummaryTableRows; } From e904d846e8c3a61d24a702f781785a28fbea477e Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:27:49 +0530 Subject: [PATCH 4/4] Reset the version to 2.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2289781..378e968 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "run-matlab-build-action", - "version": "2.4.0", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "run-matlab-build-action", - "version": "2.4.0", + "version": "2.3.0", "dependencies": { "@actions/core": "^1.4.0", "@actions/exec": "^1.1.0", diff --git a/package.json b/package.json index a3a315d..9ccd6fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "run-matlab-build-action", "author": "The MathWorks, Inc.", - "version": "2.4.0", + "version": "2.3.0", "description": "", "main": "lib/index.js", "scripts": {