2 Continuous Integration Best Practices
This chapter summarizes our guidelines about continuous integration after explaining what continuous integration is.
Along with last chapter, it forms our guidelines for Software Peer Review.
2.1 Why use continuous integration (CI)?
All rOpenSci packages must use one form of continuous integration. This ensures that all commits, pull requests and new branches are run through R CMD check
. rOpenSci packages’ continuous integration must also be linked to a code coverage service, indicating how many lines are covered by unit tests.
Both test status and code coverage should be reported via badges in your package README.
R packages should have CI for all operating systems (Linux, Mac OSX, Windows) when they contain:
Compiled code
Java dependencies
Dependencies on other languages
Packages with system calls
Text munging such as getting people’s names (in order to find encoding issues).
Anything with file system / path calls
In case of any doubt regarding the applicability of these criteria to your package, it’s better to add CI for all operating systems. Most CI services standards setups for R packages allow this with not much hassle.
2.2 Which continuous integration service(s)?
There are a number of continuous integration services, including standalone services (CircleCI, AppVeyor), and others integrated into code hosting or related services (GitHub Actions, GitLab, AWS Code Pipeline). Different services support different operating system configurations.
GitHub Actions is a convenient option for many R developers who already use GitHub as it is integrated into the platform and supports all needed operating Systems. There are actions supported for the R ecosystem, as well and first-class support in the {usethis} package. All packages submitted to rOpenSci for peer review are checked by our own pkgcheck
system, described further in the Guide for Authors. These checks are also provided as a GitHub Action in the ropensci-review-tools/pkgcheck-action
repository. Packages authors are encouraged to use that action to confirm prior to submission that a package passes all of our checks. See our blog post for more information.
usethis supports CI setup for other systems, though these functions are soft-deprecated. rOpenSci also supports the circle package, which aids in setting up CircleCI pipelines, and the tic package for building more complicated CI pipelines.
2.2.0.1 Testing using different versions of R
We require that rOpenSci packages are tested against the latest, previous and development versions of R to ensure both backwards and forwards compatibility with base R.
Details of how to run tests/checks using different versions of R locally can be found in the R-hub vignette on running Local Linux checks with Docker.
You can fine tune the deployment of tests with each versions by using a testing matrix.
If you develop a package depending on or intended for Bioconductor, you might find biocthis relevant.
2.2.0.2 Minimizing build times on CI
You can use these tips to minimize build time on CI:
- Cache installation of packages. The default r-lib/actions do this.
2.2.1 Travis CI (Linux and Mac OSX)
We recommend moving away from Travis.
2.2.2 AppVeyor CI (Windows)
For continuous integration on Windows, see R + AppVeyor. Set it up using usethis::use_appveyor()
.
Here are tips to minimize AppVeyor build time:
Cache installation of packages. Example in a config file. It’ll already be in the config file if you set AppVeyor CI up using
usethis::use_appveyor()
.Enable rolling builds.
We no longer transfer AppVeyor projects to ropensci AppVeyor account so after transfer of your repo to rOpenSci’s “ropensci” GitHub organization the badge will be [](https://ci.appveyor.com/project/individualaccount/pkgname)
.
2.3 Test coverage
Continuous integration should also include reporting of test coverage via a testing service such as Codecov or Coveralls. See the README for the covr package for instructions, as well
as usethis::use_coverage()
.
If you run coverage on several CI services the results will be merged.
2.4 Even more CI: OpenCPU
After transfer to rOpenSci’s “ropensci” GitHub organization, each push to the repo will be built on OpenCPU and the person committing will receive a notification email. This is an additional CI service for package authors that allows for R functions in packages to be called remotely via https://ropensci.ocpu.io/ using the opencpu API. For more details about this service, consult the OpenCPU help page that also indicates where to ask questions.
2.5 Even more CI: rOpenSci docs
After transfer to rOpenSci’s “ropensci” GitHub organization, a pkgdown website will be built for your package after each push to the GitHub repo. You can find the status of these builds at https://dev.ropensci.org/job/package_name
, e.g. for magick
; and the website at https://docs.ropensci.org/package_name
, e.g. for magick
. The website build will use your pkgdown config file if you have one, except for the styling that will use the rotemplate
package. Please report bugs, questions and feature requests about the central builds at https://github.com/ropensci/docs/ and about the template at https://github.com/ropensci-org/rotemplate/.