“漂亮"Python 的持续集成
问题描述
这是一个有点……徒劳的问题,但是 BuildBot 的输出并不是特别好看……
This is a slightly.. vain question, but BuildBot's output isn't particularly nice to look at..
例如,相比于..
- phpUnderControl
- 詹金斯
- 哈德逊
..和其他人,BuildBot 看起来相当.. 过时
..and others, BuildBot looks rather.. archaic
我目前正在使用 Hudson,但它非常以 Java 为中心(尽管使用 本指南,我发现它比 BuildBot 更容易设置,并产生了更多信息)
I'm currently playing with Hudson, but it is very Java-centric (although with this guide, I found it easier to setup than BuildBot, and produced more info)
基本上:是否有任何针对 python 的持续集成系统,可以生成大量闪亮的图表等?
Basically: is there any Continuous Integration systems aimed at python, that produce lots of shiny graphs and the likes?
更新: 自此以来,Jenkins 项目已取代 Hudson 作为该软件包的社区版本.原作者也已移至该项目.Jenkins 现在是 Ubuntu/Debian、RedHat/Fedora/CentOS 等的标准软件包.以下更新基本上仍然是正确的.Jenkins 的出发点是不同的.
Update: Since this time the Jenkins project has replaced Hudson as the community version of the package. The original authors have moved to this project as well. Jenkins is now a standard package on Ubuntu/Debian, RedHat/Fedora/CentOS, and others. The following update is still essentially correct. The starting point to do this with Jenkins is different.
更新:在尝试了一些替代方案后,我想我会坚持使用 Hudson.Integrity 很好很简单,但是非常有限.我认为 Buildbot 更适合拥有大量的构建从站,而不是像我使用的那样在一台机器上运行所有东西它.
Update: After trying a few alternatives, I think I'll stick with Hudson. Integrity was nice and simple, but quite limited. I think Buildbot is better suited to having numerous build-slaves, rather than everything running on a single machine like I was using it.
为 Python 项目设置 Hudson 非常简单:
Setting Hudson up for a Python project was pretty simple:
- 从 http://hudson-ci.org/ 下载 Hudson
- 使用
java -jar hudson.war
运行它 - 在默认地址
http://localhost:8080
上打开网页界面 - 转到管理 Hudson、插件、点击更新"或类似内容
- 安装 Git 插件(我必须在 Hudson 全局首选项中设置
git
路径) - 新建项目,进入仓库,SCM轮询间隔等
- 如果还没有,请通过
easy_install
安装nosetests
- 在构建步骤中,添加
nosetests --with-xunit --verbose
- 勾选Publish JUnit test result report"并将Test report XMLs"设置为
**/nosetests.xml
- Download Hudson from http://hudson-ci.org/
- Run it with
java -jar hudson.war
- Open the web interface on the default address of
http://localhost:8080
- Go to Manage Hudson, Plugins, click "Update" or similar
- Install the Git plugin (I had to set the
git
path in the Hudson global preferences) - Create a new project, enter the repository, SCM polling intervals and so on
- Install
nosetests
viaeasy_install
if it's not already - In the a build step, add
nosetests --with-xunit --verbose
- Check "Publish JUnit test result report" and set "Test report XMLs" to
**/nosetests.xml
这就是我们所需要的.您可以设置电子邮件通知,插件值得一看.我目前用于 Python 项目的一些:
That's all that's required. You can setup email notifications, and the plugins are worth a look. A few I'm currently using for Python projects:
- SLOCCount 插件 计算代码行数(并绘制图表!) - 你需要单独安装 sloccount
- Violations 解析 PyLint 输出(您可以设置警告阈值、图表每次构建的违规次数)
- Cobertura 可以解析coverage.py 输出.Nosetest 可以在运行测试时收集覆盖率,使用
nosetests --with-coverage
(这会将输出写入**/coverage.xml
)
- SLOCCount plugin to count lines of code (and graph it!) - you need to install sloccount separately
- Violations to parse the PyLint output (you can setup warning thresholds, graph the number of violations over each build)
- Cobertura can parse the coverage.py output. Nosetest can gather coverage while running your tests, using
nosetests --with-coverage
(this writes the output to**/coverage.xml
)
解决方案
你可能想看看 Nose 和 Xunit 输出插件.你可以让它运行你的单元测试,并使用这个命令检查覆盖率:
You might want to check out Nose and the Xunit output plugin. You can have it run your unit tests, and coverage checks with this command:
nosetests --with-xunit --enable-cover
如果您想走 Jenkins 路线,或者如果您想使用另一个支持 JUnit 测试报告的 CI 服务器,这将很有帮助.
That'll be helpful if you want to go the Jenkins route, or if you want to use another CI server that has support for JUnit test reporting.
同样,您可以使用 针对 Jenkins 的违规插件 捕获 pylint 的输出
Similarly you can capture the output of pylint using the violations plugin for Jenkins
相关文章