Skip to content

Commit

Permalink
Merge pull request #10 from mundialis/fix_linting_precommits
Browse files Browse the repository at this point in the history
fix linting pre commits: exit if any linting step fails
  • Loading branch information
linakrisztian authored Aug 30, 2023
2 parents fc8e434 + 7e7bb92 commit 9257374
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pre_commit_hooks/linting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,18 @@ echo "black: `black --version`"

cd $CODE_REPO_PATH

FAILINGSTEP=""
RETURNCODE=0
if [ $RUN_FLAKE8 != "FALSE" ]
then
echo
echo "FLAKE8:"
flake8 --config=.flake8 --count --statistics --show-source .
if [ $? -ne 0 ]
then
RETURNCODE=1
FAILINGSTEP="FLAKE8"
fi
else
echo
echo "FLAKE8 configured to be skipped"
Expand All @@ -124,6 +131,11 @@ then
wget https://raw.githubusercontent.com/mundialis/github-workflows/main/linting-config-examples/.pylintrc
fi
pylint .
if [ $? -ne 0 ]
then
RETURNCODE=1
FAILINGSTEP="$FAILINGSTEP PYLINT"
fi

echo
echo "PYLINT more strict:"
Expand All @@ -146,7 +158,18 @@ then
echo
echo "BLACK:"
black --check --diff --line-length 79 .
if [ $? -ne 0 ]
then
RETURNCODE=1
FAILINGSTEP="$FAILINGSTEP BLACK"
fi
else
echo
echo "BLACK configured to be skipped"
fi

if [ $RETURNCODE -ne 0 ]
then
echo "Failing steps: ${FAILINGSTEP}"
fi
exit $RETURNCODE

0 comments on commit 9257374

Please sign in to comment.