[CI] Add failure count and github issue link to new failed test page (#114138)

This commit is contained in:
Brian Seeders 2021-10-07 14:18:40 -04:00 committed by GitHub
parent e777ce9e3c
commit 62dfd2321d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 3 deletions

View file

@ -14,6 +14,8 @@ export type TestFailure = FailedTestCase['$'] & {
failure: string;
likelyIrrelevant: boolean;
'system-out'?: string;
githubIssue?: string;
failureCount?: number;
};
const getText = (node?: Array<string | { _: string }>) => {

View file

@ -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('')}
<hr />
<p><strong>${escape(failure.name)}</strong></p>
<p>
<small>
<strong>Failures in tracked branches</strong>: <span class="badge rounded-pill bg-danger">${
failure.failureCount || 0
}</span>
${
failure.githubIssue
? `<br /><a href="${escape(failure.githubIssue)}">${escape(
failure.githubIssue
)}</a>`
: ''
}
</small>
</p>
${
jobUrl
? `<p>
<small>
<strong>Buildkite Job</strong><br />
<a href="${escape(jobUrl)}">${escape(jobUrl)}</a>
</small>
</p>`
: ''
}
<pre>${escape(failure.failure)}</pre>
${screenshotHtml}
<pre>${escape(failure['system-out'] || '')}</pre>

View file

@ -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);
}
},
{