简体   繁体   English

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

[英]Configuring .gitlab-ci.yml file in Gitlab to test python Codes

Currently I am stuck with trying to configure the gitlab-ci.yml file. 目前,我一直在尝试配置gitlab-ci.yml文件。 Im trying to automatically build and test my python code when I made a commit. 我在提交时试图自动构建和测试我的python代码。 At the moment, I just wanted to build a simple hello world program and purposely put a mistake within the python file by misspelling print (printt instead of print). 此刻,我只想构建一个简单的hello world程序,并通过拼写错误打印(打印而不是打印)来故意在python文件中放入一个错误。 When I commit, the pipeline is run, but it seems to successfully pass the build and test phase (which it shouldn't). 当我提交时,管道已运行,但它似乎已成功通过了构建和测试阶段(不应这样做)。

Any help how to properly configure the gitlab-ci.yml file to automatically test python codes? 对如何正确配置gitlab-ci.yml文件以自动测试python代码有帮助吗?

I've also attached my current gitlab-ci.yml file. 我还附加了当前的gitlab-ci.yml文件。

在此处输入图片说明 Thank you 谢谢

It's dead simple. 很简单。 Here is minimal working example I use in my repo: 这是我在仓库中使用的最小工作示例:

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 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with.gitlab-ci.yml file - Gitlab Flask Page: Problems with installing python GDAL package for Frozen Flask Application with .gitlab-ci.yml file gitlab-ci.yml python -c'多行cmd'失败 - gitlab-ci.yml python -c 'multiple line cmd' failed 每个python脚本是否可以在.gitlab-ci.yml文件中填充变量? - Is it possible to fill a variable in the .gitlab-ci.yml file per python script? 我的 first.gitlab-ci.yml 文件:如何在 CI/CD 中运行现有文件 - My first .gitlab-ci.yml file: How to run existing files in CI/CD 使用 gitlab-ci.yml 管道测试 python 程序时出现问题 - Problem using MPI in a python program when testing it with a gitlab-ci.yml pipeline 在.gitlab-ci.yml中使用apt-get install python包 - use apt-get install python packages in .gitlab-ci.yml gitlab-ci.yml:“脚本:-pytest”命令无法识别 - gitlab-ci.yml: 'script: -pytest' command is not recognized 使用 pyyaml 的 Load.gitlab-ci.yml 失败,无法确定构造函数 - Load .gitlab-ci.yml with pyyaml fails with could not determine constructor 如何在 gitlab-ci.yml 中将 postgis 扩展添加到 postgresql 数据库 - How to add postgis extension to postgresql database in gitlab-ci.yml Gitlabci 管道失败:gitlab-ci.yml 中规则中的语法错误 - Gitlabci pipline failes with: syntax error in rules in gitlab-ci.yml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM