Search code examples
iosswiftgithub-actionslintswiftlint

How to make my Github action fail if there is an error


I am having the following workflow file in my project which is used to check if there is any swiftlint error. If there is any swiftlint error, I am expecting the workflow to fail, instead, I see the Workflow success.

When I check the workflow log, I can clearly see the violations, but still, the workflow gets through. Does anyone know what am I missing here,

jobs:
  build:
    runs-on: macos-latest
    continue-on-error: false
    steps:
    - name: Swiftlint
      uses: actions/checkout@v2
    - name: Checkign Swiftlint...
      run: swiftlint

Solution

  • Isn't it because the exit status of swiftlint is 0? What is the status when you run this command?

    swiftlint
    echo $?
    

    Perhaps, you might need --strict option? Ref: https://github.com/realm/SwiftLint/issues/2130