norio-nomura / action-swiftlint

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

Add PROJECT_PATH environment variable #24

Closed 123FLO321 closed 4 years ago

123FLO321 commented 4 years ago

This PR adds a PROJECT_PATH environment variable if you want to execute SwiftLint in different directory.

(also replace tabs with spaces in entrypoint.sh)

norio-nomura commented 4 years ago

Thanks for contribution! Wouldn't it work as expected with the following settings without this PR?

      - name: GitHub Action for SwiftLint
        uses: norio-nomura/action-swiftlint
        with:
          args: --path to/be/linted
123FLO321 commented 4 years ago

No because that then only lints that folder and will not use the paths specified in the .swiftlint.yml file.

norio-nomura commented 4 years ago

AFAIK, SwiftLint uses .swiftlint.yml in specified directory provided by --path. In following log, SwiftLint produces no violations with --path ../SwiftLint because ../SwiftLint/.swiftlint.yml has include setting, even though ../SwiftLint/Package*.swift contains violations:

$ head -3 ../SwiftLint/.swiftlint.yml
included:
  - Source
  - Tests
$ swiftlint lint --path ../SwiftLint --quiet
$ swiftlint lint ../SwiftLint/Package*.swift --quiet
/Users/norio/github/SwiftLint/Package.swift:21:1: warning: Line Length Violation: Line should be 120 characters or less: currently 131 characters (line_length)
/Users/norio/github/SwiftLint/Package.swift:20:90: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
/Users/norio/github/SwiftLint/Package.swift:28:34: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
/Users/norio/github/SwiftLint/Package.swift:35:23: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
/Users/norio/github/SwiftLint/Package.swift:44:28: warning: Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)
123FLO321 commented 4 years ago

I think you’re right actually. Will close the PR.