diff --git a/NEWS.md b/NEWS.md index 2a94ebba5..4da7142c0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # usethis (development version) +* `use_release_issue()` now uses internal `release_extra_revdeps()` to + add extra revdep sources. Currently only use for internal Posit tooling, + but we hope to extend to all users in the future (#1610). + * `create_from_github()` will now use an existing `.Rproj` file if it exists anywhere in the repo, not just the root directory. This is useful if you're working with repos that contain tools for multiple languages (#1680). diff --git a/R/release.R b/R/release.R index 5e19ab2b4..925c936ea 100644 --- a/R/release.R +++ b/R/release.R @@ -12,10 +12,18 @@ #' The checklist contains a generic set of steps that we've found to be helpful, #' based on the type of release ("patch", "minor", or "major"). You're #' encouraged to edit the issue to customize this list to meet your needs. -#' If you want to consistently add extra bullets for every release, you can -#' include your own custom bullets by providing a (unexported) a -#' `release_bullets()` function that returns a character vector. -#' (For historical reasons, `release_questions()` is also supported). +#' +#' ## Customization +#' +#' * If you want to consistently add extra bullets for every release, you can +#' include your own custom bullets by providing an (unexported) +#' `release_bullets()` function that returns a character vector. +#' (For historical reasons, `release_questions()` is also supported). +#' +#' * If you want to check additional packages in the revdep check process, +#' provide an (unexported) `release_extra_revdeps()` function that +#' returns a character vector. This is currently only supported for +#' Posit internal check tooling. #' #' @param version Optional version number for release. If unspecified, you can #' make an interactive choice. @@ -94,13 +102,12 @@ release_checklist <- function(version, on_cran) { todo("`rhub::check_for_cran()`"), todo("`rhub::check(platform = 'ubuntu-rchk')`", has_src), todo("`rhub::check_with_sanitizers()`", has_src), - todo("`revdepcheck::revdep_check(num_workers = 4)`", on_cran && !is_rstudio_pkg), - todo("`revdepcheck::cloud_check()`", on_cran && is_rstudio_pkg), + release_revdepcheck(on_cran, is_rstudio_pkg), todo("Update `cran-comments.md`", on_cran), todo("`git push`"), todo("Draft blog post", type != "patch"), todo("Slack link to draft blog in #open-source-comms", type != "patch" && is_rstudio_pkg), - release_extra(), + release_extra_bullets(), "", "Submit to CRAN:", "", @@ -122,13 +129,33 @@ release_checklist <- function(version, on_cran) { ) } -release_extra <- function(env = NULL) { - if (is.null(env)) { - env <- tryCatch( - pkg_env(project_name()), - error = function(e) emptyenv() - ) +release_revdepcheck <- function(on_cran = TRUE, is_rstudio_pkg = TRUE, env = NULL) { + if (!on_cran) { + return() + } + + env <- env %||% safe_pkg_env() + if (env_has(env, "release_extra_revdeps")) { + extra <- env$release_extra_revdeps() + stopifnot(is.character(extra)) + } else { + extra <- character() + } + + if (is_rstudio_pkg) { + if (length(extra) > 0) { + extra_code <- paste0(deparse(extra), collapse = "") + todo("`revdepcheck::cloud_check(extra_revdeps = {extra_code})`") + } else { + todo("`revdepcheck::cloud_check()`") + } + } else { + todo("`revdepcheck::revdep_check(num_workers = 4)`") } +} + +release_extra_bullets <- function(env = NULL) { + env <- env %||% safe_pkg_env() if (env_has(env, "release_bullets")) { paste0("* [ ] ", env$release_bullets()) @@ -140,6 +167,13 @@ release_extra <- function(env = NULL) { } } +safe_pkg_env <- function() { + tryCatch( + ns_env(project_name()), + error = function(e) emptyenv() + ) +} + release_type <- function(version) { x <- unclass(numeric_version(version))[[1]] n <- length(x) diff --git a/man/use_release_issue.Rd b/man/use_release_issue.Rd index 8831a7c49..39bf2e4bd 100644 --- a/man/use_release_issue.Rd +++ b/man/use_release_issue.Rd @@ -23,10 +23,18 @@ function creates a checklist in a GitHub issue to: The checklist contains a generic set of steps that we've found to be helpful, based on the type of release ("patch", "minor", or "major"). You're encouraged to edit the issue to customize this list to meet your needs. -If you want to consistently add extra bullets for every release, you can -include your own custom bullets by providing a (unexported) a +\subsection{Customization}{ +\itemize{ +\item If you want to consistently add extra bullets for every release, you can +include your own custom bullets by providing an (unexported) \code{release_bullets()} function that returns a character vector. (For historical reasons, \code{release_questions()} is also supported). +\item If you want to check additional packages in the revdep check process, +provide an (unexported) \code{release_extra_revdeps()} function that +returns a character vector. This is currently only supported for +Posit internal check tooling. +} +} } \examples{ \dontrun{ diff --git a/tests/testthat/_snaps/release.md b/tests/testthat/_snaps/release.md index bf7855601..9e3ff8377 100644 --- a/tests/testthat/_snaps/release.md +++ b/tests/testthat/_snaps/release.md @@ -113,6 +113,25 @@ * [ ] Tweet * [ ] Add link to blog post in pkgdown news menu +# construct correct revdep bullet + + Code + release_revdepcheck(on_cran = FALSE) + Output + NULL + Code + release_revdepcheck(on_cran = TRUE, is_rstudio_pkg = FALSE) + Output + [1] "* [ ] `revdepcheck::revdep_check(num_workers = 4)`" + Code + release_revdepcheck(on_cran = TRUE, is_rstudio_pkg = TRUE) + Output + [1] "* [ ] `revdepcheck::cloud_check()`" + Code + release_revdepcheck(on_cran = TRUE, is_rstudio_pkg = TRUE, env = env) + Output + [1] "* [ ] `revdepcheck::cloud_check(extra_revdeps = c(\"waldo\", \"testthat\"))`" + # RStudio-ness detection works Code diff --git a/tests/testthat/test-release.R b/tests/testthat/test-release.R index 16d929d57..a39d534d6 100644 --- a/tests/testthat/test-release.R +++ b/tests/testthat/test-release.R @@ -25,13 +25,25 @@ test_that("release bullets don't change accidentally", { test_that("get extra news bullets if available", { env <- env(release_bullets = function() "Extra bullets") - expect_equal(release_extra(env), "* [ ] Extra bullets") + expect_equal(release_extra_bullets(env), "* [ ] Extra bullets") env <- env(release_questions = function() "Extra bullets") - expect_equal(release_extra(env), "* [ ] Extra bullets") + expect_equal(release_extra_bullets(env), "* [ ] Extra bullets") env <- env() - expect_equal(release_extra(env), character()) + expect_equal(release_extra_bullets(env), character()) +}) + +test_that("construct correct revdep bullet", { + create_local_package() + env <- env(release_extra_revdeps = function() c("waldo", "testthat")) + + expect_snapshot({ + release_revdepcheck(on_cran = FALSE) + release_revdepcheck(on_cran = TRUE, is_rstudio_pkg = FALSE) + release_revdepcheck(on_cran = TRUE, is_rstudio_pkg = TRUE) + release_revdepcheck(on_cran = TRUE, is_rstudio_pkg = TRUE, env = env) + }) }) test_that("RStudio-ness detection works", {