README.md

Build Status Coverage Status

Building R packages with Travis CI containers

This repository contains an example R package that is built using the container-based infrastructure from Travis CI.

NOTE: As of March 2016, Travis CI supports R using containers through the default option language: r, which renders this repository obsolete. See here.

The container-based infrastructure from Travis CI to build R packages can be very fast when we cache dependent packages. The main difference between the containerized infrastructure and the "traditional" approach is that with containers we cannot use sudo anymore. Therefore, we cannot piece together our favorite version of R using sudo apt-get install or rely on binary packages (e.g. from c2d4u).

To use R from within the container I added the following lines to my .travis.yml:

addons:
  apt:
    sources:
    - r-packages-precise
    packages:
    - r-base-dev

The list of sources and packages that Travis allows is fairly limited. However, r-packages-precise is white-listed and contains an up-to-date release of R.

I store all installed R packages in the directory ~/Rlib that is eventually going be cached.

cache:
  directories: 
    - ~/Rlib

To illustrate how long all of this takes, I put together a package with lots of "heavy" dependencies: Rcpp, RcppArmadillo, and ggplot2.

| | Duration | |---------------------------|---------------| | Initial build time without cache (log file) | 9 min 2 sec | | All subsequent builds that cache dependencies (log file) | 1 min 0 sec |

See also

Yihui Xie also uses the container based infrastructure to build R packages on travis, e.g. for knitr and rmarkdown. His .travis.yml looks very similar to what I use in this repository. Yihui resolved issues stemming from old pandoc and texlive versions by putting together precompiled versions of pandoc and texlive.



jtilly/R-travis-container-example documentation built on May 20, 2019, 3:13 a.m.