diff --git a/packages/kbn-test/src/failed_tests_reporter/get_failures.ts b/packages/kbn-test/src/failed_tests_reporter/get_failures.ts index 45c7261e0fd9b..bb9ea6a425246 100644 --- a/packages/kbn-test/src/failed_tests_reporter/get_failures.ts +++ b/packages/kbn-test/src/failed_tests_reporter/get_failures.ts @@ -14,6 +14,8 @@ export type TestFailure = FailedTestCase['$'] & { failure: string; likelyIrrelevant: boolean; 'system-out'?: string; + githubIssue?: string; + failureCount?: number; }; const getText = (node?: Array) => { diff --git a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts index f075f6ef0b75b..e481da019945c 100644 --- a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts +++ b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_file.ts @@ -82,13 +82,19 @@ export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) { ? ` #${parseInt(process.env.BUILDKITE_PARALLEL_JOB, 10) + 1}` : ''; + const buildUrl = process.env.BUILDKITE_BUILD_URL || ''; + const jobUrl = process.env.BUILDKITE_JOB_ID + ? `${buildUrl}#${process.env.BUILDKITE_JOB_ID}` + : ''; + const failureJSON = JSON.stringify( { ...failure, hash, buildId: process.env.BUJILDKITE_BUILD_ID || '', jobId: process.env.BUILDKITE_JOB_ID || '', - url: process.env.BUILDKITE_BUILD_URL || '', + url: buildUrl, + jobUrl, jobName: process.env.BUILDKITE_LABEL ? `${process.env.BUILDKITE_LABEL}${jobNumberSuffix}` : '', @@ -128,6 +134,30 @@ export function reportFailuresToFile(log: ToolingLog, failures: TestFailure[]) { .join('')}

${escape(failure.name)}

+

+ + Failures in tracked branches: ${ + failure.failureCount || 0 + } + ${ + failure.githubIssue + ? `
${escape( + failure.githubIssue + )}` + : '' + } +
+

+ ${ + jobUrl + ? `

+ + Buildkite Job
+ ${escape(jobUrl)} +
+

` + : '' + }
${escape(failure.failure)}
${screenshotHtml}
${escape(failure['system-out'] || '')}
diff --git a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts index 31cd43eae4141..80fe8340e6a11 100644 --- a/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts +++ b/packages/kbn-test/src/failed_tests_reporter/run_failed_tests_reporter_cli.ts @@ -99,8 +99,6 @@ export function runFailedTestsReporterCli() { const messages = Array.from(getReportMessageIter(report)); const failures = await getFailures(report); - reportFailuresToFile(log, failures); - if (indexInEs) { await reportFailuresToEs(log, failures); } @@ -146,6 +144,8 @@ export function runFailedTestsReporterCli() { branch ); const url = existingIssue.html_url; + failure.githubIssue = url; + failure.failureCount = updateGithub ? newFailureCount : newFailureCount - 1; pushMessage(`Test has failed ${newFailureCount - 1} times on tracked branches: ${url}`); if (updateGithub) { pushMessage(`Updated existing issue: ${url} (fail count: ${newFailureCount})`); @@ -157,8 +157,10 @@ export function runFailedTestsReporterCli() { pushMessage('Test has not failed recently on tracked branches'); if (updateGithub) { pushMessage(`Created new issue: ${newIssue.html_url}`); + failure.githubIssue = newIssue.html_url; } newlyCreatedIssues.push({ failure, newIssue }); + failure.failureCount = updateGithub ? 1 : 0; } // mutates report to include messages and writes updated report to disk @@ -169,6 +171,8 @@ export function runFailedTestsReporterCli() { reportPath, dryRun: !flags['report-update'], }); + + reportFailuresToFile(log, failures); } }, {