issue #153 add results to Check title

This commit is contained in:
Dennis Palmer 2022-09-08 08:35:38 +02:00
parent 0d9714ddc7
commit 7d1f4f7a70
4 changed files with 32 additions and 5 deletions

15
dist/index.js generated vendored
View file

@ -390,6 +390,7 @@ class TestReporter {
const { listSuites, listTests, onlySummary } = this;
const baseUrl = createResp.data.html_url;
const summary = (0, get_report_1.getReport)(results, { listSuites, listTests, baseUrl, onlySummary });
const checkResultSummary = (0, get_report_1.getCheckResultSummary)(results);
core.info('Creating annotations');
const annotations = (0, get_annotations_1.getAnnotations)(results, this.maxAnnotations);
const isFailed = results.some(tr => tr.result === 'failed');
@ -397,7 +398,7 @@ class TestReporter {
const icon = isFailed ? markdown_utils_1.Icon.fail : markdown_utils_1.Icon.success;
core.info(`Updating check run conclusion (${conclusion}) and output`);
const resp = yield this.octokit.rest.checks.update(Object.assign({ check_run_id: createResp.data.id, conclusion, status: 'completed', output: {
title: `${name} ${icon}`,
title: `${checkResultSummary}${name} ${icon}`,
summary,
annotations
} }, github.context.repo));
@ -1456,7 +1457,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getReport = void 0;
exports.getCheckResultSummary = exports.getReport = void 0;
const core = __importStar(__nccwpck_require__(2186));
const markdown_utils_1 = __nccwpck_require__(6482);
const node_utils_1 = __nccwpck_require__(5824);
@ -1491,6 +1492,16 @@ function getReport(results, options = defaultOptions) {
return trimReport(lines);
}
exports.getReport = getReport;
function getCheckResultSummary(results) {
const runResultTotals = results.reduce((totals, currentResults) => {
totals.passed += currentResults.passed;
totals.failed += currentResults.failed;
totals.skipped += currentResults.skipped;
return totals;
}, { passed: 0, failed: 0, skipped: 0 });
return `${runResultTotals.passed} passed, ${runResultTotals.failed} failed, ${runResultTotals.skipped} skipped`;
}
exports.getCheckResultSummary = getCheckResultSummary;
function trimReport(lines) {
const closingBlock = '```';
const errorMsg = `**Report exceeded GitHub limit of ${MAX_REPORT_LENGTH} bytes and has been trimmed**`;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@ import {FileContent} from './input-providers/input-provider'
import {ParseOptions, TestParser} from './test-parser'
import {TestRunResult} from './test-results'
import {getAnnotations} from './report/get-annotations'
import {getReport} from './report/get-report'
import {getCheckResultSummary, getReport} from './report/get-report'
import {DartJsonParser} from './parsers/dart-json/dart-json-parser'
import {DotnetTrxParser} from './parsers/dotnet-trx/dotnet-trx-parser'
@ -171,6 +171,8 @@ class TestReporter {
const baseUrl = createResp.data.html_url as string
const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary})
const checkResultSummary = getCheckResultSummary(results)
core.info('Creating annotations')
const annotations = getAnnotations(results, this.maxAnnotations)
@ -184,7 +186,7 @@ class TestReporter {
conclusion,
status: 'completed',
output: {
title: `${name} ${icon}`,
title: `${checkResultSummary}${name} ${icon}`,
summary,
annotations
},

View file

@ -48,6 +48,20 @@ export function getReport(results: TestRunResult[], options: ReportOptions = def
return trimReport(lines)
}
export function getCheckResultSummary(results: TestRunResult[]): string {
const runResultTotals = results.reduce(
(totals, currentResults) => {
totals.passed += currentResults.passed
totals.failed += currentResults.failed
totals.skipped += currentResults.skipped
return totals
},
{passed: 0, failed: 0, skipped: 0}
)
return `${runResultTotals.passed} passed, ${runResultTotals.failed} failed, ${runResultTotals.skipped} skipped`
}
function trimReport(lines: string[]): string {
const closingBlock = '```'
const errorMsg = `**Report exceeded GitHub limit of ${MAX_REPORT_LENGTH} bytes and has been trimmed**`