I am building a project using Django, Docker, Travis CI and Flake8. My flake8 file:
[flake8]
max-line-length = 119
exclude =
migrations,
__pycache__,
manage.py,
settings.py,
env
When I run local flake8 tests using:
docker-compose exec app python manage.py test && flake8
I receive an ok message with no error messages. My code is good!
When I push my code to master which automatically starts Travis CI, the Travis build fails due to the following errors:
./project/settings.py:94:80: E501 line too long (91 > 79 characters)
./project/settings.py:97:80: E501 line too long (81 > 79 characters)
./project/settings.py:100:80: E501 line too long (82 > 79 characters)
./project/settings.py:103:80: E501 line too long (83 > 79 characters)
./core/models.py:7:80: E501 line too long (93 > 79 characters)
./core/models.py:13:80: E501 line too long (104 > 79 characters)
./core/migrations/0001_initial.py:18:80: E501 line too long (126 > 79 characters)
The command "docker-compose run app sh -c "python manage.py test && flake8"" exited with 1.
My flake8 file specifically states that the max line length is 119 so these errors should not be happening (like they are not when running the test on my local machine).
Does anyone know whats going on?
there wasn't enough information in the question so I went digging into OP's github
this was their dockerfile when the question was asked:
FROM python:3.9.0a5-alpine3.10
MAINTAINER Tom Mac
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache postgresql-client
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev linux-headers postgresql-dev
RUN pip install -r /requirements.txt
RUN apk del .tmp-build-deps
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
USER user
their flake8 configuration was at .flake8
in the root of their repository
since this file was not part of their image (nothing COPY
d it in), it was not being respected while linting
adding this file into the image (the easiest way being COPY . .
which adds everything) fixes this
what I suspect happened:
app/.flake8
(which is in the image listed above).
is mounted into the container at runtimeeither way, rebuilding and adding COPY . .
should fix this