-
Notifications
You must be signed in to change notification settings - Fork 710
[rush-daemon] Print the native operation summary and duration line on the daemon path #6068
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
Merged
Sean Larkin (TheLarkInn)
merged 4 commits into
main
from
thelarkinn-fix-rushd-summary-banner
Sep 24, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
81a178d
[rush-daemon] Print the native operation summary and duration line fo…
TheLarkInn 7765788
[rush-daemon] Fix summary test typing
TheLarkInn 47ecfe1
[rush-sdk] Update the export snapshot for _printOperationStatus
TheLarkInn f7ec178
[rush-daemon] Honor the request warnings policy in the operation summary
TheLarkInn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@microsoft/rush/rushd-summary-banner_2026-09-24-01-30.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@microsoft/rush", | ||
| "comment": "Expose the internal operation summary printer so the Rush daemon can print the native end-of-run summary.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@microsoft/rush", | ||
| "email": "TheLarkInn@users.noreply.github.com" | ||
| } |
11 changes: 11 additions & 0 deletions
11
common/changes/@rushstack/rush-daemon/rushd-summary-banner_2026-09-24-01-30.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@rushstack/rush-daemon", | ||
| "comment": "Print the native operation summary tables and the \"rush <command> (<duration>)\" line for each phased request, including warm no-op builds.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@rushstack/rush-daemon", | ||
| "email": "TheLarkInn@users.noreply.github.com" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import type { | ||
| IOperationExecutionResult, | ||
| IOperationGraph, | ||
| Operation, | ||
| _IOperationActivityOptions | ||
| } from '@microsoft/rush-lib'; | ||
| import { OperationStatus, _printOperationStatus } from '@microsoft/rush-lib'; | ||
| import { Terminal, TerminalProviderSeverity, type ITerminalProvider } from '@rushstack/terminal'; | ||
|
|
||
| const SECONDS_PER_MINUTE: number = 60; | ||
| const MILLISECONDS_PER_SECOND: number = 1000; | ||
| const SUMMARIZED_STATUSES: ReadonlySet<OperationStatus> = new Set([ | ||
| OperationStatus.Aborted, | ||
| OperationStatus.Blocked, | ||
| OperationStatus.Failure, | ||
| OperationStatus.FromCache, | ||
| OperationStatus.NoOp, | ||
| OperationStatus.Skipped, | ||
| OperationStatus.Success, | ||
| OperationStatus.SuccessWithWarning | ||
| ]); | ||
|
|
||
| /** The subset of a request event sink used to render a request's end-of-run summary. */ | ||
| export interface IPhasedRequestSummarySink { | ||
| getObservedResult(operation: Operation): { readonly executionResult: IOperationExecutionResult } | undefined; | ||
| onActivity(text: string, options?: _IOperationActivityOptions): void; | ||
| } | ||
|
|
||
| export interface IWritePhasedRequestSummaryOptions { | ||
| readonly activeOperations: ReadonlyArray<Operation>; | ||
| readonly commandName: string; | ||
| readonly elapsedMs: number; | ||
| readonly executionError: unknown; | ||
| readonly graph: IOperationGraph; | ||
| readonly sink: IPhasedRequestSummarySink; | ||
| /** Whether the request environment allows warnings in a successful build (`RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD`). */ | ||
| readonly warningsAllowedByEnvironment: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Buffers terminal output into request-scoped activity events, one event per contiguous stream run. | ||
| */ | ||
| class RequestActivityTerminalProvider implements ITerminalProvider { | ||
| public readonly supportsColor: boolean = false; | ||
| public readonly eolCharacter: string = '\n'; | ||
| readonly #sink: IPhasedRequestSummarySink; | ||
| #buffer: string = ''; | ||
| #stderr: boolean = false; | ||
|
|
||
| public constructor(sink: IPhasedRequestSummarySink) { | ||
| this.#sink = sink; | ||
| } | ||
|
|
||
| public write(text: string, severity: TerminalProviderSeverity): void { | ||
| if (severity === TerminalProviderSeverity.verbose || severity === TerminalProviderSeverity.debug) { | ||
| return; | ||
| } | ||
| const stderr: boolean = | ||
| severity === TerminalProviderSeverity.error || severity === TerminalProviderSeverity.warning; | ||
| if (stderr !== this.#stderr) { | ||
| this.flush(); | ||
| this.#stderr = stderr; | ||
| } | ||
| this.#buffer += text; | ||
| } | ||
|
|
||
| public flush(): void { | ||
| if (this.#buffer.length > 0) { | ||
| this.#sink.onActivity(this.#buffer, { stderr: this.#stderr }); | ||
| this.#buffer = ''; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Writes the native end-of-run summary (the status tables and the `rush <command> (<duration>)` line) for one | ||
| * phased request into that request's own event sink. | ||
| * | ||
| * @remarks | ||
| * Coalesced requests share one graph iteration, so the summary is computed per request from the request's own | ||
| * selection rather than from the whole iteration. Selected operations that the warm graph did not need to run are | ||
| * reported as already up to date, so a warm no-op still reports what it checked. | ||
| */ | ||
| export function writePhasedRequestSummary(options: IWritePhasedRequestSummaryOptions): void { | ||
| const { commandName, elapsedMs, executionError, sink } = options; | ||
| const provider: RequestActivityTerminalProvider = new RequestActivityTerminalProvider(sink); | ||
| const terminal: Terminal = new Terminal(provider); | ||
| const duration: string = formatDuration(elapsedMs); | ||
| if (executionError === undefined) { | ||
| const operationResults: ReadonlyMap<Operation, IOperationExecutionResult> = | ||
| collectSummaryResults(options); | ||
| _printOperationStatus(terminal, { | ||
| operationResults, | ||
| status: getSummaryStatus(operationResults, options.warningsAllowedByEnvironment) | ||
| }); | ||
| terminal.writeLine(`rush ${commandName} (${duration})`); | ||
| } else { | ||
| terminal.writeErrorLine(`rush ${commandName} - Errors! (${duration})`); | ||
| } | ||
| provider.flush(); | ||
| } | ||
|
|
||
| function collectSummaryResults( | ||
| options: IWritePhasedRequestSummaryOptions | ||
| ): ReadonlyMap<Operation, IOperationExecutionResult> { | ||
| const { activeOperations, graph, sink } = options; | ||
| const active: ReadonlySet<Operation> = new Set(activeOperations); | ||
| const results: Map<Operation, IOperationExecutionResult> = new Map(); | ||
| // Iterate the graph so the summary lists operations in the same order as the native summary. | ||
| for (const operation of graph.operations) { | ||
| if (!active.has(operation) || operation.runner?.silent !== false) { | ||
| continue; | ||
| } | ||
| const observed: IOperationExecutionResult | undefined = | ||
| sink.getObservedResult(operation)?.executionResult; | ||
| if (observed && !observed.silent) { | ||
| if (SUMMARIZED_STATUSES.has(observed.status)) { | ||
| results.set(operation, observed); | ||
| } | ||
| continue; | ||
| } | ||
| // A silent observed record belongs to an operation the graph disabled because it was already up to date. | ||
| const previous: IOperationExecutionResult | undefined = | ||
| observed ?? graph.resultByOperation.get(operation); | ||
| if (previous) { | ||
| results.set(operation, createUpToDateResult(previous)); | ||
| } | ||
| } | ||
| return results; | ||
| } | ||
|
|
||
| function createUpToDateResult(previous: IOperationExecutionResult): IOperationExecutionResult { | ||
| // The summary only reads these members for skipped operations; the shared record itself must not change. | ||
| const upToDate: Pick<IOperationExecutionResult, 'operation' | 'silent' | 'status' | 'stopwatch'> = { | ||
| operation: previous.operation, | ||
| silent: false, | ||
| status: OperationStatus.Skipped, | ||
| stopwatch: previous.stopwatch | ||
| }; | ||
| return upToDate as IOperationExecutionResult; | ||
| } | ||
|
|
||
| function getSummaryStatus( | ||
| results: ReadonlyMap<Operation, IOperationExecutionResult>, | ||
| warningsAllowedByEnvironment: boolean | ||
| ): OperationStatus { | ||
| let status: OperationStatus = OperationStatus.Success; | ||
| for (const [operation, result] of results) { | ||
| switch (result.status) { | ||
| case OperationStatus.Failure: | ||
| case OperationStatus.Blocked: | ||
| return OperationStatus.Failure; | ||
| case OperationStatus.Aborted: | ||
| status = OperationStatus.Aborted; | ||
| break; | ||
| case OperationStatus.SuccessWithWarning: | ||
| if ( | ||
| status === OperationStatus.Success && | ||
| !warningsAllowedByEnvironment && | ||
| !operation.runner?.warningsAreAllowed | ||
| ) { | ||
| status = OperationStatus.SuccessWithWarning; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| return status; | ||
| } | ||
|
|
||
| /** Matches the native Rush stopwatch format, for example `1.23 seconds` or `2 minutes 3.4 seconds`. */ | ||
| function formatDuration(elapsedMs: number): string { | ||
| const totalSeconds: number = elapsedMs / MILLISECONDS_PER_SECOND; | ||
| if (totalSeconds > SECONDS_PER_MINUTE) { | ||
| const minutes: number = Math.floor(totalSeconds / SECONDS_PER_MINUTE); | ||
| const seconds: number = totalSeconds % SECONDS_PER_MINUTE; | ||
| return `${minutes.toFixed(0)} minute${minutes === 1 ? '' : 's'} ${seconds.toFixed(1)} seconds`; | ||
| } | ||
| return `${totalSeconds.toFixed(2)} seconds`; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.