One Script to rule them all
Closed this issue · 6 comments
Description
If one is making changes to Swift syntax by updating CodeGeneration
(or in any other way), and one wants to ensure that all changes have been implemented correctly, all tests are passing, and none of the packages are throwing warnings or errors, has to follow these steps:
- Run the
generate-swift-syntax
executable. - Run unit tests for the
CodeGeneration
package. - Run unit tests for the
swift-syntax
package. - Run unit tests for the
Examples
package. - Build the
EditorExtension
project. - Once PR #2063 is merged, build the
SwiftParserCLI
to ensure no warnings or errors have been added. - Run
swift-format
.
Only after completing all these steps, one can be sure that the newly added changes don't impact other parts of the repository.
I find it beneficial to prepare a Swift script that will automate these actions, eliminating the need to remember them all. Running such a script might take a while, so it's probably more useful to do a final check before submitting a PR rather than running it after every change but still I believe it would be cool to have something to rule them all 😇
Let me know what you think about this idea.
By the way, if the title is inappropriate, feel free to change it. I couldn't resist using this reference 🙈
Tracked in Apple’s issue tracker as rdar://113920485
I think adding such an action to the new SwiftSyntaxDevUtils
package would be a very good idea.
Some (hopefully relevant) context that I've learned about how we currently do soundness check in Swift opensource projects:
In apple/swift-nio#2242, @FranzBusch prototyped a Swift Package Manager plugin that would implement a soundness.sh
that checks licensing and formatting for SwiftNIO.
SwiftNIO has soundness.sh
that's pretty consistent with other SSWG projects, but sometimes there are one-off changes, like the one I made in apple/swift-metrics#134 in swift-metrics
because the original soundness.sh
fails silently with exit code 0 if swiftformat
was not installed. It also does not enforce a specific version of swiftformat.
The formatting that we're using in swift-syntax
is different from what SSWG projects use: both the configuration (2 spaces indentation instead of 4), and the tool (SSWG uses SwiftFormat, swift-syntax
uses apple/swift-format
).
I love the idea of having the checks consolidated in a single script or a SwiftPM plugin (that's perfect!) in a single repository instead of being copied over. But it looks like for SSWG projects, it's not clear where exactly to put the script, and who will then own and maintain it. Obviously, I'm missing a lot of context about this, being a beginner contributor.
I'm also not sure if there is a long-term plan to switch all SSWG repositories to use swift-format
.
But, I would love to keep an eye on this and participate in this work — @Matejkob, please let me know if I can help you in any way. Perhaps we could prototype it for swift-syntax
first, and see how to pitch that to other projects?
@natikgadzhi, thank you for your input on this issue. I'm not sure if I've fully conveyed the idea I have in mind in the issue description. So perhaps it would be best if I drafted a PR, and we could continue the discussion there. Personally, I find it much easier to discuss things through code rather than just words. 😄
@kimdv, would you mind assigning me to this issue?