fix(core): tui summary should handle in progress tasks properly (#30905)

## Current Behavior
When running via run-many failures that include a continuous task are
indicated as a cancellation on the tui summary

## Expected Behavior
Failures that run to completion are not cancelled, and should be
displayed as a failure

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Craigory Coppola 2025-04-29 10:00:54 -04:00 committed by GitHub
parent 147d0e1345
commit 4b9eab994a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,11 +41,12 @@ export function getTuiTerminalSummaryLifeCycle({
let totalSuccessfulTasks = 0; let totalSuccessfulTasks = 0;
let totalFailedTasks = 0; let totalFailedTasks = 0;
let totalCompletedTasks = 0; let totalCompletedTasks = 0;
let totalStoppedTasks = 0;
let timeTakenText: string; let timeTakenText: string;
const failedTasks = new Set<string>(); const failedTasks = new Set<string>();
const inProgressTasks = new Set<string>(); const inProgressTasks = new Set<string>();
const stoppedTasks = new Set<string>();
const tasksToTerminalOutputs: Record< const tasksToTerminalOutputs: Record<
string, string,
{ terminalOutput: string; taskStatus: TaskStatus } { terminalOutput: string; taskStatus: TaskStatus }
@ -65,7 +66,8 @@ export function getTuiTerminalSummaryLifeCycle({
lifeCycle.setTaskStatus = (taskId, taskStatus) => { lifeCycle.setTaskStatus = (taskId, taskStatus) => {
if (taskStatus === NativeTaskStatus.Stopped) { if (taskStatus === NativeTaskStatus.Stopped) {
totalStoppedTasks++; stoppedTasks.add(taskId);
inProgressTasks.delete(taskId);
} }
}; };
@ -118,7 +120,7 @@ export function getTuiTerminalSummaryLifeCycle({
const printRunOneSummary = () => { const printRunOneSummary = () => {
let lines: string[] = []; let lines: string[] = [];
const failure = totalSuccessfulTasks + totalStoppedTasks !== totalTasks; const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;
// Prints task outputs in the order they were completed // Prints task outputs in the order they were completed
// above the summary, since run-one should print all task results. // above the summary, since run-one should print all task results.
@ -165,7 +167,7 @@ export function getTuiTerminalSummaryLifeCycle({
); );
} }
lines = [output.colors.green(lines.join(EOL))]; lines = [output.colors.green(lines.join(EOL))];
} else if (totalCompletedTasks + totalStoppedTasks === totalTasks) { } else if (totalCompletedTasks + stoppedTasks.size === totalTasks) {
let text = `Ran target ${output.bold( let text = `Ran target ${output.bold(
targets[0] targets[0]
)} for project ${output.bold(initiatingProject)}`; )} for project ${output.bold(initiatingProject)}`;
@ -173,7 +175,7 @@ export function getTuiTerminalSummaryLifeCycle({
text += ` and ${output.bold(tasks.length - 1)} task(s) they depend on`; text += ` and ${output.bold(tasks.length - 1)} task(s) they depend on`;
} }
const taskOverridesLines = []; const taskOverridesLines: string[] = [];
if (Object.keys(overrides).length > 0) { if (Object.keys(overrides).length > 0) {
taskOverridesLines.push(''); taskOverridesLines.push('');
taskOverridesLines.push( taskOverridesLines.push(
@ -189,23 +191,25 @@ export function getTuiTerminalSummaryLifeCycle({
const viewLogs = viewLogsFooterRows(totalFailedTasks); const viewLogs = viewLogsFooterRows(totalFailedTasks);
lines = [ lines = [
output.colors.red([ output.colors.red(
output.applyNxPrefix( [
'red', output.applyNxPrefix(
output.colors.red(text) + output.dim(` (${timeTakenText})`) 'red',
), output.colors.red(text) + output.dim(` (${timeTakenText})`)
...taskOverridesLines, ),
'', ...taskOverridesLines,
`${LEFT_PAD}${output.colors.red( '',
figures.cross `${LEFT_PAD}${output.colors.red(
)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`, figures.cross
`${LEFT_PAD}${output.dim( )}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
figures.tick `${LEFT_PAD}${output.dim(
)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim( figures.tick
`[${totalCachedTasks} read from cache]` )}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim(
)}`, `[${totalCachedTasks} read from cache]`
...viewLogs, )}`,
]), ...viewLogs,
].join(EOL)
),
]; ];
} else { } else {
lines = [ lines = [
@ -231,7 +235,7 @@ export function getTuiTerminalSummaryLifeCycle({
console.log(''); console.log('');
const lines: string[] = []; const lines: string[] = [];
const failure = totalSuccessfulTasks + totalStoppedTasks !== totalTasks; const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;
for (const taskId of taskIdsInOrderOfCompletion) { for (const taskId of taskIdsInOrderOfCompletion) {
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId]; const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
@ -253,7 +257,7 @@ export function getTuiTerminalSummaryLifeCycle({
lines.push(...output.getVerticalSeparatorLines(failure ? 'red' : 'green')); lines.push(...output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
if (totalSuccessfulTasks + totalStoppedTasks === totalTasks) { if (totalSuccessfulTasks + stoppedTasks.size === totalTasks) {
const successSummaryRows = []; const successSummaryRows = [];
const text = `Successfully ran ${formatTargetsAndProjects( const text = `Successfully ran ${formatTargetsAndProjects(
projectNames, projectNames,
@ -294,7 +298,7 @@ export function getTuiTerminalSummaryLifeCycle({
const text = `${ const text = `${
inProgressTasks.size ? 'Cancelled while running' : 'Ran' inProgressTasks.size ? 'Cancelled while running' : 'Ran'
} ${formatTargetsAndProjects(projectNames, targets, tasks)}`; } ${formatTargetsAndProjects(projectNames, targets, tasks)}`;
const taskOverridesRows = []; const taskOverridesRows: string[] = [];
if (Object.keys(overrides).length > 0) { if (Object.keys(overrides).length > 0) {
taskOverridesRows.push(''); taskOverridesRows.push('');
taskOverridesRows.push( taskOverridesRows.push(
@ -312,7 +316,7 @@ export function getTuiTerminalSummaryLifeCycle({
0, 0,
numFailedToPrint numFailedToPrint
); );
const failureSummaryRows = [ const failureSummaryRows: string[] = [
output.applyNxPrefix( output.applyNxPrefix(
'red', 'red',
output.colors.red(text) + output.dim.white(` (${timeTakenText})`) output.colors.red(text) + output.dim.white(` (${timeTakenText})`)