From 72c0a5bc580549693973f778a5f456ea0c6663be Mon Sep 17 00:00:00 2001 From: James Henry Date: Thu, 31 Mar 2022 18:38:48 +0400 Subject: [PATCH] fix(core): restore failed project summary data to dynamic output (#9632) --- ...mic-run-many-terminal-output-life-cycle.ts | 69 ++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts b/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts index 80c61ada7f6d4..aab92955bc0dc 100644 --- a/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts +++ b/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts @@ -66,6 +66,7 @@ export async function createRunManyDynamicOutputRenderer({ }; }); + const failedTasks = new Set(); const tasksToTerminalOutputs: Record = {}; const tasksToProcessStartTimes: Record< string, @@ -231,14 +232,6 @@ export async function createRunManyDynamicOutputRenderer({ additionalFooterRows.push(''); } - if (totalFailedTasks > 0) { - additionalFooterRows.push( - ` ${output.colors.red( - figures.cross - )} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed` - ); - } - if (totalSuccessfulTasks > 0) { additionalFooterRows.push( ` ${output.colors.green( @@ -249,6 +242,14 @@ export async function createRunManyDynamicOutputRenderer({ ); } + if (totalFailedTasks > 0) { + additionalFooterRows.push( + ` ${output.colors.red( + figures.cross + )} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed` + ); + } + clearPinnedFooter(); if (additionalFooterRows.length > 1) { @@ -376,25 +377,46 @@ export async function createRunManyDynamicOutputRenderer({ .forEach((arg) => taskOverridesRows.push(arg)); } - renderPinnedFooter( - [ - output.applyNxPrefix( - 'red', - output.colors.red(text) + output.dim.white(` (${timeTakenText})`) - ), - ...taskOverridesRows, - '', - ` ${output.colors.red( - figures.cross - )} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`, + const numFailedToPrint = 5; + const failedTasksForPrinting = Array.from(failedTasks).slice( + 0, + numFailedToPrint + ); + const failureSummaryRows = [ + output.applyNxPrefix( + 'red', + output.colors.red(text) + output.dim.white(` (${timeTakenText})`) + ), + ...taskOverridesRows, + '', + output.dim( ` ${output.dim( figures.tick )} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim( `[${totalCachedTasks} read from cache]` - )}`, - ], - 'red' - ); + )}` + ), + '', + ` ${output.colors.red( + figures.cross + )} ${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`, + `${failedTasksForPrinting + .map( + (t) => + ` ${output.colors.red('-')} ${output.dim('nx run')} ${t}` + ) + .join('\n ')}`, + ]; + + if (failedTasks.size > numFailedToPrint) { + failureSummaryRows.push( + output.dim( + ` ...and ${failedTasks.size - numFailedToPrint} more...` + ) + ); + } + + renderPinnedFooter(failureSummaryRows, 'red'); } resolveRenderIsDonePromise(); }; @@ -443,6 +465,7 @@ export async function createRunManyDynamicOutputRenderer({ break; case 'failure': totalFailedTasks++; + failedTasks.add(t.task.id); break; } printTaskResult(t.task, t.status);