Python的“漂亮”持续集成

这是一个微不足道的问题,但是BuildBot的输出并不是特别好看。

例如,相比..

  • phpUnderControl
  • jenkins
    • 哈德森
  • CruiseControl.rb

..和其他人, BuildBot看起来相当..古老

我目前正在玩哈德森,但它是非常以Java为中心(虽然有了这个指南 ,我发现比BuildBot更容易安装,并且产生了更多的信息)

基本上来说:是否有任何针对python的持续集成系统,可以产生许多shiny的graphics和类似graphics?


更新:从这一次Jenkins项目已经取代哈德森作为包的社区版本。 原作者也搬到了这个项目。 Jenkins现在是Ubuntu / Debian,RedHat / Fedora / CentOS等标准软件包。 以下更新仍然基本正确。 与Jenkins做这件事的出发点是不同的。

更新:尝试了几个select后,我想我会坚持哈德森。 诚信很好,很简单,但是相当有限。 我认为Buildbot更适合拥有大量的构build奴隶,而不是像我一直在使用它的单机上运行的所有东西。

为一个Python项目设置Hudson非常简单:

  • 从http://hudson-ci.org/下载Hudson
  • java -jar hudson.war运行它
  • 打开默认地址http://localhost:8080的Web界面
  • 去pipe理哈德森,插件,点击“更新”或类似的
  • 安装Git插件(我必须在Hudson全局首选项中设置gitpath)
  • 创build一个新项目,input仓库,SCM轮询间隔等等
  • 如果还没有,请通过easy_install安装nosetests
  • 在构build步骤中,添加nosetests --with-xunit --verbose
  • 选中“发布JUnittesting结果报告”,将“testing报告XML”设置为**/nosetests.xml

