Title: | Helpers to Develop a Package using GitHub Actions |
---|---|
Description: | A small set of functions that takes advantage of GitHub Actions for making your life easier as a R package developer. This package is primarily intended for personal use, however feel free to use it (at your own risk :)). |
Authors: | Diego Hernangómez [aut, cre, cph] |
Maintainer: | Diego Hernangómez <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9060 |
Built: | 2024-11-20 15:25:14 UTC |
Source: | https://github.com/dieghernan/pkgdev |
.gitignore
to packageAdds a global .gitgnore
file to the package. File based on default
.gitignore
provided by GitHub.
add_global_gitgnore(pkg = ".")
add_global_gitgnore(pkg = ".")
pkg |
Path to a (subdirectory of an) R package. |
Invisible, and writes a global .gitignore
file
usethis::use_git_ignore()
, usethis::git_vaccinate()
## Not run: add_global_gitgnore() ## End(Not run)
## Not run: add_global_gitgnore() ## End(Not run)
Check if title of Rd files ends in a period.
check_rd_titles(pkg = ".")
check_rd_titles(pkg = ".")
pkg |
Path to a (subdirectory of an) R package. |
A data frame with the results.
## Not run: check_rd_titles() ## End(Not run)
## Not run: check_rd_titles() ## End(Not run)
The GitHub action created would run R CMD check
on your package.
It uses a wide range of platforms, can be reduced by commenting or deleting
platforms on the matrix config.
gha_check_full(pkg = ".", overwrite = TRUE, cron_expr = "30 08 1 * *")
gha_check_full(pkg = ".", overwrite = TRUE, cron_expr = "30 08 1 * *")
pkg |
Path to a (subdirectory of an) R package. |
overwrite |
Overwrite the action if it was already present. |
cron_expr |
Valid cron expression. By default, the first day of the month at 08:30 AM. See Details. |
Use crontab.guru to check and create your own cron tag.
A GitHub Action on <pkg>/.github/workflows
.
usethis::use_github_action_check_full()
## Not run: gha_check_full(cron_expr = "57 16 12 * *") ## End(Not run)
## Not run: gha_check_full(cron_expr = "57 16 12 * *") ## End(Not run)
The GitHub action created would deploy a pkgdown site of your package on the gh-pages branch.
gha_pkgdown_branch( pkg = ".", overwrite = TRUE, platform = "macOS", version = "latest" )
gha_pkgdown_branch( pkg = ".", overwrite = TRUE, platform = "macOS", version = "latest" )
pkg |
Path to a (subdirectory of an) R package. |
overwrite |
Overwrite the action if it was already present. |
platform |
Platform to use for deploying the package. See Details |
version |
Version of the platform. See Details. |
Check https://github.com/actions/runner-images to see the available options.
A GitHub Action on <pkg>/.github/workflows
.
## Not run: # With Ubuntu 20.04 gha_pkgdown_branch(platform = "ubuntu", version = "20.04") ## End(Not run)
## Not run: # With Ubuntu 20.04 gha_pkgdown_branch(platform = "ubuntu", version = "20.04") ## End(Not run)
The GitHub action created would document your package (see update_docs()
),
would check it and would deploy the package on a gh-pages branch.
gha_update_docs( pkg = ".", overwrite = TRUE, platform = "macOS", version = "latest" )
gha_update_docs( pkg = ".", overwrite = TRUE, platform = "macOS", version = "latest" )
pkg |
Path to a (subdirectory of an) R package. |
overwrite |
Overwrite the action if it was already present. |
platform |
Platform to use for deploying the package. See Details |
version |
Version of the platform. See Details. |
Check https://github.com/actions/runner-images to see the available options.
A GitHub Action on .github/workflows
.
update_docs()
, gha_pkgdown_branch()
## Not run: # With Ubuntu 20.04 gha_update_docs(platform = "ubuntu", version = "20.04") ## End(Not run)
## Not run: # With Ubuntu 20.04 gha_update_docs(platform = "ubuntu", version = "20.04") ## End(Not run)
Precompute vignettes from CRAN, based on https://ropensci.org/blog/2019/12/08/precompute-vignettes/.
precompute_vignette( source, pkg = ".", figure_ext = ".png", create_r_file = FALSE ) precompute_vignette_all(dir = "vignettes", pkg = ".", ...)
precompute_vignette( source, pkg = ".", figure_ext = ".png", create_r_file = FALSE ) precompute_vignette_all(dir = "vignettes", pkg = ".", ...)
source |
Name without path of the |
pkg |
Path to a (subdirectory of an) R package. |
figure_ext |
Extension of the figures plotted on the vignette. See Details. |
create_r_file |
Whether to create an additional R file with the code of the vignette. |
dir |
Path to directory where the "Rmd.orig" files are stored. |
... |
Parameters passed to |
The function would search for the desired precomputed vignette on the
"./vignettes/"
folder and for plots on the root "./"
folder.
On your .Rmd.orig
file make sure you have set at least the following
lines if you are producing plots:
knitr::opts_chunk$set( ... , fig.path = "./", ... , )
A precomputed vignette
https://ropensci.org/blog/2019/12/08/precompute-vignettes/
## Not run: precompute_vignette(source = "precompute.Rmd.orig") ## End(Not run)
## Not run: precompute_vignette(source = "precompute.Rmd.orig") ## End(Not run)
Run routine checks on the package:
Clean DESCRIPTION with usethis::use_tidy_description()
Compress the data of the paths "./data"
and "./R"
using
tools::resaveRdaFiles()
.
Style code with styler::style_pkg()
Check urls with urlchecker::url_check()
Roxygenise with roxygen2::roxygenise()
Precompute vignettes if present (see https://ropensci.org/blog/2019/12/08/precompute-vignettes/)
Rebuild README.Rmd
(if present) with devtools::build_readme()
Optimize images with resmush::resmush_dir()
Write codemeta.json with codemetar::write_codemeta()
Write CITATION.cff with cffr::cff_write()
update_docs( pkg = ".", url_update = TRUE, create_codemeta = TRUE, create_cff = TRUE, build_readme = TRUE, verbose = TRUE, precompute = TRUE, opt_imgs = TRUE, opt_dir = c("pkgdown/favicon", "man/figures", "vignettes"), opt_ext = "png$|jpg$", opt_overwrite = TRUE, ... )
update_docs( pkg = ".", url_update = TRUE, create_codemeta = TRUE, create_cff = TRUE, build_readme = TRUE, verbose = TRUE, precompute = TRUE, opt_imgs = TRUE, opt_dir = c("pkgdown/favicon", "man/figures", "vignettes"), opt_ext = "png$|jpg$", opt_overwrite = TRUE, ... )
pkg |
Path to a (subdirectory of an) R package. |
url_update |
Logical, do you want to update urls with
|
create_codemeta |
Logical, do you want to create
a codemeta file with |
create_cff |
Logical, do you want to create
a CITATION.cff file with |
build_readme |
Logical, build |
verbose |
Display informative messages on the console |
precompute |
Logical, detect and precompute vignettes? See also
|
opt_imgs |
Logical. Optimize images with |
opt_dir , opt_ext , opt_overwrite
|
See |
... |
Additional arguments to functions |
This function tries to update and clean the package following a mix of
best practices (e.g. checking the urls, roxygenise and rebuilding the
README
) and some other discretionary practices I like to have in a package,
as the tidyverse
approach for the DESCRIPTION
file and overall code
and the use of codemeta.json
.
invisible, or some messages on verbose = TRUE
.
usethis::use_tidy_description()
, styler::style_pkg()
,
urlchecker::url_check()
, roxygen2::roxygenise()
,
devtools::build_readme()
, codemetar::write_codemeta()
,
tools::resaveRdaFiles()
## Not run: update_docs() ## End(Not run)
## Not run: update_docs() ## End(Not run)