I have an old python project that I am trying to progressively clean up using flake8 (to warn about PEP8 issues). I use Travis for continuous integration and want my build to fail if any unit test fails. However, I do not want my build to fail simply because flake8 produced a warning (e.g., about something minor like trailing white space).
How do I configure Travis to output flake8 warnings (so that I can resolve them as I have time) without causing them to fail the build?
My .travis.yml is below:
language: python
python:
- "3.6"
install:
- pip install -r requirements.txt
- pip install flake8
script:
- python -m unittest discover -v
- flake8 .
Example flake8 warnings:
./meta-db/file_system.py:103:80: E501 line too long (108 > 79 characters)
./meta-db/file_system.py:106:68: W291 trailing whitespace
Adding --exit-zero flag to flake8 allows lint warnings/errors to be displayed without failing the Travis build.
script:
- python -m unittest discover -v
- flake8 . --exit-zero # Exit with status code "0" even if there are errors.