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 ?
**/*.py
looks better and would handle files and directories with spaces in their names. – Kusalananda Sep 01 '22 at 05:58**
withshopt -s globstar
(assuming the shell being used isbash
), then**
will match down into subdirectories. Without theglobstar
shell option being enabled,**
works just like*
. Since the question was not about this in particular, I was just a bit surprised that you switch to usingfind
. – Kusalananda Sep 01 '22 at 06:15