call-r-cmd-check Lifecycle badge indicating this repository is stable NOAA Fisheries Integrated Toolbox Badge codecov Badge

arrows circling clapboard, symbol for the gh4actions package

What is in {ghactions4r}?

This repo contains a collection of reusable workflows found helpful for R packages. In addition, {ghactions4r} contains helper functions for setting up the workflows in a separate R package GitHub repository.

How is {ghactions4r} different than the usethis::use_github_actions() workflows?

Rather than having to maintain your own GitHub actions files (as you would need to with actions set up with usethis::use_github_action()), using a {ghactions4r} use_* function sets up a github actions file to directly call actions that exist and are maintained in the {ghactions4r} repository (in the workflows folder). This means all maintenance happens within the {ghactions4r} repository rather than in your repository!

How do I use these workflows in my R package?

First, install the {ghactions4r} R package.

Using R universe:

install.packages("ghactions4r", 
repos = c("https://noaa-fisheries-integrated-toolbox.r-universe.dev", 
          "https://cran.r-project.org"))

or remotes::install_github():

install.packages("remotes")
remotes::install_github("nmfs-fish-tools/ghactions4r")

use_*() functions in the {ghactions4r} package work like use_*() functions in the usethis package.

Open the cloned repository of an R package and run the function of choice. These functions set up the files needed to use the reproducible workflows in {ghactions4r}. Below are a list of the basic functions, for complete options, see the pkgdown reference documentation.

  • To run R CMD check using Linux (R release and R development), Mac (R release), and Windows (R release):
ghactions4r::use_r_cmd_check()
  • To calculate code coverage using covr::codecov() :
ghactions4r::use_calc_coverage()

(a codecov.io account is also necessary to view the coverage results)

  • To update documentation using devtools::document():
  • To update R code styling using styler::style_pkg():
ghactions4r::use_style_r_code()
ghactions4r::use_style_description()
ghactions4r::use_doc_and_style_r(use_rm_dollar_sign = FALSE)
  • To automatically update pkgdown that has already been set up:
ghactions4r::use_update_pkgdown()
  • To automatically build and deploy bookdown (to a branch called gh-pages in the same repository) that is in an R package repository:
  • To spell check an R package:
ghactions4r::use_spell_check()
  • To publish a product to posit connect from a private repo:
ghactions4r::use_connect_publish()

Commit and push the files generated up to github, making the github actions available for the repository of the R package.

The templates these functions generate can also be viewed for reference.

The GitHub Action Workflow I added to my repository failed. What should I do?

Check that GitHub Actions has been given the right GITHUB_TOKEN permissions. GitHub Actions will have read-only permissions by default, rather than read and write permissions. For many workflows in this repository, read and write permissions are necessary. To modify the permissions, follow these GitHub Documentation instructions.

If still running into failing actions, please submit an issue or email . Bugs are always possible, as this repository is still experimental. Reporting issues will make {ghactions4r} better for all users!

I want to setup and maintain my own github actions rather than use reusable workflows housed in {ghactions4r}. How do I do this?

r-lib/actions Includes basic actions for R as well as example workflows. In fact, many of the reusable workflows in {ghactions4r} are based on these examples. Many of these can be set up through usethis’ GitHub Actions functions.

Code of Conduct

{ghactions4r} uses the NOAA FIT Code of Conduct.

Contributing

Contributions are welcome! Contributions can be code, but are not just code, but also includes things like:

  • Reporting errors or bugs
  • Suggesting enhancements
  • Correcting or adding documentation (including editing the readme)
  • Answering questions on the discussions page

Additional details are available in the NOAA FIT Contributing Guide.

Checklist for adding a new workflow

Disclaimer

“The United States Department of Commerce (DOC) GitHub project code is provided on an”as is” basis and the user assumes responsibility for its use. DOC has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any claims against the Department of Commerce stemming from the use of its GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.”

NOAA Fisheries

U.S. Department of Commerce | National Oceanographic and Atmospheric Administration | NOAA Fisheries