Skip to content

Commit

Permalink
style and docs: run devtools::document() and styler::style_pkg()
Browse files Browse the repository at this point in the history
  • Loading branch information
k-doering-NOAA committed Oct 13, 2023
1 parent 5d3985e commit 62c7cc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions R/use_r_workflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ use_calc_coverage <- function(workflow_name = "call-calc-coverage.yml") {
#' @details
#' Note that allow the pull request created from this workflow can
#' be used to trigger github action runs, by using a personal access
#' token to provide the right permissions. The PAT is first
#' [generated on a user account](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens),
#' then [added to the repository or organization as a secret](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository).
#' Using a PAT can cause recursive runs, so should be used
#' with caution. See github documentation on
#' [triggering a workflow from a workflow](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow)
#' token to provide the right permissions. The PAT is first
#' [generated on a user account](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens),
#' then [added to the repository or organization as a secret](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository).
#' Using a PAT can cause recursive runs, so should be used
#' with caution. See github documentation on
#' [triggering a workflow from a workflow](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow)
#' for more information.
#' @template workflow_name
#' @param use_rm_dollar_sign in addition to devtools::document and
Expand All @@ -57,9 +57,9 @@ use_calc_coverage <- function(workflow_name = "call-calc-coverage.yml") {
#' @param use_pat Should a personal access token (PAT) stored as a github secret
#' be used? This is only necessary if you want the pull request generated by
#' the doc and style workflow to be able to start other github action runs.
#' @param pat_name Name of the personal access token (PAT), as stored in secrets.
#' Only used if `use_pat = TRUE`. After
#' [generating the personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens),
#' @param pat_name Name of the personal access token (PAT), as stored in secrets.
#' Only used if `use_pat = TRUE`. After
#' [generating the personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens),
#' See [how to add it as a secret](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository).
#' @export
use_doc_and_style_r <- function(workflow_name = "call-doc-and-style-r.yml",
Expand Down Expand Up @@ -128,13 +128,13 @@ use_doc_and_style_r <- function(workflow_name = "call-doc-and-style-r.yml",
}
}
if (use_pat == TRUE) {
uses_line <- grep(
uses_line <- grep(
"uses: nmfs-fish-tools/ghactions4r/.github/workflows/doc-and-style-r.yml",
gha
)
pat_line <- paste0(" PAT: ${{ secrets.", pat_name, " }}")
gha <- append(gha, " secrets:", after = uses_line)
gha <- append(gha, pat_line, after = uses_line + 1)
gha <- append(gha, " secrets:", after = uses_line)
gha <- append(gha, pat_line, after = uses_line + 1)
}
writeLines(gha, path_to_yml)
usethis::use_git_ignore(ignores = "*.rds", directory = file.path(".github"))
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-use_r_workflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_that("use_r_cmd_check() works with defaults", {
test_that("use_r_cmd_check() works with full build option", {
name <- "call-full-build-check.yml"
path <- file.path(".github", "workflows", name)
use_r_cmd_check(workflow_name = name, use_full_build_matrix = TRUE)
use_r_cmd_check(workflow_name = name, use_full_build_matrix = TRUE)
expect_true(file.exists(path))
test <- readLines(path)
expect_snapshot(test)
Expand Down Expand Up @@ -93,7 +93,7 @@ test_that("use_doc_and_style_r() works with manual trigger", {
test_that("use_doc_and_style_r() works with pat option", {
use_doc_and_style_r(
workflow_name = "doc_style_pat.yml",
use_rm_dollar_sign = FALSE, how_to_commit = "pull_request",
use_rm_dollar_sign = FALSE, how_to_commit = "pull_request",
use_pat = TRUE, pat_name = "MYPAT"
)
expect_true(file.exists(".github/workflows/doc_style_pat.yml"))
Expand Down

0 comments on commit 62c7cc0

Please sign in to comment.