Continuous Integration for R packages

[This article was first published on ipub » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

What is git?

Git is a version control system, and the best I have worked with for that matter. 15 years ago, I was happy when my company decided to migrate from RCS to SVN. Branching became simple, and many daily problems just disappeared. So I shuned other source control versioning systems for a long time. Until I came across git, that is. git introduces the concept of de-central repositories, and branching is a very light-weight operation. This is not only attractive for open-source projects, but that’s where git shines the most. For example, it is very easy and natural to fork projects.

As a result of the success of git, there has been an ecosystem of servies, products and projects that grew around it in the past few years. One of the most prominent examples is github. github is a social network of git-hosted open-source projects. It also includes project management, bug tracking, and other features. And all for free.

For example, you can find our data.tree package on github: data.tree.

 

Using git with RStudio is easy, as it’s basically built in and comes for free out of the box.

What is CI?

github in turn has been so successful that soon enough an entire ecosystem of services built around github has started to bloom. One of these services is travis-ci. This is a Berlin, Germany based company that focused 100% on github.

CI – Continuous Integration, is basically a build server that triggers a build whenever you push changes to a source code repository.

There is many different build servers like Jenkins, TeamCity, Continuum, and many others. Some of them are easier to configure than others, of course.

What is Travis?

Travis is a service that offers CI on top of github.

As travis-ci is completely integrated with github, setting up continuous integration with travis is extremely simple, as long as your source code is hosted with github. For most platforms, CI can be turned on literally with two clicks. Unfortunately, R is not (yet) a first class citizen on travis-ci, so we need to tell travis-ci what it actually needs to do. Until recently, this was a bit cumbersome, as you can read in Yihui’s blog.

But luckily, the R package devtools and r-travis (which btw are both also hosted on github) are working hard on making this configuration as simple as possible. At the time of this writing, all you need to do to turn on ci for your R package is:

  1. host your R package on github
  2. create a .travis.yml file by installing devtools 
    library(devtools) devtools::use_travis()
  3. go to travis-ci.org, accept to link you github account with travis
  4. turn on ci for your project by switching the button shown in travis-ci

And if you want to customize your build, then you need to configure the .travis.yml file. It contains the entire travis configuration in YAML format. You can find some details in this blog entry.

Pitfalls

Vignettes

As of this writing, it is not yet straight forward to include vignette building into the travis build process. As a result, you get a warning like this:

Package vignette without corresponding PDF/HTML

To resolve this, you can set the option –no-manual in .travis.yaml like this:

env:
  global:
    - WARNINGS_ARE_ERRORS=1
    - R_BUILD_ARGS=--no-manual
    - R_CHECK_ARGS=--no-manual --as-cran

 

The post Continuous Integration for R packages appeared first on ipub.

To leave a comment for the author, please follow the link and comment on their blog: ipub » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)