简体   繁体   English

python tox,创建rpm virtualenv,作为ci管道的一部分,不确定工作流中的位置

[英]python tox, creating rpm virtualenv, as part of ci pipeline, unsure about where in workflow

I'm investigating how Python applications can also use a CI pipeline, but I'm not sure how to create the standard work-flow. 我正在研究Python应用程序如何也可以使用CI管道,但是我不确定如何创建标准工作流程。

Jenkins is used to do the initial repository clone, and then initiates tox. Jenkins用于进行初始存储库克隆,然后启动tox。 Basically this is where maven, and/or msbuild, would get dependency packages and build.... which tox does via pip, so all good here. 基本上,这是maven和/或msbuild可以获取依赖包并进行构建的地方。...tox通过pip来完成,因此在这里一切都很好。

But now for the confusing part, the last part of the pipeline is creating and uploading packages. 但是现在令人困惑的是,管道的最后一部分是创建和上传软件包。 Devs would likely upload created packages to a local pip repository, BUT then also possibly create a deployment package. 开发人员可能会将创建的程序包上传到本地pip存储库,然后可能还会创建部署程序包。 In this case it would need to be an RPM containing a virtualenv of the application. 在这种情况下,它将需要是一个包含应用程序虚拟环境的RPM。 I have made one manually using rpmvenev, but regardless of how its made, how what such a step be added to a tox config? 我已经使用rpmvenev手动制作了一个,但是不管它是如何制作的,如何将这样的步骤添加到tox配置中? In the case if rpmvenv, it creates its own virtualenv, a self contained command so to speak. 在rpmvenv的情况下,它会创建自己的virtualenv,可以说这是一个自包含的命令。

I like going with the Unix philosophy for this problem. 我喜欢使用Unix哲学解决这个问题。 Have a tool that does one thing incredibly well, then compose other tools together. 拥有一个可以出色地完成一件事情的工具,然后将其他工具组合在一起。 Tox is purpose built to run your tests in a bunch of different python environments so using it to then build a deb / rpm / etc for you I feel is a bit of a misuse of that tool. Tox旨在在一系列不同的python环境中运行测试,因此使用它来为您构建deb / rpm / etc等,我觉得这是对该工具的误用。 It's probably easier to use tox just to run all your tests then depending on the results have another step in your pipeline deal with building a package for what was just tested. 仅使用tox来运行所有测试可能会更容易,然后根据结果在您的管道中又迈出了一步,即为刚刚测试的内容构建程序包。

Jenkins 2.x which is fairly recent at the time of this writing seems to be much better about building pipelines. 在撰写本文时,Jenkins 2.x似乎是最新的,它似乎在构建管道方面要好得多。 BuildBot is going through a decent amount of development and already makes it fairly easy to build a good pipeline for this as well. BuildBot正在经历大量的开发,并且已经相当容易为此建立良好的管道。

What we've done at my work is 我们在工作中所做的是

  • Buildbot in AWS which receives push notifications from Github on PR's AWS中的Buildbot,可从PR的Github接收推送通知
  • That kicks off a docker container that pulls in the current code and runs Tox (py.test, flake8, as well as protractor and jasmine tests) 这将启动一个docker容器,该容器插入当前代码并运行Tox(py.test,flake8以及量角器和茉莉花测试)
  • If the tox step comes back clean, kick off a different docker container to build a deb package 如果毒素步骤恢复正常,请启动另一个Docker容器以构建一个deb包
  • Push that deb package up to S3 and let Salt deal with telling those machines to update 将那个deb包推送到S3,让Salt处理告诉这些机器更新

That deb package is also just available as a build artifact, similar to what Jenkins 1.x would do. 该deb包也可以作为构建工件使用,类似于Jenkins 1.x所做的事情。 Once we're ready to go to staging, we just take that package and promote it to the staging debian repo manually. 一旦准备好进行登台,我们只需获取该软件包并将其手动升级到登台的debian repo。 Ditto for rolling it to prod. 同上,将其滚动到产品。

Tools I've found useful for all this: 我发现所有这些有用的工具:

  • Buildbot because it's in Python thus easier for us to work on but Jenkins would work just as well. Buildbot,因为它在Python中,因此我们可以更轻松地进行工作,但Jenkins也可以工作。 Regardless, this is the controller for the entire pipeline 无论如何,这是整个管道的控制器
  • Docker because each build should be completely isolated from every other build Docker,因为每个构建都应该与其他所有构建完全隔离
  • Tox the glorious test runner to handle all those details 毒打光荣的测试跑步者以处理所有这些细节
  • fpm builds the package. fpm生成软件包。 RPM, DEB, tar.gz, whatever. RPM,DEB,tar.gz等。 Very configurable and easy to script. 高度可配置且易于编写脚本。
  • Aptly makes it easy to manage debian repositories and in particular push them up to S3. 使用Aptly可以轻松管理debian存储库,尤其是将它们推向S3。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM