R CMD Check
Ensure that when you release your package, all the unit tests are passing and it works in a clean environment.
Example of use: falcon R package
Expected output: Fail the pipeline if R CMD Check
fails.
Why should I use this?
R CMD Check
has around 50 checks, but the general jist is it will check your package is fit to install, and as part of that process run the unit tests. In many companies, you will be running potentially multiple versions of R in parrallel. To reflect that, this gh-action is updated to run across the last 3 R major versions, using a snapshot from the Posit Public Package Manager that reflects a relevant time frame for when that R version was latest.
If you have dependencies on other pharmaverse packages, it’s likely you will also want to run R CMD Check
using CRAN today + the bleading edge of the pharmaverse (which may be pre-CRAN) via pointing at their r-universe. If this is the case, please see the advanced usage below.
How do I set it up?
Below is an example of using this gh-action
whenever someone tries to make PR into your main
or devel
branch or updates the branch. We recomend you use this on both main
and devel
branches, as it will help you catch issues before they get into your main branch.
name: Run R-CMD-check
# sourced from phuse-org/devops-toolkit
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
check:
name: Check
uses: phuse-org/devops-toolkit/.github/workflows/R-CMD-check.yml@main
The deets
Advanced use
Using other CRAN-like repositories
To use other CRAN-like repositories in your workflow, you can specify them using the extra-repositories
option in the workflow file. This is particularly useful if your package depends on packages not available on CRAN or if you want to use the latest versions of packages from a specific repository.
In the example below, we add two additional repositories: https://pharmaverse.r-universe.dev/
and https://insightsengineering.r-universe.dev/
. These repositories are added in a whitespace-separated list to the extra-repositories
option. This allows R CMD Check
to access packages from these repositories as well as CRAN.
name: Run R-CMD-check
# Specify the event types here
jobs:
check:
name: Check
uses: phuse-org/devops-toolkit/.github/workflows/R-CMD-check.yml@main
# Use the option to add extra repositories.
# One or more repositories can be added in a whitespace-separated list.
# In the example below, we add https://pharmaverse.r-universe.dev/ and
# https://insightsengineering.r-universe.dev/ as additional repositories.
with:
extra-repositories: "https://pharmaverse.r-universe.dev/ https://insightsengineering.r-universe.dev/"