ci: fail travis build if flake8 finds any issues

This commit is contained in:
Mike Salvatore 2021-04-05 13:45:18 -04:00
parent 8ed4224341
commit a7f8efa102
1 changed files with 1 additions and 11 deletions

View File

@ -55,17 +55,7 @@ install:
script: script:
# Check Python code # Check Python code
## Check syntax errors and fail the build if any are found. ## Check syntax errors and fail the build if any are found.
- flake8 ./monkey --config=./ci_scripts/flake8_syntax_check.ini - flake8 ./monkey
## Warn about linter issues.
### --exit-zero forces Flake8 to use the exit status code 0 even if there are errors, which means this will NOT fail the build.
### The output is redirected to a file.
- flake8 ./monkey --exit-zero --config=./ci_scripts/flake8_linter_check.ini > ./ci_scripts/flake8_warnings.txt
## Display the linter issues
- cat ./ci_scripts/flake8_warnings.txt
## Make sure that we haven't increased the amount of warnings.
- PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT=80
- if [ $(tail -n 1 ./ci_scripts/flake8_warnings.txt) -gt $PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT ]; then echo "Too many python linter warnings! Failing this build. Lower the amount of linter errors in this and try again. " && exit 1; fi
## Check import order ## Check import order
- python -m isort ./monkey --settings-file ./ci_scripts/isort.cfg - python -m isort ./monkey --settings-file ./ci_scripts/isort.cfg