首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Google Build cloudbuild.yaml中运行pytest来确定构建是否通过。

在Google Build cloudbuild.yaml中运行pytest来确定构建是否通过。
EN

Stack Overflow用户
提问于 2019-06-06 07:45:34
回答 1查看 2.1K关注 0票数 5

我的项目结构如下:

代码语言:javascript
复制
cloudbuild.yaml
requirements.txt
functions/
    folder_a/
        test/
            main_test.py
        main.py

我的cloudbuild.yaml

代码语言:javascript
复制
steps:
# Install
- name: 'docker.io/library/python:3.7'
  args: ['pip', 'install', '-t', '/workspace/lib', '-r', 'requirements.txt']
# Test
- name: '?'
  args: ['pytest', 'functions/**/*_test.py']

我应该使用什么构建器来运行pytest?我只是使用前面的安装步骤安装了它。我应该使用相同的docker图像吗?如何在pytest成功完成所有测试之前停止我的构建?

EN

回答 1

Stack Overflow用户

发布于 2019-06-06 07:52:05

每个步骤都在单独的容器中运行,因此您应该在一个步骤中完成所有这些操作:

代码语言:javascript
复制
steps:
# This step runs the unit tests on the app
- name: 'docker.io/library/python:3.7'
  id: Test
  entrypoint: /bin/sh
  args:
  - -c
  - 'pip install -t /workspace/lib -r requirements.txt && pytest functions/**/*_test.py'

有关更多详细信息,请参阅"GitOps-style continuous delivery with Cloud Build"

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56469381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档