Skip to content

Commit 2e59bf3

Browse files
committed
update summary writing method
1 parent c748da7 commit 2e59bf3

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/buildSummary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as core from "@actions/core";
33
import { join } from 'path';
44
import { readFileSync, unlinkSync, existsSync } from 'fs';
55

6-
export function writeSummary(taskSummaryTableRows: string[][], actionName: string) {
6+
export function addSummary(taskSummaryTableRows: string[][], actionName: string) {
77
try {
88
core.summary
99
.addHeading("MATLAB Build Results (" + actionName + ") ")
@@ -40,7 +40,7 @@ export function interpretSkipReason(skipReason: string){
4040
}
4141
}
4242

43-
export function processAndDisplayBuildSummary(
43+
export function processAndAddBuildSummary(
4444
runnerTemp: string,
4545
runId: string,
4646
actionName: string
@@ -64,6 +64,6 @@ export function processAndDisplayBuildSummary(
6464
console.error(`An error occurred while trying to delete the build summary file ${filePath}:`, e);
6565
}
6666
}
67-
writeSummary(taskSummaryTable, actionName);
67+
addSummary(taskSummaryTable, actionName);
6868
}
6969
}

src/testResultsSummary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ export interface TestResultsData {
6161
Stats: TestStatistics;
6262
}
6363

64-
export function processAndDisplayTestSummary(
64+
export function processAndAddTestSummary(
6565
runnerTemp: string,
6666
runId: string,
6767
actionName: string,
6868
workspace: string,
6969
) {
7070
const testResultsData = getTestResults(runnerTemp, runId, workspace);
7171
if(testResultsData) {
72-
writeSummary(testResultsData, actionName);
72+
addSummary(testResultsData, actionName);
7373
}
7474
}
7575

@@ -132,7 +132,7 @@ export function getTestResults(
132132
return testResultsData;
133133
}
134134

135-
export function writeSummary(
135+
export function addSummary(
136136
testResultsData: TestResultsData,
137137
actionName: string,
138138
) {

src/testResultsSummary.unit.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jest.mock("@actions/core", () => ({
1010
summary: {
1111
addHeading: jest.fn().mockReturnThis(),
1212
addRaw: jest.fn().mockReturnThis(),
13-
write: jest.fn().mockReturnThis(),
1413
},
1514
}));
1615

@@ -141,7 +140,7 @@ describe("Artifact Processing Tests", () => {
141140
it("should write test results data to the GitHub job summary", () => {
142141
if (testResultsData) {
143142
const actionName = process.env.GITHUB_ACTION || "";
144-
testResultsSummary.writeSummary(testResultsData, actionName);
143+
testResultsSummary.addSummary(testResultsData, actionName);
145144

146145
expect(core.summary.addHeading).toHaveBeenCalledTimes(2);
147146
expect(core.summary.addHeading).toHaveBeenNthCalledWith(
@@ -165,7 +164,6 @@ describe("Artifact Processing Tests", () => {
165164
expect(core.summary.addHeading).toHaveBeenNthCalledWith(2, "All tests", 3);
166165

167166
expect(core.summary.addRaw).toHaveBeenCalledTimes(2);
168-
expect(core.summary.write).toHaveBeenCalledTimes(1);
169167
}
170168
});
171169
});
@@ -322,7 +320,7 @@ describe("HTML Structure Tests", () => {
322320
});
323321

324322
describe("Error Handling Tests", () => {
325-
it("should handle errors gracefully in writeSummary", () => {
323+
it("should handle errors gracefully in addSummary", () => {
326324
const consoleSpy = jest.spyOn(console, "error").mockImplementation(() => {});
327325

328326
// Mock addHeading to throw an error
@@ -346,7 +344,7 @@ describe("Error Handling Tests", () => {
346344

347345
// This should not throw, but should log the error
348346
expect(() => {
349-
testResultsSummary.writeSummary(mockTestResultsData, "mockAction");
347+
testResultsSummary.addSummary(mockTestResultsData, "mockAction");
350348
}).not.toThrow();
351349

352350
// Verify error was logged

0 commit comments

Comments
 (0)