在Gitlab中配置.gitlab-ci.yml文件来测试python代码

问题描述 投票:0回答:1

目前我一直在尝试配置gitlab-ci.yml文件。我在提交时试图自动构建和测试我的python代码。目前,我只是想构建一个简单的hello world程序,并故意通过拼写错误的print(printt而不是print)在python文件中输入错误。当我提交时,管道运行,但它似乎成功通过构建和测试阶段(它不应该)。

任何帮助如何正确配置gitlab-ci.yml文件来自动测试python代码?

我还附上了我当前的gitlab-ci.yml文件。

enter image description here谢谢

python gitlab-ci
1个回答
0
投票

这很简单。这是我在我的仓库中使用的最小工作示例:

pytest:
  image: python:3.6
  script:
    - apt-get update -q -y
    - pip install -r requirements.txt
    - pip install -r requirements-dev.txt
    - pytest  # or pytest tests/

source

© www.soinside.com 2019 - 2024. All rights reserved.