[英]testdriven.io flask-tdd-docker course chapter 15 pipeline stage test ERROR: Job failed: exit code 1
我正在關注 python/flask/docker教程。 一切正常,直到我推送到 GitLab 管道階段構建良好然后在測試階段失敗:
stage: test
image: $IMAGE:latest
services:
- postgres:latest
variables:
POSTGRES_DB: users
POSTGRES_USER: runner
POSTGRES_PASSWORD: runner
DATABASE_TEST_URL: postgres://runner:runner@postgres:5432/users
script:
- python3.8 -m venv env
- source env/bin/activate
- pip install -r requirements.txt
- pip install black flake8 isort pytest
- pytest "project/tests" -p no:warnings
- flake8 project
- black project --check
- isort project/**/*.py --check-only
流水線測試日志:
$ pytest "project/tests" -p no:warnings
============================= test session starts ==============================
platform linux -- Python 3.8.1, pytest-6.1.1, py-1.9.0, pluggy-0.13.1
rootdir: /builds/piccoloa/flask-on-docker/project/tests, configfile: pytest.ini
collected 30 items
project/tests/test_config.py ... [ 10%]
project/tests/test_ping.py . [ 13%]
project/tests/test_users.py ............. [ 56%]
project/tests/test_users_unit.py ............. [100%]
============================== 30 passed in 0.41s ==============================
$ flake8 project
$ black project --check
would reformat /builds/piccoloa/flask-on-docker/project/api/users.py
would reformat /builds/piccoloa/flask-on-docker/project/tests/test_users.py
would reformat /builds/piccoloa/flask-on-docker/project/tests/test_users_unit.py
Oh no! 💥 💔 💥
3 files would be reformatted, 10 files would be left unchanged.
Cleaning up file based variables
00:00
ERROR: Job failed: exit code 1
找到了這個但不知道如何解決或者它是否與問題有關。 GitLab Issue中提到的“調整您的閾值或提高覆蓋率”。 我在本地主機上運行測試時沒有收到任何錯誤?
沒有完全解決失敗的工作。 作為 gitlab 新手,自從我在本地運行時沒有出現錯誤以來,唯一對我有用的是匹配測試階段 pip python 包安裝在 requirements.txt 的測試腳本中,並注釋掉 flake8 和 black 測試腳本。
我認為你在正確的軌道上。 在我看來,您的 CI 失敗了,因為black
正在尋找要重新格式化的文件。 您的 CI 中運行的black
版本可能與本地運行的版本不同,因此建議進行新的/不同的更改。
您可以通過 Gitlab 管道的 output 查看那里使用的black
版本。 如果版本與您本地的black
版本不匹配,請嘗試通過 Gitlab 使用的black
版本在本地運行您的文件,然后將這些更改的文件提交到您的 repo 以觸發您的 CI。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.