想知道 Travis 的线人是做什么的,什么时候该用

我对 Git 非常陌生,在发现 GitHub 中的一个小错误后,我计划为 GitHub 上的一些开源项目做些贡献。在分叉并修复错误之后,我提出了一个 pull 请求,我注意到这个显示:

失败,特拉维斯 CI 版本失败

仔细查看细节,我发现它是由 Could not find .travis.yml引起的,这是非常有意义的,因为我没有签署到特拉维斯氯和添加。到存储库。

这是我第一次听说特拉维斯以及所谓的持续整合。这听起来很酷,所以为了了解更多,我在维基百科上查了一下。

Travis CI 是一个托管的、分布式的持续集成服务 用于构建和测试托管在 GitHub 上的项目。Travis CI 自动检测何时提交并推送到使用 Travis CI 的 GitHub 存储库,每次发生这种情况时,它都会尝试 构建项目并运行测试。这包括提交所有分支,而不仅仅是主分支。

我目前对特拉维斯 CI 的理解是,它所做的是自动将项目推到 git commit -am ".."上,我不太理解其中的一部分。

  1. 通过 构建项目并运行测试,它将运行哪些测试?它将如何“建造”这个项目呢?(比如把它编译成二进制文件?)

  2. 它声明“这包括对所有分支的提交”-但是如果我不想对所有分支提交该怎么办?

  3. 我完全不用 Travis Cl 可以吗?在什么情况下最好使用它(或者必须使用它) ?

31031 次浏览

The simplest way to explain Travis CI is that it runs your program's tests every time you commit to GitHub (this can be configured in many ways, and you can always disable builds on some branches). The point of this is that you can often discover very quickly if your commit broke something, and fix it before it becomes a problem. I would recommend running Travis CI on every GitHub repo that you have unit tests in and is using a programming language supported by Travis CI. Since setting up Travis CI is very easy, I don't normally see a good reason not to use it, unless you don't care if you have passing tests in your program or not. Feel free to leave a comment if you have any more questions. You can read more about Travis CI here.

As you have already discovered what is Travis-CI, I would directly point to the questions you have.

By building the project and run tests, what tests is it going to run? And how is it going to "build" the project? (like compiling it to binary?)

In the .travis.yml a file you're specifying your OS, the programming language, your repo branch, the project file name and other details. By reading this file, Travis-CI will use the specific compilers which installed on their server to compile our code. Probably they will have the same mechanism as we have for Github. For the first time, they might pull the code [if we have specified specific branches they might pull the code from those branches only]. Also, we have authenticated to use our account with Travis-CI, whenever we make a commit, there should be some notification should fire to Travis-CI server thus it will be recognized as a commit and it will start compiling.


It states that "This includes commits to all branches" - but what if I don't want to commit to all branches?

You can specify different branches or the master branch. And it should only compile the specific branches specified in .travis.yml file.


Is it alright if I don't use Travis Cl at all? Under what circumstances is it best to use it (or it must be used)?

Yes, it's alright. Not a big deal. But what benefits you will be missing by not using this easy to integrate engine with your repo. Everytime you commit it may possible that it miss something and it couldn't compile because of a code. How will you know? Thus, you should use Travis-CI.


I have written a blog post which you can read to know, what is Travis-CI, Continuous Integrations and how to linked Travis-CI with your Github Repo. I have written it for a Swift repository.

I think am in a very good position to answer you question as am currently learning Travis CI at the moment. The first problem you encountered in the first place is because the project you are contributing to is using Travis CI to test and build the project. If the project isn't using Travis CI, you wouldn't have come across such error.

The solution is checkout Travis CI website and learn how it work and how it affected the project you are working on. This will put you in a very good position to understand what's failing in your code and how to fix it.

To answer the first question about building the project.

By building the project and run tests, what tests is it going to run? And how is it going to "build" the project? (like compiling it to binary?)

It's means how the source code is processed before use/test. It depends on the language you are writing. For example, if the project is writing with PHP. It's not going to build my code into executable file like C/C++ source code. It will run my PHP code on PHP interpreter and test it as it does so. It still goes through the normal compiling process your preferred language goes through.