Skip to content

Commit

Permalink
Updating as per review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nbhoski committed Jul 2, 2024
1 parent f812d93 commit ed2a02f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
21 changes: 13 additions & 8 deletions src/buildSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,28 @@ export function getBuildSummaryTable(tasks: Task[]): string[][] {
}

export function writeSummary(taskSummaryTableRows: string[][]) {
try{
try {
core.summary
.addTable(taskSummaryTableRows)
.write();
.addTable(taskSummaryTableRows)
.write();
} catch (e) {
console.error('An error occurred while adding the build results table to the summary:', e);
}
}
}

export function processAndDisplayBuildSummary() {
const runId = process.env.GITHUB_RUN_ID || '';
const runnerTemp = process.env.RUNNER_TEMP || '';

const filePath: string = join(runnerTemp, `buildSummary${runId}.json`);
const data = JSON.parse(readFileSync(filePath, { encoding: 'utf8' }));
const taskSummaryTableRows = getBuildSummaryTable(data);

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;
}
writeSummary(taskSummaryTableRows);
}

6 changes: 1 addition & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ async function run() {
(cmd, args) => exec.exec(cmd, args, execOptions),
startupOptions
).finally(() => {
try {
buildSummary.processAndDisplayBuildSummary();
} catch (e) {
console.error('An error occurred while reading the build summary file:', e);
}
buildSummary.processAndDisplayBuildSummary();
});

}
Expand Down

0 comments on commit ed2a02f

Please sign in to comment.