rhub

Tools for R Package Developers


Keywords
r, r-package, rstats
License
MIT

Documentation

rhub

R-hub v2

Lifecycle: experimental R-CMD-check Codecov test coverage

R-hub v2 uses GitHub Actions to run R CMD check and similar package checks. The rhub package helps you set up R-hub v2 for your R package, and start running checks.


Installation

Install rhub from CRAN:

pak::pkg_install("rhub")

Usage

Requirements

  • A Github account.
  • Your R package must be in a GitHub repository.
  • You need a GitHub Personal Access Token. You can use the gitcreds package to add the token to the git credential store.

See the R Consortium runners section for using rhub if your package is not on GitHub.

Private repositories

rhub uses GitHub Actions, which is free for public repositories. For private repositories you also get some minutes for free, depending on the GitHub subscription you have. See About billing for GitHub Actions for details.

Setup

  1. Switch to the directory of your package, and call rhub::rhub_setup() to add the R-hub workflow file to your package.
rhub::rhub_setup()
## Setting up R-hub v2.                                                            
## βœ” Found R package at /private/tmp/cli.                                          
## βœ” Found git repository at /private/tmp/cli.                                     
## βœ” Created workflow file /private/tmp/cli/.github/workflows/rhub.yaml.           
##                                                                                 
## Notes:                                                                          
## β€’ The workflow file must be added to the default branch of the GitHub           
##   repository.                                                                   
## β€’ GitHub actions must be enabled for the repository. They are disabled for      
##   forked repositories by default.                                               
##                                                                                 
## Next steps:                                                                     
## β€’ Add the workflow file to git using `git add <filename>`.                      
## β€’ Commit it to git using `git commit`.                                          
## β€’ Push the commit to GitHub using `git push`.                                   
## β€’ Call `rhub2::rhub_doctor()` to check that you have set up R-hub correctly.    
## β€’ Call `rhub2::rhub_check()` to check your package.                             
  1. Run git commit and git push to push the workflow file to GitHub.

  2. Run rhub::rhub_doctor() to check if everything is set up correctly:

rhub::rhub_doctor()
## βœ” Found R package at /private/tmp/cli.                                          
## βœ” Found git repository at /private/tmp/cli.                                     
## βœ” Found GitHub PAT.                                                             
## βœ” Found repository on GitHub at <https://github.com/r-lib/cli>.                 
## βœ” GitHub PAT has the right scopes.                                              
## βœ” Found R-hub workflow in default branch, and it is active.                     
## β†’ WOOT! You are ready to run `rhub2::rhub_check()` on this package.             

Run checks

Use rhub::rhub_platforms() to get a list of supported platforms and checks:

rhub::rhub_platforms()
## ── Virtual machines ─────────────────────────────────────────────────────────── 
##  1 [VM]  linux                                                                  
##    All R versions on GitHub Actions ubuntu-latest                               
##  2 [VM]  macos                                                                  
##    All R versions on GitHub Actions macos-latest                                
##  3 [VM]  macos-arm64                                                            
##    All R versions on GitHub Actions macos-14                                    
##  4 [VM]  windows                                                                
##    All R versions on GitHub Actions windows-latest                              
##                                                                                 
## ── Containers ───────────────────────────────────────────────────────────────── 
##  5 [CT]  atlas  [ATLAS]                                                         
##    R Under development (unstable) (2024-03-13 r86113) on Fedora Linux 38 (Conta…
##    ghcr.io/r-hub/containers/atlas:latest                                        
##  6 [CT]  clang-asan  [asan, clang-ASAN, clang-UBSAN, ubsan]                     
##    R Under development (unstable) (2024-03-12 r86109) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/clang-asan:latest                                   
##  7 [CT]  clang16  [clang16]                                                     
##    R Under development (unstable) (2024-03-12 r86109) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/clang16:latest                                      
##  8 [CT]  clang17  [clang17]                                                     
##    R Under development (unstable) (2024-03-11 r86098) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/clang17:latest                                      
##  9 [CT]  clang18  [clang18]                                                     
##    R Under development (unstable) (2024-03-12 r86109) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/clang18:latest                                      
## 10 [CT]  donttest  [donttest]                                                   
##    R Under development (unstable) (2024-03-12 r86109) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/donttest:latest                                     
## 11 [CT]  gcc13  [gcc13]                                                         
##    R Under development (unstable) (2024-03-13 r86113) on Fedora Linux 38 (Conta…
##    ghcr.io/r-hub/containers/gcc13:latest                                        
## 12 [CT]  intel  [Intel]                                                         
##    R Under development (unstable) (2024-03-13 r86113) on Fedora Linux 38 (Conta…
##    ghcr.io/r-hub/containers/intel:latest                                        
## 13 [CT]  mkl  [MKL]                                                             
##    R Under development (unstable) (2024-03-13 r86113) on Fedora Linux 38 (Conta…
##    ghcr.io/r-hub/containers/mkl:latest                                          
## 14 [CT]  nold  [noLD]                                                           
##    R Under development (unstable) (2024-03-13 r86113) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/nold:latest                                         
## 15 [CT]  nosuggests  [noSuggests]                                               
##    R Under development (unstable) (2024-03-13 r86113) on Fedora Linux 38 (Conta…
##    ghcr.io/r-hub/containers/nosuggests:latest                                   
## 16 [CT]  ubuntu-clang  [r-devel-linux-x86_64-debian-clang]                      
##    R Under development (unstable) (2024-03-13 r86113) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/ubuntu-clang:latest                                 
## 17 [CT]  ubuntu-gcc12  [r-devel-linux-x86_64-debian-gcc]                        
##    R Under development (unstable) (2024-03-13 r86113) on Ubuntu 22.04.4 LTS     
##    ghcr.io/r-hub/containers/ubuntu-gcc12:latest                                 
## 18 [CT]  ubuntu-next  [r-next, r-patched, r-patched-linux-x86_64]               
##    R version 4.3.3 Patched (2024-02-29 r86113) on Ubuntu 22.04.4 LTS            
##    ghcr.io/r-hub/containers/ubuntu-next:latest                                  
## 19 [CT]  ubuntu-release  [r-release, r-release-linux-x86_64, ubuntu]            
##    R version 4.3.3 (2024-02-29) on Ubuntu 22.04.4 LTS                           
##    ghcr.io/r-hub/containers/ubuntu-release:latest                               
## 20 [CT]  valgrind  [valgrind]                                                   
##    R Under development (unstable) (2024-03-13 r86113) on Fedora Linux 38 (Conta…
##    ghcr.io/r-hub/containers/valgrind:latest                                     

