In the last couple of weeks, we have made changes to the Swift testing infrastructure that allow testing dependent projects of SwiftSyntax without needing to rebuild SwiftSyntax. As a result, it would now be possible to test swift-format as part of the Swift CI testing infrastructure.
Integrating swift-format with the Swift CI infrastructure would allow PR testing on the apple/swift-format repository. Additionally, swift-format would be tested as part of Swift’s continuous integration jobs, ensuring that no change to the master branch of SwiftSyntax or the Swift compiler will break the master branch of swift-format.
The integration comes with the expectation that developers of swift-format take active part in fixing CI issues in a timely manner. Because of this, we leave it up to you to decide when and if the CI integration should be pushed forward. I have composed a list of the items below that need to be done in order to get the CI integration working:
- Update swift-format to depend on SwiftSyntax’s master branch
- Make all
@testable
imports in swift-format’s test normal imports, making all necessary types and methodspublic
[1] - Depend on local dependencies if the
SWIFTCI_USE_LOCAL_DEPS
environment flag is specified - Add a
build-script-helper.py
script to the package which can be invoked by thebuild-script
in the main Swift repository- See swift-stress-tester/build-script-helper.py at main · apple/swift-stress-tester · GitHub as an example
- Only the
build
andtest
actions need to be supported - Particularly the
SWIFTCI_USE_LOCAL_DEPS
environment variable needs to be specified when invokingswift build
. Furthermore, the--multiroot-data-file
option must be passed toswift build
- Add
swift-format
as a product to Swift’sswift_build_support
- See https://github.com/apple/swift/blob/master/utils/swift_build_support/swift_build_support/products/skstresstester.pyas an example. The install phase should not be supported for now, installing swift-format in the toolchain can be discussed after CI integration has been implemented
- Additionally, the correct command line flags need to be added to
build-script
. See Move stress tester and swiftevolve to new swift_build_support build infrastructure by ahoppen · Pull Request #27580 · apple/swift · GitHub for an example of which flags to add
- Create a preset for PR testing in the swift-format repository
- See Move stress tester and swiftevolve to new swift_build_support build infrastructure by ahoppen · Pull Request #27580 · apple/swift · GitHub for an example of a macOS preset and [build-presets] Add preset for testing SwiftSyntax on Linux by ahoppen · Pull Request #28094 · apple/swift · GitHub for a example of a Linux preset
- Let us know that you have completed the above steps, so swift-format can be added to the checkout on the CI bots and CI testing for the swift-format repository can be enabled
- After verifying that the CI works on the swift-format repository using a dummy PR, update the presets to test swift-format as a downstream dependency of SwiftSyntax
- As a starting point, it would be a good idea to test it everywhere
swift-evolve
is being tested - If
swift-format
should also be tested on Linux, it needs to be added to the corresponding Linux bots as well
- As a starting point, it would be a good idea to test it everywhere
[1] We are only building SwiftSyntax once without testability enabled, because that’s the version we are installing in the toolchain. SwiftPM does not support building targets with different build configurations, so we cannot build swift-format with testability enabled.
CC @allevato