在 Travis CI 中构建 Django 应用程序未成功

Building a django app in Travis CI not successful

我正在尝试将 Travis CI 与 Django 应用程序集成。但是我收到以下错误

Successfully built 9b60427cea1c
Successfully tagged 3_recipe_app_app:latest
WARNING: Image for service app was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating 3_recipe_app_app_run ... 
System check identified no issues (0 silenced).
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
./app/settings.py:23:80: E501 line too long (81 > 79 characters)
./app/settings.py:89:80: E501 line too long (91 > 79 characters)
./app/settings.py:92:80: E501 line too long (81 > 79 characters)
./app/settings.py:95:80: E501 line too long (82 > 79 characters)
./app/settings.py:98:80: E501 line too long (83 > 79 characters)
ERROR: 1
The command "docker-compose run app sh -c "python manage.py test && flake8"" exited with 1.
Done. Your build exited with 1.

.travis.yml

language: python
python:
  - "3.6"

services:
  - docker

before_script: pip install docker-compose

script:
  - docker-compose run app sh -c "python manage.py test && flake8"

.flake8

[flake8]
exclude =
  migrations
  __pycache__,
  manage.py,
  settings.py

Dockerfile

FROM python:3.7-alpine
LABEL maintainer="hans"
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
USER user

docker-compose.yml

version: "3"
services:
  app:
    build:
      context: .
    ports:
      - "8000:8000"
    volumes:
      - ./app:/app
    command: >
      sh -c "python manage.py runserver 0.0.0.0:8000"

我不确定这个错误是怎么发生的。我试了好几次,但仍然出现同样的错误。我该如何解决这个问题。提前致谢

好吧...您已经在您的代码中将 flake8 linter 配置为 运行。

linter 已配置为将超过 79 个字符(默认)的行视为太长,并且您的设置文件包含此类行:

./app/settings.py:23:80: E501 line too long (81 > 79 characters)
./app/settings.py:89:80: E501 line too long (91 > 79 characters)
./app/settings.py:92:80: E501 line too long (81 > 79 characters)
./app/settings.py:95:80: E501 line too long (82 > 79 characters)
./app/settings.py:98:80: E501 line too long (83 > 79 characters)

缩短这些行,或配置 flake8 以允许更长的行。