这就是所有必需的。 你可以设置电子邮件通知, 插件是值得一看。 我正在使用Python项目中的一些:

  • SLOCCount插件来计算代码行(并绘制它!) – 您需要单独安装sloccount
  • ViolationsparsingPyLint输出(可以设置警告阈值,绘制每个构build的违规数量)
  • Cobertura可以parsingcoverage.py的输出。 Nosetest可以在运行testing时收集覆盖范围,使用nosetests --with-coverage (将输出写入**/coverage.xml

你可能想看看鼻子和Xunit输出插件 。 你可以让它运行你的unit testing,并用这个命令覆盖检查:

 nosetests --with-xunit --enable-cover 

如果你想要去Jenkins路线,或者如果你想使用另一个支持JUnittesting报告的CI服务器,这将会很有帮助。

同样,您可以使用Jenkins的侵犯性插件来捕获pylint的输出

不知道是否会这样做: Bitte由编写Trac的人员完成,并与Trac集成。 Apache Gump是Apache使用的CI工具。 它是用Python编写的。

TeamCity作为我们的CI服务器,并以鼻子作为我们的testing者,取得了巨大的成功。 用于nosetests的TeamCity插件可以让您计数合格/不合格,可读的失败testing显示(可以通过电子邮件发送)。 在堆栈运行时,您甚至可以看到testing失败的细节。

如果当然支持像在多台机器上运行的东西,并且比buildbot更容易安装和维护。

Buildbot的瀑布页面可以大大地美化。 这是一个很好的例子http://build.chromium.org/buildbot/waterfall/waterfall

Atlassian的Bamboo也绝对值得一试。 整个Atlassian套件(JIRA,Confluence,FishEye等)都非常的甜美。

我想这个线程是相当古老的,但这是我与哈德森:

我决定用点子,并build立一个回购(痛苦的工作,但看起来不错的鸡蛋),哈德森自动上传到一个成功的testing。 这里是我的粗糙和准备脚本使用Hudsonconfiguration执行脚本,如:/var/lib/hudson/venv/main/bin/hudson_script.py -w $ WORKSPACE -p my.package -v $ BUILD_NUMBER,只是把** / coverage.xml,pylint.txt和configuration位中的nosetests.xml:

 #!/var/lib/hudson/venv/main/bin/python import os import re import subprocess import logging import optparse logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s') #venvDir = "/var/lib/hudson/venv/main/bin/" UPLOAD_REPO = "http://ldndev01:3442" def call_command(command, cwd, ignore_error_code=False): try: logging.info("Running: %s" % command) status = subprocess.call(command, cwd=cwd, shell=True) if not ignore_error_code and status != 0: raise Exception("Last command failed") return status except: logging.exception("Could not run command %s" % command) raise def main(): usage = "usage: %prog [options]" parser = optparse.OptionParser(usage) parser.add_option("-w", "--workspace", dest="workspace", help="workspace folder for the job") parser.add_option("-p", "--package", dest="package", help="the package name ie, back_office.reconciler") parser.add_option("-v", "--build_number", dest="build_number", help="the build number, which will get put at the end of the package version") options, args = parser.parse_args() if not options.workspace or not options.package: raise Exception("Need both args, do --help for info") venvDir = options.package + "_venv/" #find out if venv is there if not os.path.exists(venvDir): #make it call_command("virtualenv %s --no-site-packages" % venvDir, options.workspace) #install the venv/make sure its there plus install the local package call_command("%sbin/pip install -e ./ --extra-index %s" % (venvDir, UPLOAD_REPO), options.workspace) #make sure pylint, nose and coverage are installed call_command("%sbin/pip install nose pylint coverage epydoc" % venvDir, options.workspace) #make sure we have an __init__.py #this shouldn't be needed if the packages are set up correctly #modules = options.package.split(".") #if len(modules) > 1: # call_command("touch '%s/__init__.py'" % modules[0], # options.workspace) #do the nosetests test_status = call_command("%sbin/nosetests %s --with-xunit --with-coverage --cover-package %s --cover-erase" % (venvDir, options.package.replace(".", "/"), options.package), options.workspace, True) #produce coverage report -i for ignore weird missing file errors call_command("%sbin/coverage xml -i" % venvDir, options.workspace) #move it so that the code coverage plugin can find it call_command("mv coverage.xml %s" % (options.package.replace(".", "/")), options.workspace) #run pylint call_command("%sbin/pylint --rcfile ~/pylint.rc -f parseable %s > pylint.txt" % (venvDir, options.package), options.workspace, True) #remove old dists so we only have the newest at the end call_command("rm -rfv %s" % (options.workspace + "/dist"), options.workspace) #if the build passes upload the result to the egg_basket if test_status == 0: logging.info("Success - uploading egg") upload_bit = "upload -r %s/upload" % UPLOAD_REPO else: logging.info("Failure - not uploading egg") upload_bit = "" #create egg call_command("%sbin/python setup.py egg_info --tag-build=.0.%s --tag-svn-revision --tag-date sdist %s" % (venvDir, options.build_number, upload_bit), options.workspace) call_command("%sbin/epydoc --html --graph all %s" % (venvDir, options.package), options.workspace) logging.info("Complete") if __name__ == "__main__": main() 

当涉及到部署的东西,你可以做这样的事情:

 pip -E /location/of/my/venv/ install my_package==XYZ --extra-index http://my_repo 

然后人们可以使用以下方式开发内容

 pip -E /location/of/my/venv/ install -e ./ --extra-index http://my_repo 

这个东西假设你有一个每个包都有一个setup.py和依赖关系的软件包,然后你可以检查一下这个trunk并在其上运行这个东西。

我希望这可以帮助别人。

——更新———

我添加了epydoc,非常适合哈德森。 只需添加javadoc到您的configuration与HTML文件夹

请注意,pip现在不支持-E标志,所以你必须单独创build你的venv

另一个: Shining Panda是Python的托pipe工具

如果您正在考虑托pipeCI解决scheme,并开放源代码,则还应该考虑Travis CI–它与GitHub有很好的集成。 虽然它是作为一个Ruby工具开始的,但是他们刚刚添加了Python支持 。

信号是另一种select。 你可以更多地了解它,并在这里观看video。

我会考虑CircleCi – 它有很好的Python支持,并且非常漂亮的输出。

continuum的binstar现在可以从github中触发构build,可以编译为linux,osx和windows(32/64)。 整洁的事情是,它真的可以让你紧密结合分配和持续集成。 这是跨越了我的整合我。 网站,工作stream程和工具都非常精美,AFAIK conda是分发复杂python模块的最强大和最python的方式,您需要打包分发C / C ++ / Fotran库。

我们已经使用了很多。 它非常漂亮,与Trac很好地集成在一起,但是如果你有任何非标准的工作stream程,那么定制就会很痛苦。 还有就是没有那么多的插件,比较stream行的工具。 目前我们正在评估Hudson作为替代品。

检查rultor.com 。 正如这篇文章所解释的,它为每个构build使用Docker。 多亏了这个,你可以在你的Docker镜像中configuration任何你喜欢的东西,包括Python。

一点免责声明,我实际上不得不为这样一个客户端build立一个这样的解决scheme,想要一个方法来自动testing和部署任何代码的git推,并通过git笔记pipe理问题票据。 这也导致了我在AIMS项目上的工作 。

可以很容易地设置一个裸机节点系统,它有一个构build用户,并通过make(1)expect(1)crontab(1) / systemd.unit(5)incrontab(1)pipe理它们的构build。 甚至可以更进一步,使用一个gridfs / nfs文件存储的分布式构build的可靠和芹菜。

虽然,除了Graybeard UNIX家伙或者原理级别工程师/架构师之外,我不希望有任何人能够实现这一目标。 只是为了一个好主意和潜在的学习经验,因为构build服务器不过是以自动方式任意执行脚本化任务的一种方式。