Skip to content

Integrate SwiftFormat into the swiftly project dependencies #158

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
merged 3 commits into from
Aug 26, 2024

Conversation

cmcgee1024
Copy link
Member

The SwiftFormat that is run in the CI is a very specific version that is unlikely to be the one a dev has installed with homebrew or discovered for themselves and built from source. Discovering the version involves finding the magic in the lint.dockerfile.

SwiftPM provides a mechanism for bringing in product dependencies so that you can simply run using the toolchain. The dependencies can be specified using an exact match on a particular version. These products from the dependencies can be discovered using the swift package describe command, and perhaps someday Swift devs will discover a package's dev tools in this way.

Add the SwiftFormat dependency as a package dependency in swiftly at the version that is currently used in the soundness CI checks. Use the the swift command to invoke the 'swiftformat' product from the dependency instead of manually git cloning and building it manually in the dockerfile.

Provide a rationale for the dependency in the Package.swift for anyone who is curious about it.

The SwiftFormat that is run in the CI is a very specific version
that is unlikely to be the one a dev has installed with homebrew
or discovered for themselves and built from source. Discovering
the version involves finding the magic in the lint.dockerfile.

SwiftPM provides a mechanism for bringing in product dependencies
so that you can simply run using the toolchain. The dependencies
can be specified using an exact match on a particular version.
These products from the dependencies can be discovered using the
`swift package describe` command, and perhaps someday Swift devs
will discover a package's dev tools in this way.

Add the SwiftFormat dependency as a package dependency in swiftly
at the version that is currently used in the soundness CI checks.
Use the the swift command to invoke the 'swiftformat' product from
the dependency instead of manually git cloning and building it
manually in the dockerfile.

Provide a rationale for the dependency in the Package.swift for
anyone who is curious about it.
@cmcgee1024
Copy link
Member Author

@swift-ci test macOS

@cmcgee1024
Copy link
Member Author

@swift-ci test macOS

@rauhul
Copy link
Member

rauhul commented Aug 23, 2024

Given that swiftly is now part of Swiftlang, it would be good to adopt swift-format

@cmcgee1024
Copy link
Member Author

Given that swiftly is now part of Swiftlang, it would be good to adopt swift-format

Yes, that makes sense. I've raised an issue to track that since there's more work involved than this PR can cover: #159

@cmcgee1024
Copy link
Member Author

@swift-ci test macOS

@cmcgee1024 cmcgee1024 marked this pull request as ready for review August 23, 2024 20:15
@adam-fowler
Copy link
Contributor

Is there any point doing this if the eventual plan is to move swift-format?

@cmcgee1024
Copy link
Member Author

Is there any point doing this if the eventual plan is to move swift-format?

I think that moving to swift-format is something that we need to do, but it will take some effort.

An immediate problem that I hit is that I need to have the SwiftFormat repo checked out at the exact right version to run the formatter before I commit. With this change I can have certainty that when I run the formatter it will be in the exact same version and configuration as the soundness check in CI.

Also, consolidating the formatter into the project configuration is a stepping stone to switching the version of the formatter, and even switching formatters to swift-format.

@cmcgee1024 cmcgee1024 merged commit a7ef9e8 into swiftlang:main Aug 26, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants