git 试图了解 Travis CI 的作用以及何时应该使用它

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22587148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:54:40  来源:igfitidea点击:

Trying to understand what Travis CI does and when it should be used

gittravis-cigit-flow

提问by trying to figure it out

I am very new to Git and I am planning to contribute to some open-source project on GitHub after discovering a small error in it. Upon forking it and fixing the error, I purposed a pull request and I noticed this showing up:

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

Failed — The Travis CI build failed

失败 - Travis CI 构建失败

Looking into the details I discovered it was caused by Could not find .travis.yml, which made perfect sense since I had not signed in to Travis Cl with and add .travis.yml to the repository.

查看详细信息,我发现它是由 引起的Could not find .travis.yml,这是完全合理的,因为我没有使用 .travis.yml 登录到 Travis Cl 并将其添加到存储库中。

This is my first time hearing about Travis and what that is known as continuous integration. And it sounds pretty cool so in order to learn more about it, I looked it up on Wikipedia.

这是我第一次听说 Travis 以及所谓的持续集成。听起来很酷,所以为了了解更多信息,我在维基百科上查了一下。

Travis CI is a hosted, distributed continuous integration service used to build and test projects hosted at GitHub. Travis CI automatically detects when a commit has been made and pushed to a GitHub repository that is using Travis CI, and each time this happens, it will try to build the project and run tests. This includes commits to all branches, not just to the master branch.

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

My current understanding of Travis CI is that what it does is automatically pushing the project upon git commit -am ".."and I don't quite understand some part of it.

我目前对 Travis CI 的理解是它所做的是自动推动项目git commit -am "..",我不太了解其中的某些部分。

  1. 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?)

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

  3. 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)?

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

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

  3. 如果我根本不使用 Travis Cl 可以吗?在什么情况下最好使用(或必须使用)?

回答by joshua-anderson

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.

解释 Travis CI 的最简单方法是,每次提交到 GitHub 时它都会运行程序的测试(这可以通过多种方式进行配置,并且您始终可以在某些分支上禁用构建)。这样做的重点是,你通常可以很快发现你的提交是否破坏了某些东西,并在它成为问题之前修复它。我建议在每个有单元测试的 GitHub 存储库上运行 Travis CI,并且使用 Travis CI 支持的编程语言。由于设置 Travis CI 非常简单,我通常认为没有理由不使用它,除非您不在乎是否在程序中通过了测试。如果您还有其他问题,请随时发表评论。您可以在此处阅读有关 Travis CI 的更多信息。

回答by Hemang

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

由于您已经发现了什么是 Travis-CI,我将直接指出您的问题。

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.ymla 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.

.travis.yml一个文件中,您要指定您的操作系统、编程语言、您的存储库分支、项目文件名和其他详细信息。通过读取此文件,Travis-CI 将使用安装在其服务器上的特定编译器来编译我们的代码。可能它们将具有与我们在 Github 中相同的机制。第一次,他们可能会拉取代码 [如果我们指定了特定的分支,他们可能只会从这些分支拉取代码]。此外,我们已经通过 Travis-CI 认证使用我们的帐户,每当我们进行提交时,应该有一些通知应该发送到 Travis-CI 服务器,因此它将被识别为提交并开始编译。



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 masterbranch. And it should only compile the specific branches specified in .travis.ymlfile.

您可以指定不同的分支或master分支。它应该只编译.travis.yml文件中指定的特定分支。



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)?

如果我根本不使用 Travis Cl 可以吗?在什么情况下最好使用(或必须使用)?

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.

是的,没关系。没什么大不了的。但是如果不使用这个易于集成的引擎与您的存储库,您将失去什么好处。每次提交时,它可能会遗漏某些内容并且由于代码而无法编译。你怎么知道?因此,您应该使用 Travis-CI。



I have written a blog postwhich 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.

我写了一个博客帖子,你可以看了就知道,什么是特拉维斯-CI,持续集成和如何联系特拉维斯-CI与你的GitHub库。我已经为 Swift 存储库编写了它。

回答by Emmanuel

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.

我认为我可以很好地回答你的问题,因为我目前正在学习 Travis CI。您首先遇到的第一个问题是因为您正在贡献的项目是使用 Travis CI 来测试和构建项目。如果项目没有使用 Travis CI,你就不会遇到这样的错误。

The solution is checkout Travis CI websiteand 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.

解决方案是查看 Travis CI 网站并了解它是如何工作的以及它如何影响您正在处理的项目。这将使您处于非常有利的位置,以了解您的代码中出现了什么问题以及如何修复它。

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.

这意味着在使用/测试之前如何处理源代码。这取决于您正在编写的语言。例如,如果项目是用 PHP 编写的。它不会像 C/C++ 源代码那样将我的代码构建成可执行文件。它将在 PHP 解释器上运行我的 PHP 代码并在执行时对其进行测试。它仍然会经历您的首选语言所经历的正常编译过程。