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 7.0 but currently its not failing my job. I have got a way to fail the build but it only works for one directory. But if there is a sub directory which has a python file it does not lint that
for file in */*.py; do pylint --disable=E0401 "$file" --fail-under=7.0; done
This is the for loop i have used but if there is a directory inside which has another python file I have to write another for loop to lint that and it would look like this
for file in */*/*.py; do pylint --disable=E0401 "$file" --fail-under=7.0; done
is there a way such that for loop can lint all the files even if there is a sub-directory ? In case some new directory is added by a developer this solution is not a great way to fix the issue. I have tried to use find command but it does not fail the GitHub action workflow if there pylint score of a file is less than 7.0
CodePudding user response:
The below snippet works fine and is able to find .py file even from sub directories. This is actually working for me.
- name: Checks if pylint score is above 7.0
run: |
for file in $(find -name '*.py')
do
pylint --disable=E0401,W0611 "$file" --fail-under=7.0;
done