1

I am trying to implement a python linter using pylint. But I am getting the score of each python file and also displaying the suggestion to improve the score but I am also looking to terminate the GitHub action job if my pylint score is below 6.0 but currently its not failing my job. I have got a way to exit the code but i am unable to set the condition for the same. I want to lint all python files but this code exits after linting a single python file. Is it possible to make a check and if the exit code is something like an error it should terminate else the linting must proceed.

Pylint has different exit codes for error and warning but i am not able to set a condition for this : pylint exit code

This is the workflow which I have used :

---

name: Python Notebooks Linting on: push: branches: - 'main' repository_dispatch:

types: [python-lint] test

jobs: linting: runs-on: ubuntu-latest steps: - name: Checkout the code uses: actions/checkout@v2 - name: Install dependencies run: | python -m pip install --upgrade pip pip install pylint pip install umsgpack pip install cryptography pip install pylint-fail-under - name: pylint version run: pylint --version - name: Analysing the code with pylint run: | set -e for file in */.py; do pylint "$file"; done

But this code exits after linting a single file I want to set a condition that the linting should exit if the exit code is a specific number. How do I implement this ?

1 Answers1

-1

I used a different way to implement this requirement. Now the GitHub workflow fails if pylint score is less than 6.0 for a single file which is present in my python repo.By using find command in a for loop its able to terminate the job if its returning an exit code corresponding to an error.

  - name: Lints each python file and fails if pylint score is less than 6.0
    run: |
          for file in $(find -name '*.py')
          do
            pylint --disable=E0401,W0611 "$file" --fail-under=6.0;
          done

Refer : Lint python files using Github Workflows