GitHub 动作 flake8 Lint 在提交时失败 "failed with exit code 1"

GitHub actions flake8 Lint failing upon commit "failed with exit code 1"

我在 GitHub 上有一个存储库,其中包含 my.yaml 文件用于 github 操作配置,如下所示:

name: flake8 Lint

on: [push, pull_request]

jobs:
  flake8-lint:
    runs-on: ubuntu-latest
    name: Lint
    steps:
      - name: Check out source repository
        uses: actions/checkout@v2
      - name: Set up Python environment
        uses: actions/setup-python@v1
        with:
          python-version: "3.8"
      - name: flake8 Lint
        uses: py-actions/flake8@v2
        with:
          max-line-length: "100"
          path: "app"

这个文件工作得很好并且在提交时传递,但是,我最近在我的应用程序文件夹(flask 应用程序代码)中添加了一些代码,现在它失败了并给出如下所示的错误:

Run py-actions/flake8@v2
[*] Installing flake8 package @ latest...
/opt/hostedtoolcache/Python/3.8.12/x64/bin/python -m pip install --upgrade flake8
Collecting flake8
  Downloading flake8-4.0.1-py2.py3-none-any.whl (64 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.1/64.1 KB 14.6 MB/s eta 0:00:00
Collecting pyflakes<2.5.0,>=2.4.0
  Downloading pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.7/69.7 KB 18.3 MB/s eta 0:00:00
Collecting mccabe<0.7.0,>=0.6.0
  Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pycodestyle<2.9.0,>=2.8.0
  Downloading pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.1/42.1 KB 10.8 MB/s eta 0:00:00
Installing collected packages: mccabe, pyflakes, pycodestyle, flake8
Successfully installed flake8-4.0.1 mccabe-0.6.1 pycodestyle-2.8.0 pyflakes-2.4.0
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the '/opt/hostedtoolcache/Python/3.8.12/x64/bin/python -m pip install --upgrade pip' command.
[*] Installed flake8 package version:
/opt/hostedtoolcache/Python/3.8.12/x64/bin/flake8 --version
4.0.1 (mccabe: 0.6.1, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.8.12 on
Linux
/opt/hostedtoolcache/Python/3.8.12/x64/bin/flake8 --max-line-length 100 app
app/__init__.py:5:1: W293 blank line contains whitespace
app/__init__.py:6:1: E302 expected 2 blank lines, found 1
app/__init__.py:6:28: E251 unexpected spaces around keyword / parameter equals
app/__init__.py:6:30: E251 unexpected spaces around keyword / parameter equals
app/__init__.py:9:1: W293 blank line contains whitespace
app/__init__.py:12:1: W293 blank line contains whitespace
app/__init__.py:15:1: W293 blank line contains whitespace
app/config.py:7:1: E302 expected 2 blank lines, found 1
app/main/routes.py:1:1: F401 'flask.Flask' imported but unused
app/main/routes.py:1:1: F401 'flask.url_for' imported but unused
app/main/routes.py:1:1: F401 'flask.redirect' imported but unused
app/main/routes.py:1:1: F401 'flask.request' imported but unused
app/main/routes.py:4:1: W293 blank line contains whitespace
app/main/routes.py:6:1: E302 expected 2 blank lines, found 1
app/main/routes.py:6:32: E231 missing whitespace after ','
app/main/routes.py:8:1: W293 blank line contains whitespace
app/main/routes.py:9:41: W292 no newline at end of file
Error: The process '/opt/hostedtoolcache/Python/3.8.12/x64/bin/flake8' failed with exit code 1

我的应用程序文件夹中有文件不是 .py,这可能是导致 github 动作 flake8 测试失败的问题,如果是这样,我如何忽略其他文件?

您的问题似乎是您的代码没有通过 PEP8,如果您不这样做,Flake8 检查将失败(这就是重点)。请注意,Flake8 检查 不会 重新格式化文件,它只会告诉您它们是错误的!错误日志会告诉你个别的错误代码(如W293 blank line contains whitespace