/renv-actions-test

A repo containing a GitHub Action for performing R CMD check on package subdirectories of a monorepo (with or without using `renv`)

Primary LanguageRMIT LicenseMIT

renv-actions-test

R-CMD-check

This repository demonstrates how to set up GitHub Actions which will run R CMD check on packages.

Key features

  • This Action works whether or not the package uses renv
  • It caches installed package dependencies for quicker runtime
  • It is compatible with monorepos - allowing the developer to specify a subdirectory in which all packages live as a top level paths: filter, and then specific subdirectories (using dorney/paths-filter) which will ensure the Action only runs when files in these specific subdirectories are modified

See the PRs of this repo for examples:

  • #1 does not use renv
  • #3 does use renv

Setup

  1. Create a .github/workflows directory in the top level of your repo / monorepo
  2. Copy the .github/workflows/R-CMD-check.yaml file into this .github/workflows directory
  3. Modify the paths: part of the YAML file to specify the subdirectory in which all your packages live (or delete it altogether if there is no specific subdirectory where they all live):
name: R-CMD-check
on:
  pull_request:
    branches:
      - main
      - master
    paths:
      - 'packages/**'  # << the subdirectory where your packages live goes here
  1. Add the package directories to matrix.pkgs. The label will be used in a filename, so avoid spaces.
strategy:
      fail-fast: false
      matrix:
        pkgs:  # << list the individual directories where each package lives
          - {label: app-one, dir: packages/app.one}
          - {label: app-two, dir: packages/app.two}
        config:
          - {os: macOS-latest, r: 'release'}
  1. Make pull requests and stuff

Removing a package from GitHub Actions scrutiny

Simply remove it from the matrix.path:

strategy:
      fail-fast: false
      matrix:
        pkgs:  # << list the individual directories where each package lives
          # - {label: app-one, dir: packages/app.one} (commented out so not checked)
          - {label: app-two, dir: packages/app.two}
        config:
          - {os: macOS-latest, r: 'release'}

Waiving checks for a specific PR

You can skip all checks (as long as the settings for your repo permit) for all actions by adding [skip ci] to the commit message before pushing. Read more here.

An example of this can be seen on this PR in this repo.