Skip to content
Advertisement

Pylint fail under does not fail my Github action job

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.

This is the workflow which I have used :

JavaScript

My goal is the show that pylint has failed for a file and then terminate Git-hub action job. But i am not able to implement it using this can someone help ?

Advertisement

Answer

You have to make your command in “Analysing the code with pylint” step to return code != 0.

You are using https://pubs.opengroup.org/onlinepubs/009695399/utilities/find.html which ignores completely the exit code or exec part and will return always 0, unless there is an error in iterating over files.

You have to combine find with xargs instead – then your exit code will be coming from your pylint command instead of find.

The find + xargs will go through all resources and nonzero status if any of executed command returned nonzero status.

If you would like to stop on the first file not passing the lining I would recommend using set -e and writing the script differently:

JavaScript
Advertisement