Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active August 12, 2022 17:19
Show Gist options
  • Save mdsumner/44d3f02930bc0053ca674aa5c0e38313 to your computer and use it in GitHub Desktop.
Save mdsumner/44d3f02930bc0053ca674aa5c0e38313 to your computer and use it in GitHub Desktop.
Moving to Github Actions with R and usethis

A tired old R package repo

NOTE: *below I originally advocated deleting .travis.yml, appveyor.yml, codecov.yml and related ignore items, I don't think you should be so hasty - leave them for a while maybe. *

Here is tabularaster, an R package on CRAN that uses Appveyor, Travis, Codecov, and manual pkgdown builds.

Here is the state of the repo at 2020-04-13: https://github.com/hypertidy/tabularaster/tree/c0207410a01c169790646b92b84e2071fea3bf60

See the current master branch for the new Actions state.

Note:

  • /docs/ folder contains the content from pkgdown::build_site() hosted in master/docs
  • .travis.yml the Travis config, and
  • appveyor.yml the Appveyor config
  • codecov.yml the CodeCov config

Run usethis

https://www.tidyverse.org/blog/2020/04/usethis-1-6-0/

Install usethis and run

## create /.github/ with workflows
use_github_action("check-standard")
use_github_action("test-coverage") 
use_github_action("pkgdown") 

## will spit out text to add a badge to the readme
## dothese _after_ putting the <!-- badges: start -->/ <!-- badges: end --> 
## in readme and usethis will put them in there for you
use_github_actions_badge("check-standard")
use_github_actions_badge("test-coverage")
use_github_actions_badge("pkgdown")

Delete old stuff (when you fee like it, it's not actually necessary at this point)

Maybe delete /docs/, .travis.yml, appveyor.yml, codecov.yml they aren't needed any more.

Maybe delete the travis, appveyor, and codecov badges from the readme. (Put the print out of the actions badge from above step in their place, we get other badges later once Actions have run). Rebuild the readme, it's not important for the actions to run but nice to see the new badges asap.

Mayb e(carefully) remove ignore items from .Rbuildignore, we don't need to ignore them now they don't exist

Do note that usethis has already put an ignore item in .Rbuildignore for the /.github/ folder.

Commit and push

Revel. (Don't worry about the pkgdown content, that gets created in a new gh-pages branch by github actions and we just change a Setting).

Now go to the repo and see how the Actions are going (click Actions in the middle of the menu). When they are done, and successful ...

  • check that "gh-pages" branch exists, and update Settings to host the pkgdown website from this branch

Re-knit readme, commit and push again.

FIN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment