Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Continuous integration 如何将CD与CircleCI集成?_Continuous Integration_Circleci_Continuous Delivery - Fatal编程技术网

Continuous integration 如何将CD与CircleCI集成?

Continuous integration 如何将CD与CircleCI集成?,continuous-integration,circleci,continuous-delivery,Continuous Integration,Circleci,Continuous Delivery,我一直在关注很多关于使用Python的CI的教程,但这些教程似乎到此为止,很少进入CD的下一步。我也是唯一的开发者 我在Github上设置了一个项目,它在我的PC上本地运行,不是一个web应用程序。我已经将它连接到CircleCI for CI。这是我的config.yml文件 version: 2 jobs: build: docker: - image: circleci/python:3.7 working_directory: ~

我一直在关注很多关于使用Python的CI的教程,但这些教程似乎到此为止,很少进入CD的下一步。我也是唯一的开发者

我在Github上设置了一个项目,它在我的PC上本地运行,不是一个web应用程序。我已经将它连接到CircleCI for CI。这是我的
config.yml
文件

  version: 2
  jobs:
    build:
      docker:
        - image: circleci/python:3.7

      working_directory: ~/repo

      steps:
        # Step 1: obtain repo from GitHub
        - checkout
        - run:
            name: install dependencies
            command: |
              sudo apt-get update
              pip install -r requirements.txt
        - run:
            name: run tests
            command: |
              python -m pytest -v
一切都运行得很好,我收到CircleCI的一封电子邮件,当我在github上推到master时,它警告我构建失败,其中一个pytests失败

所以我的问题是,下一步是什么?我有一些想法,但老实说,我对其中任何一个都不确定

  • 创建代码的单独测试和产品版本。在测试版本生成时自动更新产品版本,且无错误。但是,不确定要使用什么工具来实现这一点
  • 将项目推送到Dockerhub。但这对我来说似乎是多余的,因为Docker将运行与CircleCI相同的pytests。我不确定这对CD有什么帮助

  • 有人能在这里提供一些关于下一步的指导吗?

    目前您只有一个作业
    构建
    ,因此您可以在作业部分下添加更多作业。因此,您在这里要做的是:

  • 添加测试
  • 生成产品版本
  • 推到Dockerhub
  • 请使用配置2.1启用工作流

    version: 2.1
      jobs:
        build:
          docker:
            - image: circleci/python:3.7
    
          working_directory: ~/repo
    
          steps:
            # Step 1: obtain repo from GitHub
            - checkout
            - run:
                name: install dependencies
                command: |
                  sudo apt-get update
                  pip install -r requirements.txt
            - run:
                name: run tests
                command: |
                  python -m pytest -v
    
        test:
          docker:
            - image: circleci/python:3.7
          steps:
            - checkout
            - run: echo "do your test here"
    
        build-prod:
          docker:
            - image: circleci/python:3.7
          steps:
            - checkout
            - run: echo "build your app"
    
        push-to-dockerhub:
          docker:
            - image: circleci/python:3.7
          steps:
            - checkout
            - setup_remote_docker # this is necessary to use docker daemon
            - run: echo "do docker login and docker push here"
    
    workflows:
      build-and-push:
        jobs:
          - build
          - test
              requires:
                - build
          - build-prod
              requires:
                - test
          - push-to-dockerhub
              requires:
                - build-prod
    
    请确保仅当所需作业成功完成时,我们才使用
    requires
    运行该作业

    当然,我还没有测试过配置,但它就像上面的配置一样。这里有更多的配置文档,所以请仔细查看,以使其完美工作。

    非常感谢。如果你不介意的话,我只有几个问题。1) Python中没有按需构建,因此省略这一点是否正确?2) 如果成功推送Dockerhub,Dockerhub上是否会自动下载代码以PROD?您可以根据需要更改图像-不确定是否是您要求的。只需更改配置并使用circleci cli进行验证。您不需要按下按钮来触发构建来验证配置。我也不知道你想为2做什么。。