-
Notifications
You must be signed in to change notification settings - Fork 282
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
feat: SPM(Swift Package Manager) backend #2241
Conversation
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.
Logic-wise it looks prefect. Nicely done @kattouf.
impl SwiftPackageRepo { | ||
fn new(name: &str) -> Result<Self, eyre::Error> { | ||
let shorthand_regex = regex!(r"^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$"); | ||
let shorthand_in_url_regex = |
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.
Would it make sense to generalize this such that it also supports other Git platforms, for example Gitlab?
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.
Yes, it makes sense globally, I just decided not to spend too much time on unpopular cases right now.
I think we could cover almost everything else cases by implementing:
- support for any URLs up to
.git
- support for various git revisions as versions: tag, commit, branch
and divide the versioning flow into:
- github releases
- specific git revision
But is it worth doing this right away, I'm not sure
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 this can be done in a follow-up PR. It seems a good candidate to be extracted into a separate function that can be reused across the backend. I'm sure @jdx has already put some thoughts there.
struct PackageDescriptionProduct { | ||
name: String, | ||
#[serde(deserialize_with = "PackageDescriptionProductType::deserialize_product_type_field")] | ||
r#type: PackageDescriptionProductType, |
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.
Out of curiosity, what's the meaning of this r#type
annotation? (I'm not that versed at Rust)
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's raw identifier
, used to define user data names, same as language keywords (like `type` in swift)
https://stackoverflow.com/a/69871965
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.
Gotcha! Thanks for the reference to Swift, it helped :)
mise use swift | ||
|
||
assert "mise x spm:nicklockwood/[email protected] -- swiftformat --version" "0.53.10" | ||
assert "mise x spm:https://github.com/nicklockwood/[email protected] -- swiftformat --version" "0.53.10" |
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.
Would you mind adding https://github.com/tuist/tuist?
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 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.
5m is terrible! So feel free to skip it then :)
Co-authored-by: Pedro Piñera Buendía <[email protected]>
@pepicrft Could you also check |
I'd be consistent with what the other backends do. If they install the required toolchain absent, we can error out telling users that "Swift was not found in the environment" until we install it ourselves. This is a scarce scenario because most developers using this backend will likely be Xcode developers with the toolchain available in their systems.
I'm in a similar spot here. At least on Linux, if everything is statically linked, the binary should work, so the issues will likely arise when using dynamic dependencies, which I'm not entirely sure are supported on Linux. Similarly, this is a bit uncommon, so I'd ship this as it is and iterate on it as feedback comes our way.
This is a bit confusing, especially considering that they are referring to the same package. @jdx might be able to help with this one. |
Currently
Agree 🤝 |
* first simple implementation * get executables list and work with them only * rename SpmForge -> SPMBackend * Package description deserialization with serde * copy build artifacts * refactoring * spm e2e tests * use project git client * refactoring * fix repo url name usage; fix git checkout * update test assert * fix lint violations * fix package version in e2e test * add spm repo parsing unit tests * Better error message Co-authored-by: Pedro Piñera Buendía <[email protected]> * reformat --------- Co-authored-by: Pedro Piñera Buendía <[email protected]>
Implementation of backend for install executables managed by Swift Package Manager
Description
Discussion
Compared to previous PR there are no dependencies on third parties other than Swift itself.
SPM does not support installing an executable, only the build command. This backend implementation itself covers this functionality and is described by a flow:
Package.swift
for a list of executablesmise
install directoryDemo screenshots:
P.S. I'm not full-time Rust developer, feel free to make comments if something is not done according to best practices in Rust community
Requires attention
swift
dependencyI had some problems installing
swift
with the current asdf plugin so I guess we'll just have to wait for Add Swift plugin #1708Now missed dependency leads to:
I have no experience using
swift
on other platforms (Linux, Windows) and can't be sure about finite list of resource and dynamic libraries formats we should support to copy together with binary.I decide dive into it after we are sure that everyone is happy with the feature and we will discuss merging it.
spm:nicklockwood/[email protected]
spm:https://github.com/nicklockwood/[email protected]
Maybe we should add other options by community requests
I got some errors when trying to change the BackendArg name to generic format (shortened) in
SPMBackend::new(name)
Are there any other options to solve this problem?
Current implementation looking for GitHub release tags for installation candidates. Installation by branch/commit can also be supported, but I'm not sure if this should be done now.