diff --git a/action.yml b/action.yml index 6817b67..700aa9d 100644 --- a/action.yml +++ b/action.yml @@ -89,6 +89,8 @@ outputs: description: Count of skipped tests time: description: Test execution time [ms] + runHtmlUrl: + description: comma separated list of html links to test results runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 5e2edf1..0d387cf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -339,12 +339,16 @@ class TestReporter { core.info(`Using test report parser '${this.reporter}'`); const parser = this.getParser(this.reporter, options); const results = []; + const outputHtml = []; const input = yield inputProvider.load(); for (const [reportName, files] of Object.entries(input)) { try { core.startGroup(`Creating test report ${reportName}`); - const tr = yield this.createReport(parser, reportName, files); + const [tr, html] = yield this.createReport(parser, reportName, files); results.push(...tr); + if (html != null) { + outputHtml.push(html); + } } finally { core.endGroup(); @@ -356,11 +360,13 @@ class TestReporter { const failed = results.reduce((sum, tr) => sum + tr.failed, 0); const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0); const time = results.reduce((sum, tr) => sum + tr.time, 0); + const html = [...new Set(outputHtml)].join(','); core.setOutput('conclusion', conclusion); core.setOutput('passed', passed); core.setOutput('failed', failed); core.setOutput('skipped', skipped); core.setOutput('time', time); + core.setOutput('runHtmlUrl', html); if (this.failOnError && isFailed) { core.setFailed(`Failed test were found and 'fail-on-error' option is set to ${this.failOnError}`); return; @@ -375,7 +381,7 @@ class TestReporter { return __awaiter(this, void 0, void 0, function* () { if (files.length === 0) { core.warning(`No file matches path ${this.path}`); - return []; + return [[], '']; } core.info(`Processing test results for check run ${name}`); const results = []; @@ -416,7 +422,7 @@ class TestReporter { core.info('*** showhtmlnotice set to true'); console.log(`::notice title=Test Results::${resp.data.html_url}`); } - return results; + return [results, resp.data.html_url]; }); } getParser(reporter, options) { diff --git a/src/main.ts b/src/main.ts index 03b5dc3..63f2b2b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -107,12 +107,16 @@ class TestReporter { const parser = this.getParser(this.reporter, options) const results: TestRunResult[] = [] + const outputHtml: string[] = [] const input = await inputProvider.load() for (const [reportName, files] of Object.entries(input)) { try { core.startGroup(`Creating test report ${reportName}`) - const tr = await this.createReport(parser, reportName, files) + const [tr, html] = await this.createReport(parser, reportName, files) results.push(...tr) + if (html != null) { + outputHtml.push(html) + } } finally { core.endGroup() } @@ -124,12 +128,14 @@ class TestReporter { const failed = results.reduce((sum, tr) => sum + tr.failed, 0) const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0) const time = results.reduce((sum, tr) => sum + tr.time, 0) + const html = [...new Set(outputHtml)].join(',') core.setOutput('conclusion', conclusion) core.setOutput('passed', passed) core.setOutput('failed', failed) core.setOutput('skipped', skipped) core.setOutput('time', time) + core.setOutput('runHtmlUrl', html) if (this.failOnError && isFailed) { core.setFailed(`Failed test were found and 'fail-on-error' option is set to ${this.failOnError}`) @@ -142,10 +148,14 @@ class TestReporter { } } - async createReport(parser: TestParser, name: string, files: FileContent[]): Promise { + async createReport( + parser: TestParser, + name: string, + files: FileContent[] + ): Promise<[TestRunResult[], string | null]> { if (files.length === 0) { core.warning(`No file matches path ${this.path}`) - return [] + return [[], ''] } core.info(`Processing test results for check run ${name}`) @@ -204,7 +214,7 @@ class TestReporter { console.log(`::notice title=Test Results::${resp.data.html_url}`) } - return results + return [results, resp.data.html_url] } getParser(reporter: string, options: ParseOptions): TestParser {