rstudio / shiny-workflows

GitHub Actions workflows for Shiny and related packages
16 stars 4 forks source link

Reusable GHA workflows

:triangular_flag_on_post::triangular_flag_on_post::triangular_flag_on_post: This repo is intended for internal use only. Sweeping changes will be made without notice. :triangular_flag_on_post::triangular_flag_on_post::triangular_flag_on_post:

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

Usage:

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:
    branches: [main]
  schedule:
    - cron: '0 8 * * 1' # every monday

name: Package checks

jobs:
  website:
    uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1
  routine:
    uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1
  R-CMD-check:
    uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1

Note: Adjust the 8 in the schedule to match the number of letters in the package name to insert some time variance. This helps mitigate PAT rate limits when testing many packages on a schedule.

Workflows

There are three main reusable workflows to be used by packages in the shiny-verse

Customization

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:

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
fi

pkgdown setup

Typically 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")

Where to find help

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

Additional resources

Common questions

  1. Why are my builds failing on macOS?\ Please double check that their are no required dependencies stated in the log during installation. If there is an unmet dependency, please make an issue so that other repos may utilize this knowledge: https://github.com/rstudio/shiny-workflows/issues/new
  2. What if my website is custom?\ It is ok to comment the website job in your workflow file. When the time comes that you can use the standardised {pkgdown} workflow, feel free to uncomment the website job.

shiny-workflow development

Adopting a feature

Reasons to consider a feature:

Reasons to NOT consider a feature:

Updates to workflows or actions

If updates are made to the workflows, the v1 tag must be (forcefully) moved forward to the latest value within the rstudio/shiny-workflows. To do this, run:

git tag -f v1
git push origin --tags -f

License CC0 licensed

All examples in this repository are published with the CC0 license.