swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.72k stars 1.34k forks source link

WIP: New and user selectable progress bars #7897

Open rauhul opened 1 month ago

rauhul commented 1 month ago

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

https://github.com/user-attachments/assets/710d1fcb-4b33-405b-89ff-aff2a992b7cb

TODO:

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 commented 1 month ago

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 commented 1 month ago

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

dschaefer2 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

rauhul commented 1 month ago

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

I'd consider that a "full note"!

rauhul commented 1 month ago

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 commented 3 weeks ago

@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 commented 3 weeks ago

oops I meant to ping @neonichu not Doug 😓

bkhouri commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

@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 commented 2 weeks ago

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: https://github.com/swiftlang/swift-testing/pull/19#issuecomment-1735768717 https://github.com/swiftlang/swift-testing/pull/19#issuecomment-1733909628

The relevant bullet points from their comments:

grynspan commented 2 weeks ago

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 commented 2 weeks ago

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.

hassila commented 2 weeks ago

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.