Skip to content

Commit 9286d1b

Browse files
Copilotneilime
andcommitted
Fix empty outputs by updating format parsing logic
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
1 parent 9058509 commit 9286d1b

2 files changed

Lines changed: 23 additions & 20 deletions

File tree

actions/parse-ci-reports/src/ReportParserCore.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,21 @@ export class ReportParserCore {
5151
* @param {ReportData} reportData - The parsed report data
5252
* @param {string} reportName - Name of the report
5353
* @param {boolean} includePassed - Include passed tests
54-
* @param {string} outputFormat - Output format (summary, markdown, both)
54+
* @param {string} outputFormat - Output format (comma-separated: summary, markdown, annotations, or "all")
5555
* @returns {Object} Object with markdown and summary strings
5656
*/
5757
generateOutput(reportData, reportName, includePassed, outputFormat) {
58+
// Parse output formats
59+
const formats = this.parseOutputFormats(outputFormat);
60+
5861
let markdown = "";
5962
let summary = "";
6063

61-
if (outputFormat === "markdown" || outputFormat === "both") {
64+
if (formats.includes("markdown")) {
6265
markdown = this.markdownFormatter.format(reportData, reportName);
6366
}
6467

65-
if (outputFormat === "summary" || outputFormat === "both") {
68+
if (formats.includes("summary")) {
6669
summary = this.summaryFormatter.format(
6770
reportData,
6871
reportName,
@@ -72,4 +75,20 @@ export class ReportParserCore {
7275

7376
return { markdown, summary };
7477
}
78+
79+
/**
80+
* Parse output format string into array of formats
81+
* @param {string} outputFormat - Output format string (comma-separated or "all")
82+
* @returns {string[]} Array of output format values
83+
*/
84+
parseOutputFormats(outputFormat) {
85+
if (outputFormat === "all") {
86+
return ["summary", "markdown", "annotations"];
87+
}
88+
89+
return outputFormat
90+
.split(",")
91+
.map((f) => f.trim())
92+
.filter((f) => f.length > 0);
93+
}
7594
}

actions/parse-ci-reports/src/index.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function run({ core, glob: globModule, inputs }) {
1212
core.info(`Output Format: ${inputs.outputFormat}`);
1313

1414
// Parse output formats (comma-separated or "all")
15-
const outputFormats = parseOutputFormats(inputs.outputFormat);
15+
const outputFormats = parserCore.parseOutputFormats(inputs.outputFormat);
1616
core.info(`Output formats: ${outputFormats.join(", ")}`);
1717

1818
// Resolve report paths using the dedicated component
@@ -80,22 +80,6 @@ async function run({ core, glob: globModule, inputs }) {
8080
}
8181
}
8282

83-
/**
84-
* Parse output format string into array of formats
85-
* @param {string} outputFormat - Output format string (comma-separated or "all")
86-
* @returns {string[]} Array of output format values
87-
*/
88-
function parseOutputFormats(outputFormat) {
89-
if (outputFormat === "all") {
90-
return ["summary", "markdown", "annotations"];
91-
}
92-
93-
return outputFormat
94-
.split(",")
95-
.map((f) => f.trim())
96-
.filter((f) => f.length > 0);
97-
}
98-
9983
/**
10084
* Generate GitHub annotations for failed tests and lint issues
10185
*/

0 commit comments

Comments
 (0)