-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Set up SwiftLint as a standalone build plugin #23996
base: mokagio/remove-cocoapods-christmast-branch
Are you sure you want to change the base?
Set up SwiftLint as a standalone build plugin #23996
Conversation
…thenticatedImageDownload redirect)
This reverts commit 3e41f0c8024c0e871653a52c1240749bbd489787.
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
There's a problem with the Docker image and version 0.58.1: ``` Digest: sha256:0a86399eb15ab7d3e9535f38df6f3f443aad1efde3cba9ff5ee34a3d226386e9 [2025-01-21T09:34:29Z] Status: Downloaded newer image for ghcr.io/realm/swiftlint:0.58.1 [2025-01-21T09:34:31Z] warning: Currently running SwiftLint 0.58.0 but configuration specified version 0.58.1. ``` https://buildkite.com/automattic/wordpress-ios/builds/25472#01948835-83d4-47b2-b177-40ba3bf2d5a8
8df602d
to
f692687
Compare
@@ -33,8 +33,7 @@ public extension NSAttributedString { | |||
if | |||
displayAnimatedGifs, | |||
let animatedImage = image as? AnimatedImage, | |||
animatedImage.gifData != nil | |||
{ | |||
animatedImage.gifData != nil { |
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.
Moving up from version 0.54.0 brought up this and other opening_brace
violations.
Might be related to the rule having been rewritten in version 0.55.0 and then updated in version 0.57.0.
@@ -1,10 +1,11 @@ | |||
swiftlint_version: 0.54.0 | |||
swiftlint_version: 0.58.2 |
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.
We cannot use 0.54.0
because it's not available as a built tool plugin, see https://github.com/SimplyDanny/SwiftLintPlugins/releases
Given that, it makes sense to use the latest available version. But even if we didn't want to:
- 0.58.0 and 0.58.1 have a bug where the Docker image reads the wrong version, so we cannot use them
- 0.55.0 does not have the
--working-directory
option which we need
This reverts commit 9da124f. When run via the plugin, SwiftLint consistently fails to fetch the remote configuration. See https://buildkite.com/automattic/wordpress-ios/builds/25484#01948b50-ee3b-4e18-a2a8-1555071c933c
This way, we'll be able to add additional checks without messing up the project file.
af75c45
to
db78e12
Compare
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 a bit of an argument from authority, which is why I'm leaving it last and using it more as a reinforcement of my conclusion than an explanation, but realm/SwiftLint#5207 (comment)
I concur. It should be used only when the code requires a tool to compile – mainly code generators.
@@ -0,0 +1 @@ | |||
.build |
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'd add it to the .gitignore file in the root directory.
name: "BuildTools", | ||
platforms: [.macOS(.v10_13)], | ||
dependencies: [ | ||
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: loadSwiftLintVersion()), |
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.
Does the version numbers have to be in .swiftlint.yml
? Are there any other roadblocks for simply defining the version here in the package:
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: "0.58.2"),
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.
.swiftlint.yml
needs to specify the SwiftLint version the configuration expects
We don't have to read the version from there here, but I find it nice to have a single source of truth.
We could duplicate the value here, but we might run into some annoying issues if the version defined here diverges from the one in the config so that we end up with CI running a different version than local and giving different feedback.
5189e4b
to
d7d0010
Compare
#23958 removes CocoaPods from the project setup, but with SwiftLint also goes away.
This PR re-introduces SwiftLint, fetching it using the SwiftPM plugin repo but then calling the binary directly via the existing SwiftLint aggregate target (which calls
rake lint
under the hood.I considered using the plugin setup, see #23990, but didn't go ahead with it because:
For reference, this setup is inspired by SwiftFormat.
I considered fetching SwiftLint directly instead of the plugin, but doing so would have required compiling SwiftLint from source to run it, which was very time consuming.
Finally, it crossed my mind to keep the old CocoaPods setup for SwiftLint. I started going down that path in #23998 but stopped once I noticed that the performance using the setup in this PR were comparable to those on
trunk
, see #23999Given that removing CocoaPods whether to build the app or for tooling, brings us closer to our goal of no longer depending on Ruby for product-development tasks, I'd rather stick with this Swift-only approach.
Note
I'm having issues archiving the app via Fastlane, even though
vanillaand Xcode work fine. I'm investigating...xcodebuild
Apart from being unsure about the error itself, I don't understand is how the changes in this PR might be affecting the build that way...
Updated I haven't fixed the issue but I have a workaround that I like and that I think we should consider in order to merge this PR and then move forward with #23958
The TL;DR is that the error occurs only when building builds with configuration Release or Release-Alpha, so I told the script that runs SwiftLint to only run on Debug builds. We have CI covering us when building a different configuration because it runs the standalone linter. In fact, I also disabled the SwiftLint build phase in CI, to save time because of that.
Regression Notes
PR submission checklist:
RELEASE-NOTES.txt
if necessary. N.A.UI changes testing checklist: Not a UI PR.