Skip to content

Commit

Permalink
Use release_bullets() in use_release_issue()
Browse files Browse the repository at this point in the history
This is a bit of a hack because it assumes that the `release_bullets()` function is somewhere on the search path, but that's likely to be true because the developer will have usually called `load_all()` previously. Also includes some golden tests for release_bullets().

Fixes #941
  • Loading branch information
hadley committed Mar 17, 2020
1 parent 602acc7 commit 7ef0c88
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 4 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# usethis (development version)

* If your package has a `release_bullets()` function which returns a character
vector (and the package has been loaded with `load_all()`), then
`use_release_issue()` will include extra bullets in the issue (#941).

* In `use_travis()`, `use_travis_badge()` and `browse_travis()`, argument `ext`
now defaults to `"com"` instead of `"ext"`, given travis-ci.com is now
recommended over travis-ci.org (#1038, @riccardoporreca).
Expand Down
8 changes: 5 additions & 3 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use_release_issue <- function(version = NULL) {
return(invisible(FALSE))
}

checklist <- release_checklist(version)
on_cran <- !is.null(cran_version())
checklist <- release_checklist(version, on_cran)

issue <- gh::gh("POST /repos/:owner/:repo/issues",
owner = github_owner(),
Expand All @@ -34,13 +35,13 @@ use_release_issue <- function(version = NULL) {
view_url(issue$html_url)
}

release_checklist <- function(version) {
release_checklist <- function(version, on_cran) {
type <- release_type(version)
on_cran <- !is.null(cran_version())
cran_results <- cran_results_url()
has_src <- dir_exists(proj_path("src"))
has_news <- file_exists(proj_path("NEWS.md"))
has_pkgdown <- file_exists(proj_path("_pkgdown.yml"))
has_extra <- exists("release_bullets", parent.env(globalenv()))

todo <- function(x, cond = TRUE) {
x <- glue(x, .envir = parent.frame())
Expand All @@ -65,6 +66,7 @@ release_checklist <- function(version) {
todo("[Polish NEWS](https://style.tidyverse.org/news.html#news-release)", on_cran),
todo("Review pkgdown reference index for, e.g., missing topics", has_pkgdown),
todo("Draft blog post", type != "patch"),
if (has_extra) paste0("* [ ] ", get("release_bullets", parent.env(globalenv()))()),
"",
"Submit to CRAN:",
"",
Expand Down
3 changes: 2 additions & 1 deletion man/proj_utils.Rd

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

93 changes: 93 additions & 0 deletions tests/testthat/test-release-usethis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

First release
=============

> cat(release_checklist("0.1.0", on_cran = FALSE), sep = "\n")
Prepare for release:

* [ ] Check that description is informative
* [ ] Check licensing of included files
* [ ] `usethis::use_cran_comments()`
* [ ] `devtools::check(remote = TRUE, manual = TRUE)`
* [ ] `devtools::check_win_devel()`
* [ ] `rhub::check_for_cran()`
* [ ] Update `cran-comments.md`
* [ ] Draft blog post

Submit to CRAN:

* [ ] `usethis::use_version('minor')`
* [ ] `devtools::submit_cran()`
* [ ] Approve email

Wait for CRAN...

* [ ] Accepted :tada:
* [ ] `usethis::use_news_md()`
* [ ] `usethis::use_github_release()`
* [ ] `usethis::use_dev_version()`
* [ ] Update install instructions in README
* [ ] Finish blog post
* [ ] Tweet
* [ ] Add link to blog post in pkgdown news menu


Patch release
=============

> cat(release_checklist("0.0.1", on_cran = TRUE), sep = "\n")
Prepare for release:

* [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_usethis.html)
* [ ] `devtools::check(remote = TRUE, manual = TRUE)`
* [ ] `devtools::check_win_devel()`
* [ ] `rhub::check_for_cran()`
* [ ] `revdepcheck::revdep_check(num_workers = 4)`
* [ ] Update `cran-comments.md`
* [ ] [Polish NEWS](https://style.tidyverse.org/news.html#news-release)

Submit to CRAN:

* [ ] `usethis::use_version('patch')`
* [ ] `devtools::submit_cran()`
* [ ] Approve email

Wait for CRAN...

* [ ] Accepted :tada:
* [ ] `usethis::use_news_md()`
* [ ] `usethis::use_github_release()`
* [ ] `usethis::use_dev_version()`


Major release
=============

> cat(release_checklist("1.0.0", on_cran = TRUE), sep = "\n")
Prepare for release:

* [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_usethis.html)
* [ ] `devtools::check(remote = TRUE, manual = TRUE)`
* [ ] `devtools::check_win_devel()`
* [ ] `rhub::check_for_cran()`
* [ ] `revdepcheck::revdep_check(num_workers = 4)`
* [ ] Update `cran-comments.md`
* [ ] [Polish NEWS](https://style.tidyverse.org/news.html#news-release)
* [ ] Draft blog post

Submit to CRAN:

* [ ] `usethis::use_version('major')`
* [ ] `devtools::submit_cran()`
* [ ] Approve email

Wait for CRAN...

* [ ] Accepted :tada:
* [ ] `usethis::use_news_md()`
* [ ] `usethis::use_github_release()`
* [ ] `usethis::use_dev_version()`
* [ ] Finish blog post
* [ ] Tweet
* [ ] Add link to blog post in pkgdown news menu

30 changes: 30 additions & 0 deletions tests/testthat/test-release.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
test_that("release bullets don't change accidentally", {
# Avoid finding any files in real usethis project
old <- proj_set(dir_create(path_temp("usethis")), force = TRUE)
on.exit(proj_set(old))

verify_output(test_path("test-release-usethis.txt"), {
"# First release"
cat(release_checklist("0.1.0", on_cran = FALSE), sep = "\n")

"# Patch release"
cat(release_checklist("0.0.1", on_cran = TRUE), sep = "\n")

"# Major release"
cat(release_checklist("1.0.0", on_cran = TRUE), sep = "\n")
})
})

test_that("get extra news bullets if available", {
standard <- release_checklist("1.0.0", TRUE)

attach(
list(release_bullets = function() "Extra bullets"),
name = "extra",
warn.conflicts = FALSE
)
on.exit(detach("extra"))

new <- setdiff(release_checklist("1.0.0", TRUE), standard)
expect_equal(new, "* [ ] Extra bullets")
})

0 comments on commit 7ef0c88

Please sign in to comment.