Project

General

Profile

Actions

Task #1117

closed

study the method to integrate Gerrit Code Review and Travis CI

Added by Junxiao Shi about 10 years ago. Updated about 10 years ago.

Status:
Abandoned
Priority:
Normal
Assignee:
Category:
Build
Target version:
Start date:
Due date:
% Done:

40%

Estimated time:

Description

Using Gerrit Code Review in an Open Source Project page 21 mentions both Jenkins and Travis CI could be used with Gerrit.

Travis CI is tied to GitHub, but Gerrit (with some scripts) could fork the repo on GitHub and create a pull request with the patchsets, which would be picked up by Travis CI and compiled. The results of compilation and unit testing are written back to Gerrit as comments.

This task shall study the feasibility on triggering Travis CI from Gerrit via the methods mentioned in the slides.

If such integration is feasible, produce a document on the steps to setup such an integration.


Related issues 1 (0 open1 closed)

Related to NFD - Task #1164: Setup Jenkins to perform basic integrated tests and connect it to Gerrit Code ReviewClosedYi Huang01/29/2014

Actions
Actions #2

Updated by Junxiao Shi about 10 years ago

  • Assignee set to Yingdi Yu
Actions #3

Updated by Junxiao Shi about 10 years ago

  • Assignee changed from Yingdi Yu to Yi Huang
Actions #4

Updated by Alex Afanasyev about 10 years ago

  • Target version set to Mock
Actions #5

Updated by Yi Huang about 10 years ago

  • % Done changed from 0 to 60
Actions #6

Updated by Junxiao Shi about 10 years ago

  • Status changed from New to In Progress
  • Estimated time changed from 12.00 h to 30.00 h

The basic procedure I can imagine is below.

  • The primary repository is on Gerrit.
  • A GitHub repository is a mirror of the primary repository. The master branch of GitHub repository always tracks the master branch of primary repository, which contains approved changes.

Change workflow:

  1. Developer submits a patchset to Gerrit
  2. The script is notified about a new patchset (triggered by email or some other hook from Gerrit)
  3. The script pulls the patchset to a local repository, pushes it to a new branch on GitHub, and creates a pull request from that branch into the master branch of GitHub repository
  4. The script adds one commit that changes Travis CI from Ubuntu compilation to OS X compilation, pushed it to another new branch on GitHub, and creates another pull request from that branch into the master branch of GitHub repository
  5. Travis CI will pick up both pull requests and verify them
  6. The script is notified about a new verification result (triggered by email or some other hook from Travis CI)
  7. The script retrieves the verification results, and adds them as comments of the patchset on Gerrit. The vote is derived from whether the verification is successful or not.
  8. The script rejects both pull requests on GitHub, and deletes both new branches
Actions #7

Updated by Alex Afanasyev about 10 years ago

I will not say it is not possible to set up travis to do this work, but I'm kind of pessimistic about the benefits vs. time spent on figuring out how everything can work.

From what I gathered during brief experiments, it would be way easier to set up our own Jenkins server and create a job that would dispatch upon notification from gerrit and post reviews. In the simple scenario (and I would go for now with it), we need to set up environments (=servers/machines/or vms) in which code will be compiled (linux, freebsd, osx)---what I mean is that we just install all necessary dependencies once and compile code multiple times. When everything works, we can think how to check dependencies (do we really need to check them every time?).

Actions #8

Updated by Junxiao Shi about 10 years ago

This task focuses on the feasibility of Gerrit-Travis CI setup.
If assignee thinks it's infeasible (incl taking too much work), the response should be "infeasible" and this task is completed.

I will write another task about setting up Gerrit-Jenkins.

Actions #9

Updated by Yi Huang about 10 years ago

I've done writing python script to create two branches and tested that travis can pick up two pull-requets (for ubuntu and osx). Also, a second script that discard the two pull requests and delete the branches is almost done. I think the only thing I'm not sure is that how to hook and pull patch-set from Gerrit and how to get those two scripts triggered.

Actions #10

Updated by Junxiao Shi about 10 years ago

Yi Huang wrote:

I think the only thing I'm not sure is that how to hook and pull patch-set from Gerrit and how to get those two scripts triggered.

Gerrit-to-GitHub script can be triggered with patchset-created hook.

Pulling patch-set from Gerrit is simply a git pull command, once you know the numeric change id.

I'm not sure how Travis CI notifies about a successful or failed build.
If it has a web hook, you can trigger the script via CGI.
If it sends an email, you can configure postfix mail server to trigger the script.

Actions #11

Updated by Alex Afanasyev about 10 years ago

I'm not sure how Travis CI notifies about a successful or failed build.
If it has a web hook, you can trigger the script via CGI.
If it sends an email, you can configure postfix mail server to trigger the script.

There are a number of different ways Travis CI allow notificateions (http://docs.travis-ci.com/user/notifications/). The simplest and fastest way seem to be Webhook notification (with proper authorization of course).

Actions #12

Updated by Yi Huang about 10 years ago

Junxiao Shi wrote:

Yi Huang wrote:
Gerrit-to-GitHub script can be triggered with patchset-created hook.

Pulling patch-set from Gerrit is simply a git pull command, once you know the numeric change id.

I read the doc page and I just want to make sure I understand how patchset-created hook works.
Does that mean my script should be called patchset-created and should be placed in the hook directory. Gerrit will call it with the command "patchset-created --change --is-draft --change-url --project --branch --topic --uploader --commit --patchset " when a patchset is created?

And what is the clone url for our gerrit server? I think I can't use "git pull-request" on this clone url since it is not GitHub. Is that correct?

Also I think it will be better for me to have access to our gerrit server to explore more about it.

Actions #13

Updated by Junxiao Shi about 10 years ago

Gerrit looks in '$site_path'/hooks for executables with names listed below.

This needs SSH access to the Gerrit server machine.
I suggest you try the setup on a virtual machine with a separate instance of Gerrit.
gerrit.named-data.net is a production environment, you shouldn’t experiment on it. Once you know the method and write down the steps, we could deploy it there.

Actions #14

Updated by Junxiao Shi about 10 years ago

I remember that in the slides, author mentions that interested users could contact him to obtain some information.
If the assignee of this task hasn't done so, he should contact the author.

Actions #15

Updated by Alex Afanasyev about 10 years ago

Yi. I think we are wasting time trying to make travis-ci do something that is too complicated. I would suggest you to create a simple .travis.yml and submit it to gerrit, so we can actually start using it (at least with linux).

After that, please move to the new issue #1164 to set up jenkinks, create jenkins job, and figure out which plugins we need to use to connect it to gerrit.

Actions #16

Updated by Alex Afanasyev about 10 years ago

  • Status changed from In Progress to Abandoned
  • % Done changed from 0 to 40

Mark this as abandoned for now. We have connected our github to travis-ci (only for linux-based testing). The rest will try to do in jenkins

Actions #17

Updated by Junxiao Shi about 10 years ago

  • Category set to Build
Actions

Also available in: Atom PDF