Porting to native R support in Travis

Jim Hester edited this page Feb 15, 2016 · 7 revisions

Now that R is natively supported on Travis, most users are encouraged to switch.

The official documentation on R support in Travis lists all the options.

Simple configuration

If you've been using the sample config, your new .travis.yml is pretty simple:

language: r
sudo: false
cache: packages

You can add extra options (email notification, etc), but the defaults will work for you if you don't need any additional packages installed beyond your package dependencies. This caches your project's package dependencies, so repeated builds will be much quicker than without caching.

More complex configuration

The configuration for R builds in Travis is a bit different than this repo: it's a declarative approach, as opposed to the more imperative approach we use with travis-tool.sh. This means that instead of specifying a list of commands to run in a fixed order, you list your dependencies, and the system takes care of the rest. (Under the hood, it's mostly similar code -- we just use it differently.)

For installing dependencies, native support makes things easier: instead of running a sequence of install steps via travis-tool.sh, you specify a list of dependencies as a top-level configuration item in your .travis.yml. So what was previously

install:
  - ./travis-tool.sh aptget_install pkg1 pkg2
  - ./travis-tool.sh r_install rpkg1 rpkg2

now becomes

r_packages:
 - rpkg1
 - rpkg2
apt_packages:
 - pkg1
 - pkg2

Here's a quick conversion guide for the commonly used install commands:

r-travis command native config option
aptget_install apt_packages
(none) brew_packages
r_binary_install r_binary_packages
r_install r_packages
bioc_install bioc_packages
install_github r_github_packages

Note that the order listed here is the order these lists are processed on Travis -- so each list can depend on packages in the list before it already being installed. apt and brew packages are ignored if they aren't applicable on the OS where Travis is building.

With native support, we also simplify things by always installing LaTeX and pandoc, and building vignettes as part of the package check.

Environment variables

  • WARNINGS_ARE_ERRORS=1 -> warnings_are_errors: true
  • CRAN="http://cran.rstudio.com" -> cran: http://cran.rstudio.com
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.