🚩🚩🚩 This repo is intended for internal use only. Sweeping changes will be made without notice. 🚩🚩🚩
A reusable workflow is a workflow that is defined in a single location but can be executed from another location as if it was locally defined. Link: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows
This workflow below should be copied into your repo at .github/workflows/R-CMD-check.yaml
# Workflow derived from https://github.com/rstudio/shiny-workflows
#
# NOTE: This Shiny team GHA workflow is overkill for most R packages.
# For most R packages it is better to use https://github.com/r-lib/actions
on:
push:
branches: [main, rc-**]
pull_request:
workflow_dispatch:
name: Package checks
jobs:
website:
uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1
routine:
uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1
with:
format-r-code: true
R-CMD-check:
uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1This file is also available as examples/pkg-r.yaml, so it can be installed directly:
usethis::use_github_action(
url = file.path(
"https://raw.githubusercontent.com/rstudio/shiny-workflows",
"main/examples/pkg-r.yaml"
)
)To run any of the three workflows on its own triggers, adopt the matching file from examples/ instead and drop that job from Package checks.
There are three main reusable workflows to be used by packages in the shiny-verse
website.yaml- This is a wrapper for building a
{pkgdown}website and deploying it to thegh-pagesbranch of the repo. - Packages included in the
DESCRIPTIONfieldConfig/Needs/websitewill also be installed - The site is deployed on
push,workflow_dispatch, andrepository_dispatchevents. On other events (such aspull_request), the site is only built and verified. - To run the site as its own workflow, so that it can also be rebuilt on demand without running the rest of
Package checks, copyexamples/website.yamlinto your repo and drop thewebsitejob fromPackage checks. See the examples README. - Parameters:
runs-on: The runner to use for the job. Defaults toubuntu-24.04.extra-packages: Installs extra packages not listed in theDESCRIPTIONfile to be installed. Link: https://github.com/r-lib/actions/tree/v2/setup-r-dependenciescache-version: The cache key to be used. Link: https://github.com/r-lib/actions/tree/v2/setup-r-dependencies. Defaults to"2".pandoc-version: Sets the pandoc version to be installed. Link: https://github.com/r-lib/actions/tree/HEAD/setup-pandoc . Defaults to3.xwhich installs a recent 3.x version of pandoc. (Similar behavior for2.x.)check-title: Iftrue, will check that vignette titles and document titles match. Defaults totrue.clean: Whether to clean the site before building. Defaults to"TRUE".working-directory: The working directory where all checks are executed. Defaults to"."(repository root).
- This is a wrapper for building a
routine.yaml- Performs many common tasks for packages in the shiny-verse and commits them back to the repo
- Check for url redirects in
rc-v**branches - Formats R code with
air usethis::use_tidy_description()devtools::document()devtools::build_readme()(ifREADME.Rmdexists)- Losslessly optimizes tracked PNG files with
oxipng - Checks code coverage with
covrifcodecov.ymlexists - Checks for broken lints if
.lintrexists - Calls
npm build/yarn buildand commits any changes ininst,srcts, andsrcjs. - Updates the bundled JavaScript dependency list in
LICENSE.noteand comments on the PR when it changes, iflicense-note: true. See thelicense-noteREADME. - Calls
npm test/yarn test - Checks for outdated
staticimports
- Check for url redirects in
- Packages included in the
DESCRIPTIONfieldConfig/Needs/routinewill also be installed - To run the tasks as their own workflow, so that they can be re-run on demand without the rest of
Package checks, copyexamples/routine.yamlinto your repo and drop theroutinejob fromPackage checks. See the examples README. - Parameters:
extra-packages,cache-version,pandoc-version: Same as inwebsite.yamlnode-version: Version ofnode.jsto install. Defaults to"current".staticimports: Iftrue, checks for outdated staticimports. Defaults totrue.format-r-code: Iftrue, will format R code withair. Defaults tofalse.format-description: Iftrue, will runusethis::use_tidy_description()to format the DESCRIPTION file. Defaults totrue.build-readme: Iftrue, will build README.md from README.Rmd. Defaults totrue.check-js: Iftrue, will check for apackage.jsonfile and runnpm install/yarn installandnpm build/yarn buildif it exists. Defaults totrue.js-working-directory: Folder that contains thepackage.jsonfile. Defaults to the working directory input.optimize-pngs: Newline-separated git pathspecs of tracked PNG files to losslessly optimize withoxipng. Defaults toman/figures/*.pngandvignettes/*.png. Note that*matches/in a pathspec, so nested folders are included. Files under a_snaps/folder are never optimized, astestthat::compare_file_binary()compares snapshots byte for byte and optimizing one would keep it from matching a freshly generated screenshot. Set tofalse(or an empty string) to disable. See theoptimize-pngsaction for details.license-note: Iftrue, updates the bundled JavaScript dependency list inLICENSE.note. Defaults tofalse— set it totrueand add the generated-block markers toLICENSE.noteto opt in. See thelicense-noteREADME.working-directory: The working directory where all checks are executed. Defaults to"."(repository root).
- Performs many common tasks for packages in the shiny-verse and commits them back to the repo
R-CMD-check.yaml- Performs
R CMD check .on your package - To run the check matrix as its own workflow, so that it can be re-run on demand without the rest of
Package checks, copyexamples/R-CMD-check.yamlinto your repo and drop theR-CMD-checkjob fromPackage checks. See the examples README. - Parameters:
extra-packages,cache-version,pandoc-version: Same as inwebsite.yamlextra-check-args,extra-check-build-args: Arguments passed in addition to the default checkargs/build-argsof https://github.com/r-lib/actions/blob/v2/check-r-package/error-on: Condition that makesR CMD checkfail, forwarded torcmdcheck'serror_on. Must be a quoted R string, e.g.'"note"'. Defaults to'"warning"'. Note that'"note"'can be flaky in CI even for a locally clean package, due to environment NOTEs such as checking CRAN incoming feasibility and checking for future file timestamps.macOS:macOSruntime to use. Set tofalseto disable testing on macOS. Defaults to"macOS-latest".windows:windowsruntime to use. Set tofalseto disable testing on Windows. Defaults to"windows-latest".ubuntu:ubunturuntime to use. To use more than one ubuntu value, send in a value separated by a space. For example, to test on ubuntu 22.04 and 24.04, use"ubuntu-22.04 ubuntu-24.04". The firstubuntuvalue will be tested using the"devel"R version. Set tofalseto disable testing on Ubuntu. Defaults to"ubuntu-24.04".minimum-r-version: If provided, only R versions >= tominimum-r-versionwill be created in the matrix. Great for dependencies that will not install on earlier R versions.force-windows-src: Iftrue, forces the check to assume the package has compiled code even if it doesn't. Defaults tofalse.upload-snapshots: Iftrue, uploads testthat snapshots as artifacts. Defaults totrue.upload-check-results: Iftrue, uploads check results on failure. Defaults tofalse.working-directory: The working directory where all checks are executed. Defaults to"."(repository root).check-timeout-minutes: Timeout in minutes for the check step. Defaults to30.check-depends-only: Iftrue, adds an extra job that checks the package with only dependencies installed (sets_R_CHECK_DEPENDS_ONLY_=true). Defaults totrue.
- Performs
There are a set of known files that can be run. The file just needs to exist to be run. No extra configuration necessary.
The files must exist in the .github/shiny-workflows/ folder. Such as .github/shiny-workflows/package-install.R.
Files:
package-install.R/package-install.sh- This step is run in all workflows after R is installed, but before the local package dependencies are installed.
- This script could be useful for installing custom dependencies
website.R/website.sh- Run in
website.yamlbefore the site is built - This script could be useful for copying assets to a directory
- Run in
routine.R/routine.sh- Run in
routine.yaml. Runs before the local commits are pushed back to GitHub - This script could be useful for running some logic on a single OS and push the results back to GitHub
- This script could be useful for running a test that needs to be performed once and not on every job of
R-CMD-check.yaml
- Run in
These scripts should be done for their side effects, such as copying files or installing dependencies.
For example, a common use case for using a shell script over an R script would be to install custom system dependencies. Since installation is usually OperatingSystem specific, you'll likely want to make use of System environment variables, such as $RUNNER_OS. Link: https://docs.github.com/en/actions/learn-github-actions/environment-variables
Example usage of package-install.sh:
if [ "$RUNNER_OS" == "macOS" ]; then
brew install harfbuzz fribidi
fiTypically when using pkgdown in a package, you run the command below to initalize all necessary configs.
# Init pkgdown webs
usethis::use_pkgdown_github_pages()However, we will need to remove the GHA workflow file created, as we will use the website.yaml reusable shiny-workflow.
# Remove pkgdown workflow file; (Using reusable shiny-workflow)
unlink(".github/workflows/pkgdown.yaml")If your build fails and you are unsure of why, please visit https://github.com/r-lib/actions#where-to-find-help for more debugging tips. If you feel it is an error done by shiny-workflows, please submit an issue: https://github.com/rstudio/shiny-workflows/issues/new
r-lib/actions- GitHub Actions for R, Jim Hester's talk at rstudio::conf 2020. Recording, slidedeck.
- GitHub Actions advent calendar a series of blogposts by Edward Thomson, one of the GitHub Actions product managers highlighting features of GitHub Actions.
- GitHub Actions with R - a short online book about using GitHub Actions with R, produced as part of the rOpenSci OzUnconf.
- Awesome Actions - a curated list of custom actions. Note many of these are from early in the GitHub Actions beta and may no longer work.
- Why are my builds failing on macOS?
macOS packages are installed as binaries from Posit Public Package Manager, so system dependencies are rarely needed;setup-macOS-dependenciesonly installs XQuartz, and only forCairo. If a package must be built from source, or its binary is linked against a library the runner image lacks, install it from yourpackage-install.shlocal script. Please also make an issue so that other repos may utilize this knowledge: https://github.com/rstudio/shiny-workflows/issues/new - What if my website is custom?
It is ok to comment thewebsitejob in your workflow file. When the time comes that you can use the standardised{pkgdown}workflow, feel free to uncomment thewebsitejob.
Reasons to consider a feature:
- If more than two repos needs custom work, it should be considered.
- If all other repos could benefit from an installation step, even if they are currently not utilized. (Ex: phantomJS, tinytex)
Reasons to NOT consider a feature:
- Trying to appease a single repo. General response: The repo can run more compute cycles / jobs to meet their needs
- The feature imposes behavior that no other repos are performing or willing to adopt. Ex: Automatically setting the package version in
package.json
If updates are made to the workflows, the v1 tag must be (forcefully) moved forward to the latest commit on main within rstudio/shiny-workflows. Until the tag moves, consumers on @v1 do not see merged changes.
Moving the tag ships every unreleased commit on main to every consumer repo at once, so it is a deploy rather than a git chore. The procedure — pre-flight checks, the commit list to review, the force-push, and how to roll back — lives in .claude/skills/update-v1-tag/SKILL.md. Follow it there rather than running the commands from memory; if you are working with Claude Code, ask it to update the v1 tag and it will use that skill.
All examples in this repository are published with the CC0 license.