Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance: improve error feedback when tasks fail in CI #19786

Merged
merged 4 commits into from
Nov 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions scripts/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,18 @@ async function writeJunitXml(
taskKey: TaskKey,
templateKey: TemplateKey,
startTime: Date,
err?: Error
err?: Error,
systemError?: boolean
) {
let errorData = {};
if (err) {
// we want to distinguish whether the error comes from the tests we are running or from arbitrary code
errorData = systemError ? { errors: [{ message: err.stack }] } : { errors: [err] };
}

const name = `${taskKey} - ${templateKey}`;
const time = (Date.now() - +startTime) / 1000;
const testCase = { name, assertions: 1, time, ...(err && { errors: [err] }) };
const testCase = { name, assertions: 1, time, ...errorData };
const suite = { name, timestamp: startTime, time, testCases: [testCase] };
const junitXml = getJunitXml({ time, name, suites: [suite] });
const path = getJunitFilename(taskKey);
Expand Down Expand Up @@ -282,7 +289,7 @@ async function runTask(task: Task, details: TemplateDetails, optionValues: Passe
const hasJunitFile = await pathExists(junitFilename);
// If there's a non-test related error (junit report has not been reported already), we report the general failure in a junit report
if (junitFilename && !hasJunitFile) {
await writeJunitXml(getTaskKey(task), details.key, startTime, err);
await writeJunitXml(getTaskKey(task), details.key, startTime, err, true);
}

throw err;
Expand Down