Run rhub::rhub_check() to start R-hub v2 checks on GitHub Actions:

rhub::rhub_check()
## βœ” Found git repository at /private/tmp/cli.                                     
## βœ” Found GitHub PAT.                                                             
##                                                                                 
## Available platforms (see `rhub2::rhub_platforms()` for details):                
##                                                                                 
##  1 [VM] linux          R-* (any version)                     ubuntu-latest on G…
##  2 [VM] macos          R-* (any version)                     macos-latest on Gi…
##  3 [VM] macos-arm64    R-* (any version)                     macos-14 on GitHub 
##  4 [VM] windows        R-* (any version)                     windows-latest on …
##  5 [CT] atlas          R-devel (2024-03-13 r86113)           Fedora Linux 38 (C…
##  6 [CT] clang-asan     R-devel (2024-03-12 r86109)           Ubuntu 22.04.4 LTS 
##  7 [CT] clang16        R-devel (2024-03-12 r86109)           Ubuntu 22.04.4 LTS 
##  8 [CT] clang17        R-devel (2024-03-11 r86098)           Ubuntu 22.04.4 LTS 
##  9 [CT] clang18        R-devel (2024-03-12 r86109)           Ubuntu 22.04.4 LTS 
## 10 [CT] donttest       R-devel (2024-03-12 r86109)           Ubuntu 22.04.4 LTS 
## 11 [CT] gcc13          R-devel (2024-03-13 r86113)           Fedora Linux 38 (C…
## 12 [CT] intel          R-devel (2024-03-13 r86113)           Fedora Linux 38 (C…
## 13 [CT] mkl            R-devel (2024-03-13 r86113)           Fedora Linux 38 (C…
## 14 [CT] nold           R-devel (2024-03-13 r86113)           Ubuntu 22.04.4 LTS 
## 15 [CT] nosuggests     R-devel (2024-03-13 r86113)           Fedora Linux 38 (C…
## 16 [CT] ubuntu-clang   R-devel (2024-03-13 r86113)           Ubuntu 22.04.4 LTS 
## 17 [CT] ubuntu-gcc12   R-devel (2024-03-13 r86113)           Ubuntu 22.04.4 LTS 
## 18 [CT] ubuntu-next    R-4.3.3 (patched) (2024-02-29 r86113) Ubuntu 22.04.4 LTS 
## 19 [CT] ubuntu-release R-4.3.3 (2024-02-29)                  Ubuntu 22.04.4 LTS 
## 20 [CT] valgrind       R-devel (2024-03-13 r86113)           Fedora Linux 38 (C…
##                                                                                 
## Selection (comma separated numbers, 0 to cancel): 1, 5                          
##                                                                                 
## βœ” Check started: linux, atlas (daft-acornwoodpecker).                           
##   See <https://github.com/r-lib/cli/actions> for live output!                   

The R Consortium runners

If you don’t want to put your package on GitHub, you can still use the rhub package to run package checks on any supported platform using a shared pool of runners in the https://github.com/r-hub2 GitHub organization.

The process is similar to the first version of R-hub:

  • Set your working directory to the R package you want to check.

  • Obtain a token from R-hub, to verify your email address:

    rc_new_token()
    

    (You do not need to do this, if you already submitted packages to a previous version of R-hub from the same machine, using the same email address. Call rc_list_local_tokens() to check if you already have tokens.)

  • Submit a build with

    rc_submit()
    
  • Select the platforms you want to use, and follow the instructions and the link provided to see your check results.

Limitations of the R Consortium runners

  • You package will be public for the world, and will be stored in the https://github.com/r-hub2 organization. Your check output and results will be public for anyone with a GitHub account. If you want to keep your package private, you can put it in a private GitHub repository, and use the rhub_setup() and rhub_check() functions instead.
  • The R Consortium runners are shared among all users, so you might need to wait for your builds to start.
  • You have to wait at least five minutes between submissions with rc_submit().
  • Currently you need to create a GitHub account to see the check logs of your package. You don’t need a GitHub account to submit the checks.

To avoid these limitations (except for the neeed for a GitHub accounr), put your package in a GitHub repository, and use the rhub_setup() and rhub_check() functions instead of rc_submit() and the R Consortium runners.

Code of Conduct

Please note that the rhub package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

MIT Β© R Consortium