Skip to content

Commit

Permalink
wrap document action closes #286
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Jul 2, 2019
1 parent 8347a16 commit b17b2c8
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 23 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ export(auto_commit)
export(browse_github_actions)
export(check_clean_tree)
export(docker_cli)
export(document)
export(edit_workflow)
export(filter)
export(filter_branch)
export(firebase)
export(firebase_deploy)
export(fix_docs)
export(ghactions_events)
export(ghpages)
export(install_deps)
export(list2ghact)
export(make_action_block)
export(make_workflow_block)
Expand Down
38 changes: 38 additions & 0 deletions R/actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,41 @@ firebase_deploy <- function(IDENTIFIER = "Deploy",
PROJECT_ID = PROJECT_ID
)
}

# TODO this duplicates material from the README.md and man of the action https://github.com/r-lib/ghactions/issues/180
#' @title Install Dependencies
#'
#' @description
#' This GitHub action installs R package dependencies from a `DESCRIPTION` at the repository root.
#'
#' @template actions
#'
#' @export
install_deps <- function(IDENTIFIER = "Install Dependencies",
needs = NULL) {
list(
IDENTIFIER = IDENTIFIER,
uses = "r-lib/ghactions/actions/install-deps@8347a162e105155a6ff7066f7c57461948551278",
needs = needs
)
}

#' @title Document Package
#'
#' @description
#' This GitHub action installs R package dependencies from a `DESCRIPTION` at the repository root.
#'
#' @template actions
#'
#' @export
document <- function(IDENTIFIER = "Document Package",
needs = NULL,
args = NULL) {
list(
IDENTIFIER = IDENTIFIER,
uses = "r-lib/ghactions/actions/document@8347a162e105155a6ff7066f7c57461948551278",
needs = needs,
args = args,
secrets = "GITHUB_TOKEN"
)
}
28 changes: 16 additions & 12 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ use_ghactions <- function(workflow = website()) {
}
)

if (!fs::file_exists("DOCKERFILE")) {
usethis::ui_warn(x = glue::glue(
'Could not find a {usethis::ui_code("DOCKERFILE")} at your repository root.'
))
use_dockerfile()
usethis::ui_todo(x = glue::glue(
'Please edit the {usethis::ui_code("DOCKERFILE")} if you need additional dependencies.'
))
} else {
usethis::ui_line(x = glue::glue(
'Using the {usethis::ui_code("DOCKERFILE")} found at your repository root.'
))
# TODO bad hackfix for https://github.com/r-lib/ghactions/issues/288
needs_docker <- isTRUE(attr(workflow, 'byod'))
if (needs_docker) {
if (!fs::file_exists("DOCKERFILE")) {
usethis::ui_warn(x = glue::glue(
'Could not find a {usethis::ui_code("DOCKERFILE")} at your repository root.'
))
use_dockerfile()
usethis::ui_todo(x = glue::glue(
'Please edit the {usethis::ui_code("DOCKERFILE")} if you need additional dependencies.'
))
} else {
usethis::ui_line(x = glue::glue(
'Using the {usethis::ui_code("DOCKERFILE")} found at your repository root.'
))
}
}

# body ====
Expand Down
45 changes: 45 additions & 0 deletions R/workflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ website <- function(IDENTIFIER = "Render and Deploy RMarkdown Website",
),
deploy[[1]]
)

# bad hack-fix for https://github.com/r-lib/ghactions/issues/288
attr(res, 'byod') <- TRUE
res
}

Expand All @@ -88,3 +91,45 @@ fau <- purrr::partial(
)
)
)

#' @title Fix documentation
#'
#' @description
#' This GitHub action creates `man/` documentation from [*roxygen*](https://github.com/klutometis/roxygen/) comments in `R/` scripts at the repository root using [*devtools*](https://devtools.r-lib.org).
#'
#' @inheritParams make_workflow_block
#'
#' @inheritParams auto_commit
#'
#' @template workflows
#'
#' @details
#' If you set `after_code = 'commit'` this action will automatically commit and push changes to your repository for you.
#' This will pollute your commit history and may cause unintended interruptions, such as merge conflicts *with yourself*.
#' The programmatic commit will not trigger another action run, but may trigger other workflow automations (such as Travis and AppVeyor).
#'
#' GitHub actions are currently available only in repos who belong to organisations or personal accounts who are on the beta.
#' GitHub actions always runs against the repo to which the push was made, and does not currently support pull requests.
#'
#' For more caveats, see [auto_commit()].
#'
#' @export
fix_docs <- function(IDENTIFIER = "Fix Documentation",
after_code = NULL) {
# Input validation

# TODO this is a stupid roundtrip of R argument to bash to R to wherever
if (isTRUE(after_code == "commit")) {
after_code <- "--after-code=commit"
}

rlang::exec(.fn = list, !!!list(
IDENTIFIER = IDENTIFIER,
on = "push",
resolves = c("Document Package"),
actions = list(
install_deps(),
document(needs = "Install Dependencies", args = after_code)
)
))
}
5 changes: 3 additions & 2 deletions man/docker_cli.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions man/document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/filter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/firebase.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions man/fix_docs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/ghpages.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions man/install_deps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/netlify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/rscript_byod.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/rsync.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/website.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b17b2c8

Please sign in to comment.