Skip to content

WIP: New and user selectable progress bars #7897

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rauhul
Copy link
Member

@rauhul rauhul commented Aug 20, 2024

this is very much a work in progress. It works enough to be helpful locally for myself.

Screen.Recording.2024-08-20.at.9.52.03.AM.mov

TODO:

  • Handle % based tasks
  • Use milliseconds for tasks with 0 full seconds
  • refactor user text interleaving with progress animation (closure based api)
  • Make "Write sources" tasks display name be more informational
  • Indicate host vs target in task name

Larger example output, the new progress bar makes it really easy to see duplicate work:
Screenshot 2024-08-20 at 10 23 50 AM

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Aug 20, 2024

I wonder if it would make sense for items that end up rounded as "0s" to drop down to milliseconds instead? Otherwise 0s doesn't seem believable on its own, and a lot of "0s" can accumulate to a substantial number, which also would be confusing.

@rauhul
Copy link
Member Author

rauhul commented Aug 20, 2024

I wonder if it would make sense for items that end up rounded as "0s" to drop down to milliseconds instead? Otherwise 0s doesn't seem believable on its own, and a lot of "0s" can accumulate to a substantial number, which also would be confusing.

Probably! I'd love feedback and suggestions :D

@MaxDesiatov MaxDesiatov added swift test Changes impacting `swift test` tool swift build Changes impacting `swift build` command-line interface labels Aug 20, 2024
@dschaefer2
Copy link
Member

I wouldn't mind some of this now like the number of sources and compile durations. Is it easy to separate into a smaller PR?

@dschaefer2
Copy link
Member

dschaefer2 commented Aug 20, 2024

Also can we show whether something is compiling as a tool (host) or destination (target)?

(update: never mind, we build the plug-in tools before we do the production build, sigh).

@neonichu
Copy link
Contributor

Side note: should the "Write sources" tasks display name be more informational?

@rauhul
Copy link
Member Author

rauhul commented Aug 20, 2024

Side note: should the "Write sources" tasks display name be more informational?

I'd consider that a "full note"!

@rauhul
Copy link
Member Author

rauhul commented Aug 20, 2024

Also can we show whether something is compiling as a tool (host) or destination (target)?

(update: never mind, we build the plug-in tools before we do the production build, sigh).

It still useful because we build swift-syntax for the host (for macros) as part of the real build.

@rauhul
Copy link
Member Author

rauhul commented Sep 11, 2024

@dschaefer2 @MaxDesiatov ms in the time and a more descriptive task name for some write-aux-file tasks.

Screenshot 2024-09-10 at 7 04 22 PM

@rauhul
Copy link
Member Author

rauhul commented Sep 11, 2024

oops I meant to ping @neonichu not Doug 😓

@bkhouri
Copy link
Contributor

bkhouri commented Sep 11, 2024

This looks nice. Would it be possible to add some automated tests to validate the expected behaviour? This way, we will ensure the feature does not regress.

@dschaefer2
Copy link
Member

This looks nice. Would it be possible to add some automated tests to validate the expected behaviour? This way, we will ensure the feature does not regress.

Rauhul and I chatted about this today. We acknowledged the need but also the difficulty writing tests for it. Maybe we can get some help with that. Do we have tests for the current progress messages?

@Sajjon
Copy link

Sajjon commented Sep 12, 2024

@rauhul nice! Progress bar for building and progress bar for Swift Testing could/should most likely share implementation - a generic implementation of the CLI based GUI for displaying and updating some progress bars - with the difference being the event stream of updates.

Swift Testing does not have SPM as dependency in Package.swift though, hmm, perhaps a new Swift package for displaying progress in CLI could be created and added as a dependency to both Swift Testing and SPM?

@plemarquand
Copy link
Contributor

This is very cool! I am a big fan of making progress related output more informative and fun, since I think we all spend a good amount of our time looking at it.

That said, I think there are some use cases and nuances to keep in mind. @stmontgomery and @grynspan raised some interesting comments on @Sajjon's swift-testing progress bar patch that I think apply here as well:
swiftlang/swift-testing#19 (comment)
swiftlang/swift-testing#19 (comment)

The relevant bullet points from their comments:

  • We need to make sure that output is legible when written to something like Jenkins or a plain text file
  • What do warnings and errors look like (stderr output)?
  • Need to ensure this is tested and functional on macOS' Terminal.app, Ubuntu's Terminal, pure-CLI Linux, and Windows' modern Console.

@grynspan
Copy link
Contributor

With @plemarquand's notes in mind, I'd love to get this all packaged up somewhere that Swift Testing could link to it and use it too. :)

@dschaefer2
Copy link
Member

There are other use cases I know that could use good terminal progress animation in a Swift package such as swift-testing. I'd like to see turning this into that as a long term goal.

Also this is an optional view of progress. I think we still need the old one around for tools that depend on it. vscode-swift currently is one of those tools. But talking with @award999, we'd probably be better off with that interface being a streaming machine interface rather than trying to parse human consumable output. We need to be free to make changes to improve human consumption, like we are here.

@rauhul rauhul force-pushed the rauhul/blast-progress-bar branch from e974a4d to f3891a5 Compare September 12, 2024 17:29
@hassila
Copy link

hassila commented Sep 12, 2024

I'd definitely also would be interested in consider using it for the Benchmark package if it's broken out to a separate dependency in the future.

@rauhul rauhul force-pushed the rauhul/blast-progress-bar branch from f3891a5 to 1f9da2e Compare May 12, 2025 15:48
Copy link

@Sajjon Sajjon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Any recordings of the various animations? I'm curious about Ninja and Blast :)

}
}

class BlastProgressAnimation {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this class can be final?

}
progressAnimation.update(step: step, total: 100, text: message)
progressAnimation.complete("Build complete!")
// case .didUpdateProgress(let progressInfo):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

@@ -260,12 +263,14 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
let parameters = try self.makeBuildParameters()
let derivedDataPath = self.buildParameters.dataPath.pathString

let progressAnimation = ProgressAnimation.percent(
// Figure out which progress bar we have to use during the build.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing TODO? Or is comment obsolete?

self.onTaskProgressUpdateText?(text, targetName)
if let task = self.progressText(of: message, targetName: targetName) {
self.swiftTaskProgressTexts[info.pid] = task
// self.progressAnimation.update(id: info.pid, name: task, event: .discovered, at: time)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

self.swiftTaskProgressTexts[info.pid] = nil
if let task = self.swiftTaskProgressTexts[info.pid] {
swiftTaskProgressTexts[info.pid] = nil
// self.progressAnimation.update(id: info.pid, name: task, event: .completed(.succeeded), at: time)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

progressTracker.buildStart(configuration: configuration)
progressTracker.buildStart(
configuration: configuration,
action: "Building")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we might benefit from a:

extension String {
    static let building: Self = "Building"
}

and use that instead of "Building" String literal in many places?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would want to use an enum conforming to CustomStringConvertible rather than extending a currency type like String.

if env.runningInXcode { return .noColors }
// Disabled colors because output stream is not a tty, CI == nil,
// and CLICOLOR_FORCE == nil.
// FIXME: dont use stream.isTTY
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any resolution for this FIXME? Any suggestions for improvement?

//===----------------------------------------------------------------------===//

// FIXME: use task tree
//struct ProgressTask {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line interface swift build Changes impacting `swift build` swift test Changes impacting `swift test` tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants