gpt4 book ai didi

python - 如何在 Gitlab 中为简单的 hello world 程序配置 gitlab-ci.yml

转载 作者:行者123 更新时间:2023-11-30 22:03:39 26 4
gpt4 key购买 nike

我想知道如何配置正确的 .gitlab-ci.yml 文件,以便它自动检测我提交到项目中的代码中的错误。

例如,我将创建一个新的Python文件helloworld.py:

print("hello world""

上面的代码中有一个明显的错误,我希望我的 .gitlab-ci.yml 能够测试该代码并确保它不会通过。

我该怎么做呢?我真的很感谢对此的任何帮助。

最佳答案

尝试在 linter 中执行脚本:

.gitlab-ci.yml:

image: ubuntu

hello-test:
script:
- apt-get update && apt-get install -y pylint3
- pylint3 helloworld.py

或者直接在解释器中执行:

.gitlab-ci.yml:

image: ubuntu

hello-test:
script:
- apt-get update && apt-get install -y python3
- python3 helloworld.py

关于python - 如何在 Gitlab 中为简单的 hello world 程序配置 gitlab-ci.yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53483164/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com