R Travis

R Travis

In this post we will explore how to set up R package development on github focusing on implementing an automatic Travis and codecoverage check.

I set up a sample repo that will include a very basic configuration: TravisR

Travis

Travis is a great You can easily sign up by connecting your github account:

Travis CI

You will need to select the repository want to have checked and save this in a file called travis.yml:

# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages

r_packages:
  - covr
  - devtools

after_success:
  - Rscript -e 'library(covr); codecov()'

# safelist
branches:
  only:
  - master
  - development

As you can see I already added the covr support. This is what a succesful Travis build looks like:

Travis CI

codecov

codecov is a tool to “group, merge, archive, and compare coverage reports.” It is free for open source.

Again we can easily sign up or sign in by using our github account. This method has the great advantage of directly being able to choose the repository we want to have checked.

Travis CI

You can easily select the repository that you want to have covered and afterwards it will directly provide you with a token, like so:

Travis CI

You can use this token to either create another .yml-file with all the necessary configuration. Or you could simply add the token in the setting environments of the Travis CI Build, like here:

Travis CI

In order to get the cool badges add this to your READ.ME:

[![Build Status](https://travis-ci.com/thomaslaber/TravisR.svg?branch=master)](https://travis-ci.com/thomaslaber/TravisR)
[![codecov](https://codecov.io/gh/thomaslaber/TravisR/branch/master/graph/badge.svg)](https://codecov.io/gh/thomaslaber/TravisR)

For an overview of available badges have a look here: Badges

This is what the final result looks like:

Travis CI