Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update_yml(): Support updating multiple YAML files #283

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ByteCompile: No
Encoding: UTF-8
LazyData: TRUE
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0.9000
RoxygenNote: 7.1.1
SystemRequirements: sodium
Collate:
'ci.R'
Expand Down
6 changes: 1 addition & 5 deletions R/steps-bookdown.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
BuildBookdown <- R6Class(
"BuildBookdown",
inherit = TicStep,

public = list(
initialize = function(...) {
private$bookdown_args <- list(...)
super$initialize()
},

run = function() {
do.call(bookdown::render_book, private$bookdown_args)
},

prepare = function() {
verify_install(c("bookdown", "remotes"))
super$prepare()
}
),

private = list(
bookdown_args = NULL
)
Expand All @@ -27,7 +23,7 @@ BuildBookdown <- R6Class(
#'
#' Build a bookdown book using [bookdown::render_book()].
#'
#' @inheritDotParams bookdown::render_book
#' @param ... See [bookdown::render_book].
#'
#' @export
#' @examples
Expand Down
35 changes: 24 additions & 11 deletions R/update-yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#' latest versions. Currently only GitHub Actions and Circle CI templates are
#' supported.
#'
#' @details By default all workflow files starting with `tic` are matched. This
#' means that you can have multiple YAML files with update support, e.g.
#' `"tic.yml"` and `"tic-db.yml"`.
#'
#' @section Formatting requirements of tic YAML templates: To ensure that
#' updating of {tic} templates works, ensure the following points:
#' - Your template contains the type (e.g. linux-matrix-deploy) and the revision
Expand All @@ -18,10 +22,12 @@
#' @param template_out `[character]`\cr
#' Where the updated template should be written to. This is mainly used for
#' internal testing purposes and should not be set by the user.
#' Can only be set
#'
#' @examples
#' \dontrun{
#' # auto-search
#' update_yml()
#'
#' update_yml("tic.yml")
#'
#' # custom named templates
Expand All @@ -38,8 +44,11 @@ update_yml <- function(template_in = NULL,
# by default all templates will be updated that can be found
if (is.null(template_in)) {
# check for existences of .travis.yml, circle-ci/config.yml and tic.yml
if (file.exists(usethis::proj_path(".github/workflows", "tic.yml"))) {
ghactions <- usethis::proj_path(".github/workflows", "tic.yml")
tic_ymls <- list.files(usethis::proj_path(".github/workflows"),
pattern = "^tic*", full.names = TRUE
)
if (length(tic_ymls) > 0) {
ghactions <- tic_ymls
}
else {
# account for old main.yml default
Expand Down Expand Up @@ -125,15 +134,16 @@ update_yml <- function(template_in = NULL,
), quiet = TRUE)

if (!rev_date_latest > rev_date_local) {
rlang::inform(sprintf(
"You already have the latest version of the %s template (%s).",
ci_provider,
rev_date_latest
))
cli::cli_alert_info(
"{.file {basename(instance)}}: You already have the latest version of
the {ci_provider} template (rev_date_latest).",
wrap = TRUE
)
next
} else {
cli::cli_alert("Updating {ci_provider} template from version
'{rev_date_local} to version '{rev_date_latest}'.", wrap = TRUE)
cli::cli_alert("Updating {ci_provider} template
{.file {basename(instance)}} from version
'{rev_date_local} to version '{rev_date_latest}'.", wrap = TRUE)
}

# call internal update function for each provider
Expand All @@ -144,6 +154,8 @@ update_yml <- function(template_in = NULL,
)

cli::cli_alert_info("Writing {.file {template_out}}.")
cli::cli_par()
cli::cli_end()
writeLines(tmpl_latest, template_out)

# reset template_out
Expand Down Expand Up @@ -392,7 +404,8 @@ update_ghactions_yml <- function(tmpl_local, tmpl_latest) {
if (length(custom_header) > 0) {
cli::cli_alert_info("Found a custom header entry. Will use it
instead of the header in the {.pkg tic} upstream template.",
wrap = TRUE)
wrap = TRUE
)
# find 'jobs:' tags
custom_header_local <- stringr::str_which(
tmpl_local,
Expand Down
2 changes: 1 addition & 1 deletion man/ci.Rd

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

2 changes: 1 addition & 1 deletion man/do_blogdown.Rd

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

2 changes: 1 addition & 1 deletion man/do_bookdown.Rd

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

212 changes: 106 additions & 106 deletions man/do_drat.Rd

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

Loading