-
Notifications
You must be signed in to change notification settings - Fork 28
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
Streamline the swiftly init process #177
base: main
Are you sure you want to change the base?
Conversation
cmcgee1024
commented
Oct 20, 2024
•
edited
Loading
edited
Add a design proposal for the new swiftly proxy system
…ocation clarify the boundaries of the swiftly toolchain abstraction and elaborate on how to work around them
…new swiftly run command
Change the nature of the swiftly symlinks so that they point to the swiftly executable at install time. These do not change when new toolchains are used. Toolchain selection happens each time when the proxies are run. The proxies are created for a well-known set of toolchain binaries that are constant for a wide variety of toolchain versions and platforms. Add support for .swift-version files for toolchain selection. Update the use command so that it can point out which toolchain is in use based on context, such as swift version files that are located in the current working directory or above. The fallback selection comes from the global default configuration's 'inUse' setting. When querying for what's in use the global default is shown with the "(default)" tag. If the in-use toolchain is selected by a swift-version file the path to that file is displayed. Provide a print location flag to the use subcommand that can print the file path of the toolchain that is in use in the current context. When using a new toolchain, depending on whether a swift version is selecting the current one, update the swift version file with the selected toolchain version. If no swift version file can be located, attempt to create a new one at the top of the git worktree. If there is no git worktree, then fallback to updating the global default in the configuration. Provide a global default flag for the use subcommand so that only the global default in-use toolchain is considered and not any of the swift version files.
…esult and centralized error messages
Provide a run command that allows arbitrary commands to be run in the context of the selected toolchain. Provide a one-off selection mechanism with a special syntax on the run command.
With no arguments the install subcommand will install the currently selected toolchain from the `.swift-version` files.
…swiftly install`. Guard automatic creation of .swift-version file from `swiftly use` around a prompt overridable using an `--assume-yes`. Minor cleanup
Fix all of the swift.org urls so that they use www.swift.org to avoid redirection
Fix symlink target selection for swiftly when it is system managed
Print the error in a better way
Add support for these new platforms to swiftly, the autodetection, the tests, and docker support. Remove the swiftly installer portion of the code.
@swift-ci test macOS |
macOS tests are passing:
|
…x/macOS and hide platform-specific details
…ly into streamlined_init
@swift-ci test macOS |
@swift-ci test macOS |
Provide more verbose untarring messages in Linux behind the verbose flag
@swift-ci test macOS |
@swift-ci test macOS |
|
||
``` | ||
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason we can't offer the script as an alternative? Removing it completely makes install Swiftly and Swift a reasonably amount more complicated as it puts the onus on the user to work out what OS and architecture they're using, which they can get wrong and make it seem like Swift doesn't work.
Additionally this makes building tooling on top of Swiftly significantly more complicated and each tool has to do the same logic of working out what system it's running on and going to find the correct binary which is a lot of duplicated work. It would be good to have that centralised in the tool.
Finally, this reduces the 'copy and paste this one line' installation for Swift that we have had up to now, making the experience on installing Swift on different systems a step back IMO compared to say rustup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are number of ways that we're hoping to address these as we can't use a curl | bash
approach.
For the regular user install workflow, the website can help to find them the most likely swiftly download candidate for their OS and architecture. More details can be found in the PR here: swiftlang/swift-org-website#830
We can also add a very short guide to help them on the next steps. Feedback is welcome on that PR.
The download for macOS brings them to the pkg installer for the easy flow. It can also be invoked headlessly on the command-line either in a system directory or the user's home directory. Details are in the docs.
Since swiftly is a Linux binary that can work on a wide variety of Linux distributions, it takes on the responsibility of Linux flavour detection, and configuration. The user needs only to untar it and run swiftly
wherever it is to continue.
For automated systems, there's a document here that goes over how one would automatically install swiftly. Feedback is welcome on this document as part of a separate PR/issue: https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/automated-install
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the slightly longer term, there is also the possibility of providing swiftly in system package managers to make this even easier. Swiftly is able to be run from a system location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are number of ways that we're hoping to address these as we can't use a curl | bash approach.
We can no longer use the install script for some reason? I agree with Tim that the one liner approach seems a bit more user friendly as it handles environment detection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in the near term the website can do much to ease the new user flow to compensate, such as making sure that they have the right executable, escape hatch to the full list of executables. The URL when it's finally decided for the website, can be made to be friendly to uname -m
and uname -s
. System packages of swiftly will be an accelerator as well, once they are available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what's the actual reason "we can't use a curl | bash
approach"? I fully support the plan to offer an executable that does more work and make it possible to install without requiring a shell script, but removing it all together as an option feels like a step backwards
@swift-ci test macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the commit history looks like it needs to be cleaned up a bit post proxy merge
|
||
``` | ||
curl -L <trusted_location_of_swiftly> > swiftly | ||
curl -L <location_of_swiftly_swift_org> > swiftly.tar.gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
location_of_swiftly_swift_org
Does this exist? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will once these website update PR's are merged with a released version of swiftly:
swiftlang/swift-org-website#828
swiftlang/swift-org-website#830
|
||
``` | ||
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are number of ways that we're hoping to address these as we can't use a curl | bash approach.
We can no longer use the install script for some reason? I agree with Tim that the one liner approach seems a bit more user friendly as it handles environment detection
$ swift --version | ||
|
||
Swift version 5.8.1 (swift-5.8.1-RELEASE) | ||
Swift version 6.0.1 (swift-6.0.1-RELEASE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few lines down the doc references swift build
with a commend saying latest (5.8.1) toolchain
, probably just want to update that comment to 6.0.1 too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can raise another PR to fresh the version numbers in the documentation, or make them more version independent. Suggestions are welcome on how best to handle this problem of balancing accuracy and maintainability.
Sources/SwiftlyCore/Platform.swift
Outdated
return swiftlyHomeBin | ||
} | ||
|
||
if installSwiftly { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the code that installs swiftly, yeah, and it's wrapped around a single boolean which changes the purpose of this method, should it just be its own method? We would essentially have:
findSwiftlyBin
installSwiftly
Not a huge deal, just tripped me up when reviewing. Totally up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I couldn't find a good abstraction, so maybe this deserves to have two similar functions beside each other for the locality of change, at least.
Co-authored-by: Justice Adams <[email protected]>
On this project I've tended to keep the full and ugly truth of the PR commit history because GitHub doesn't handle force pushes very well, and sometimes comments and their context gets fully lost. I try to compensate for this by most often using the squash and merge function when the PR is complete so that the main branch history is much cleaner. |
@swift-ci test macOS |
@swift-ci test macOS |
…recting to swiftly init subcommand
@swift-ci test macOS |