feat: allows to generate the summary only.

This commit is contained in:
Giuseppe Lippolis 2021-06-03 10:41:08 +02:00
parent e8f4fdfec7
commit 17e793242c
6 changed files with 189 additions and 129 deletions

View file

@ -39,6 +39,7 @@ class TestReporter {
readonly maxAnnotations = parseInt(core.getInput('max-annotations', {required: true}))
readonly failOnError = core.getInput('fail-on-error', {required: true}) === 'true'
readonly workDirInput = core.getInput('working-directory', {required: false})
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
readonly token = core.getInput('token', {required: true})
readonly octokit: InstanceType<typeof GitHub>
readonly context = getCheckRunContext()
@ -160,9 +161,9 @@ class TestReporter {
})
core.info('Creating report summary')
const {listSuites, listTests} = this
const {listSuites, listTests, onlySummary} = this
const baseUrl = createResp.data.html_url
const summary = getReport(results, {listSuites, listTests, baseUrl})
const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary})
core.info('Creating annotations')
const annotations = getAnnotations(results, this.maxAnnotations)

View file

@ -10,12 +10,14 @@ export interface ReportOptions {
listSuites: 'all' | 'failed'
listTests: 'all' | 'failed' | 'none'
baseUrl: string
onlySummary: boolean
}
const defaultOptions: ReportOptions = {
listSuites: 'all',
listTests: 'all',
baseUrl: ''
baseUrl: '',
onlySummary: false
}
export function getReport(results: TestRunResult[], options: ReportOptions = defaultOptions): string {
@ -152,8 +154,10 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s
sections.push(resultsTable)
}
const suitesReports = testRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat()
sections.push(...suitesReports)
if (options.onlySummary === false) {
const suitesReports = testRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat()
sections.push(...suitesReports)
}
return sections
}