in test-reporter/src/main.ts [67:141]
async run(): Promise<void> {
if (this.workDirInput) {
core.info(`Changing directory to '${this.workDirInput}'`)
process.chdir(this.workDirInput)
}
core.info(`Check runs will be created with SHA=${this.context.sha}`)
// Split path pattern by ',' and optionally convert all backslashes to forward slashes
// fast-glob (micromatch) always interprets backslashes as escape characters instead of directory separators
const pathsList = this.path.split(',')
const pattern = this.pathReplaceBackslashes ? pathsList.map(normalizeFilePath) : pathsList
const inputProvider = this.artifact
? new ArtifactProvider(
this.octokit,
this.artifact,
this.name,
pattern,
this.context.sha,
this.context.runId,
this.token
)
: new LocalFileProvider(this.name, pattern)
const parseErrors = this.maxAnnotations > 0
const trackedFiles = await inputProvider.listTrackedFiles()
const workDir = this.artifact ? undefined : normalizeDirPath(process.cwd(), true)
core.info(`Found ${trackedFiles.length} files tracked by GitHub`)
const options: ParseOptions = {
workDir,
trackedFiles,
parseErrors
}
core.info(`Using test report parser '${this.reporter}'`)
const parser = this.getParser(this.reporter, options)
const results: TestRunResult[] = []
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)
results.push(...tr)
} finally {
core.endGroup()
}
}
const isFailed = results.some(tr => tr.result === 'failed')
const conclusion = isFailed ? 'failure' : 'success'
const passed = results.reduce((sum, tr) => sum + tr.passed, 0)
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)
core.setOutput('conclusion', conclusion)
core.setOutput('passed', passed)
core.setOutput('failed', failed)
core.setOutput('skipped', skipped)
core.setOutput('time', time)
if (this.failOnError && isFailed) {
core.setFailed(`Failed test were found and 'fail-on-error' option is set to ${this.failOnError}`)
return
}
if (results.length === 0) {
core.setFailed(`No test report files were found`)
return
}
}