Unit Tests
Updated 11 Days AgoPublic

How to do Continuous Integration (CI)

There are two ways of doing unit testing in c4science

Using Jenkins on c4science

Access

Jenkins on c4science is in private beta mode. You can ask to have access. Once you're given access to the group #jenkins_access
you will see a Jenkins Job tab on every of your repository and a Create Jenkins Jobon your Project.

How this works

You can create a new Job from a Project page or from the Jenkins application. You'll have to provide a Project that will be used as Policy for the job. Only the people in the Project will have access to the Job on Jenkins. You also have to provide a branch the Job will use.

Once you created the job, a Harbormaster build plan and a Herald commit rule will automatically be created. The Herald rule triggers the Harbormaster build plan on new commit on the Repository/Branch couple. The build plan then call the new Jenkins Job.

You can see the status of the job from the Project page and the Repository page, as well as the link to the Jenkins job.

Jenkinsfile

The most important part of the setup is the Jenkinsfile. It is a file that must be present in your repository/branch the job will execute against. This file contains a set of options and command that define your Job.

Examples
  • You can find basic example in this repo: rPHJENKINS and discuss about the experience in the chatroom

Using Arcanist on your local machine

We'll be using a community extensions to integrate your custom unit test engine with Phabricator. This extensions allows any TAP compatible engine to be used. You can also write your own engine, take a look at the documentation.

  • In your repository
  • Add the lib as a submodule
git submodule add https://github.com/tagview/arcanist-extensions.git .arcanist-extensions
git submodule update --init
  • Create an .arcconfig file with the following content
{
  "load": [
    ".arcanist-extensions/tap_test_engine"
  ],

  "unit.engine": "TAPTestEngine",
  "unit.engine.tap.command": "your_unit_test_script.sh"
}
  • Replace your_unit_test_script.sh by a script in your repository that do the unit testing and returns the result in a TAP format
  • For instance if your code is in python, you can use tap.py, see the example in rPHTEST
  • Those tests can be run by using the arc unit command or it will be run automatically when you create a Differential Revision using Arcanist (arc diff)
Last Author
aubort
Projects
Subscribers
None