Skip to content
Kirill Müller edited this page Nov 7, 2013 · 43 revisions

Getting started

  • Visit https://travis-ci.org/profile and flip the switch for the project you want to test

    • Sign up if necessary
  • Two options:

    • Paste the following into a terminal that has the current directory set to the root of the GitHub repository of your R package:
git checkout -b travis &&
wget https://github.com/craigcitro/r-travis/raw/master/sample.travis.yml -O .travis.yml &&
echo '^\.travis\.yml$' >> .Rbuildignore &&
git add .travis.yml .Rbuildignore &&
git commit -m "enable continuous integration via craigcitro/r-travis" &&
git push origin travis

(This assumes that you have set up and are allowed to push to the remote origin, which is the default setting.)

- TODO: Add instructions for GUI/GitHub users
  • Tweak .travis.yml and/or your package until you are satisfied with results and run times of the tests

  • Merge the travis branch into your main branch (usually master)

Configuration Options

OSX

To build on OSX in addition to Ubuntu, execute scripts/create-osx.sh. The script will create a branch with suffix -osx that has the necessary changes made in .travis.yml to let the tests run on OS X instead of Ubuntu. If such a branch exists, it will be updated. As usual, to trigger the test you must push your changes to GitHub, for a new branch use the --all switch:

git push [--all]

Note that it's not currently possible to have one branch that runs tests on both Linux and OSX.

You can also create a link to this script in your private bin directory:

ln -s /path-to-r-travis/scripts/create-osx.sh ~/bin/

If you want to test exclusively on OS X (not recommended), simply change language to objective-c in your .travis.yml file.

Build and test options

Options used for building or testing your R package can be controlled by uncommenting one or both of the following; the values here are the defaults, which live in travis-tool.sh:

 env:
   global:
     - CRAN: http://cran.rstudio.com
     - R_BUILD_ARGS="--no-build-vignettes --no-manual"
     - R_CHECK_ARGS="--no-build-vignettes --no-manual --as-cran"
     - BOOTSTRAP_LATEX=""

See the travis docs for more information.

Logs

To only dump logs on failure by using after_failure instead of after_script.

after_script:
  - ./travis-tool.sh dump_logs

Selective testing of branches

To restrict the branches to test, see the travis docs. For instance, to tests all branches except those with suffix -expt ("experimental"), use

 branches:
   except:
     - /-expt$/

Note that in general it is advisable to test (almost) all branches in order to automatically test pending pull requests.

Install non-R dependencies

Some R packages, such as rgdal, require libraries that are not present on the system by default. These requirements are listed in the SystemRequirements section of the package's DESCRIPTION. To use such packages for Travis, these requirements must be installed in advance.

Ubuntu

In many cases, dependencies are available in the standard Ubuntu package repository and can be installed through ./travis-tool.sh aptget_install. This command internally calls apt-get install. Figuring out the name of the corresponding Ubuntu package from a SystemRequirements entry in DESCRIPTION is mostly manual work. If an Ubuntu installation is available, the tool apt-file helps determining which packages provide a certain file; missing files are reported when an R package fails to install due to a missing dependency.

OS X

No neat solution available yet. Comment on #61 if your dependencies are packaged as a .pkg file.

Recipes

Clone this wiki locally