From be9e1a7bcace6b79f53d8bf2055d755bc26dfc79 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:03:09 +0530 Subject: [PATCH] updated --- src/buildSummary.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index ac05a87..ffe2fed 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -13,8 +13,9 @@ export interface Task { export function getBuildSummaryTable(tasks: Task[]): string[][] { - const header: string[] = ['MATLAB Build Task', 'Status', 'Description', 'Duration (hh:mm:ss)']; - let taskSummaryTableRows: string[][] = [header]; + const header = [{data:'MATLAB Build Task', header: true}, {data: 'Status', header: true}, {data:'Description', header:true}, {data: 'Duration (hh:mm:ss)', header: true }]; + let taskSummaryTableRows: string[][] = []; + if(!Array.isArray(tasks)){ taskSummaryTableRows = getTaskSummaryRows(tasks, taskSummaryTableRows); @@ -40,13 +41,15 @@ export function writeSummary(taskSummaryTableRows: string[][]) { export function processAndDisplayBuildSummary() { const runId = process.env.GITHUB_RUN_ID || ''; const runnerTemp = process.env.RUNNER_TEMP || ''; + const header = [{data:'MATLAB Build Task', header: true}, {data: 'Status', header: true}, {data:'Description', header:true}, {data: 'Duration (hh:mm:ss)', header: true }]; const filePath: string = join(runnerTemp, `buildSummary${runId}.json`); let taskSummaryTableRows; if (existsSync(filePath)) { try { - const data = JSON.parse(readFileSync(filePath, { encoding: 'utf8' })); - taskSummaryTableRows = getBuildSummaryTable(data); + const bs = readFileSync(filePath, { encoding: 'utf8' }); + const data = JSON.parse(bs).map((t: { name: any; failed: { toString: () => any; }; description: any; duration: { toString: () => any; }; }) => [t.name, t.failed.toString(), t.description, t.duration.toString()]); + taskSummaryTableRows = [header, ...data];//getBuildSummaryTable(data); } catch (e) { console.error('An error occurred while reading the build summary file:', e); return;