21  Continuous integration

Second edition

You are reading the work-in-progress second edition of R Packages. This chapter is currently a dumping ground for ideas, and we don’t recommend reading it.

21.1 Introduction

21.2 Checking after every commit with GitHub actions

If you’re using GitHub, as we recommend, you should also use GitHub Actions. GitHub Actions allow you to run code every time you push to GitHub.

To use GitHub Actions:

  1. Run usethis::use_github_action_check_standard() to set up a GitHub Action that runs R CMD check on Linux, Mac, and Windows. Literally, this adds a new file to your package, below .github/workflows/.

  2. Commit this new file and push to GitHub.

  3. Wait a few minutes to see the results in your email.

With this setup in place, R CMD check will be run every time you push to GitHub or whenever someone submits a pull request. You’ll find out about failures right away, which makes them easier to fix. Using automated checks also encourages me to check more often locally, because I know if it fails I’ll find out about it a few minutes later, often once I’ve moved on to a new problem.

21.2.1 Other uses

Since GitHub Actions allows you to run arbitrary code, there are many other things that you can use it for:

  • Re-publishing a book website every time you make a change to the source. (Like this book!)

  • Building vignettes and publishing them to a website.

  • Automatically building a documentation website for your package.

Learn more about using GitHub Actions with R at https://github.com/r-lib/actions/tree/master/examples.