[action][swiftlint] Fix path option for SwiftLint 0.48.0 and above#30080
Conversation
SwiftLint removed the `--path` flag in 0.48.0, so `swiftlint(path:)` failed with `Unknown option '--path'` on newer versions. The action now passes the path as a positional argument for SwiftLint 0.48.0 and above, while still emitting `--path` for older versions.
There was a problem hiding this comment.
Pull request overview
This PR updates the swiftlint action to remain compatible with SwiftLint 0.48.0+, where the --path flag was removed and paths must be passed positionally.
Changes:
- Version-gates how
pathis passed to SwiftLint (--path <path>for < 0.48.0; positional<path>for >= 0.48.0). - Adds specs covering the new positional path behavior and shell-escaping for paths containing spaces.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| fastlane/lib/fastlane/actions/swiftlint.rb | Adds path_argument helper and switches path handling based on SwiftLint version. |
| fastlane/spec/actions_specs/swiftlint_spec.rb | Adds new specs for SwiftLint >= 0.48.0 positional path behavior and escaping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
thanks! Added Copilot and edited a few more bugs/PRs to close on merge of this. |
Addresses review feedback: SwiftLint usage is `lint [<options>] [<paths> ...]`, so the positional path must come after the option flags. Adds a spec asserting path ordering relative to --strict.
Addresses review feedback: append the positional path in run() after the --use-script-input-files flag so it stays the last swiftlint argument when both :path and :files are used. Adds a spec covering that ordering.
There was a problem hiding this comment.
Hey @augustocbx 👋
Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a month, and your PR will be included in the next one.
Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀"
There was a problem hiding this comment.
Congratulations! 🎉 This was released as part of fastlane 2.237.0 🚀
🔑
Checklist
bundle exec rspecfrom the root directory to see all new and existing tests passbundle exec rubocop -ato ensure the code style is validci/circlecibuilds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
Resolves #22191
Resolves #22063
Closes #22124
SwiftLint deprecated the
--pathflag in 0.48.0 and newer releases reject it outright, so any lane usingswiftlint(path: ...)fails withError: Unknown option '--path'.Description
The
swiftlintaction always appended--path <path>to the command, regardless of the installed SwiftLint version. Since SwiftLint replaced--pathwith a positional path argument in 0.48.0, the emitted command became invalid on current SwiftLint installs.The action now version-gates how the path is passed: it keeps
--path <path>for SwiftLint below 0.48.0 and passes the path as a positional argument (swiftlint lint <path>) for 0.48.0 and above. Existing behavior for older versions is unchanged, and the path is still shell-escaped in both cases.Testing Steps
bundle exec rspec fastlane/spec/actions_specs/swiftlint_spec.rbbundle exec rubocop fastlane/lib/fastlane/actions/swiftlint.rb fastlane/spec/actions_specs/swiftlint_spec.rbNew specs assert that for SwiftLint 0.48.0 and above the command is
swiftlint lint <path>(no--path) and that spaces in the path are still escaped. The existing example pinning--pathfor older versions remains green.