norio-nomura / action-swiftlint

GitHub Action for SwiftLint
MIT License
370 stars 58 forks source link

Add optional WORKING_DIRECTORY environment variable and fix test run (#33) #34

Closed m-herold closed 3 years ago

m-herold commented 3 years ago

Add an optional WORKING_DIRECTORY environment variable which allows to run this GitHub action in a subdirectory (i.e., in case your code and .swiftlint.yml configuration file do not reside in the root of your repository). These changes also work in combination with the DIFF_BASE environment variable.

This pull request also fixes the test run, since with SwiftLint version 0.41.0, SwiftLint has also changed the exit status on warnings in case you are using the --strict option (https://github.com/realm/SwiftLint/pull/3372/files#diff-5b9fa80336289abd42b297396f8eceb078430b385bd97439cb720a46896f4cefR65).

Please note: this was not necessary prior to SwiftLint version 0.41.0. With that version SwiftLint has changed the calculation of the root path when a directory in the tree is passed as path argument.

Prior to this version it was possible to define a path argument, whereas SwiftLint then took the config file and all excluded files relative to this path argument. This seems to have changed, whereas this awesome GitHub action does not work properly anymore in the case (a) your source code is not located in the root folder of your repository, and (b) you have defined excluded files/path in a configuration file which are relative to this source code folder (e.g., to be used within an Xcode build phase). In those cases this GitHub action can not be used anymore, due to the following changes of SwiftLint:

realm/SwiftLint@6d77deb

For further details please see #33.

norio-nomura commented 3 years ago

Thanks for contribution!

Add an optional WORKING_PATH environment variable…

The actual change uses WORKING_DIRECTORY, but I think the change should be as it is, similar to the working-directory used in GitHub Actions.

m-herold commented 3 years ago

Good point! I updated the PR title and description. Thanks!

norio-nomura commented 3 years ago

Thanks! 🙏