Skip to content

Commit aadd06c

Browse files
hadleyjennybc
andauthored
First stab at use_tidy_upkeep_issue() (#1514)
* First stab at use_tidy_upkeep_issue() For the purposes of discussion. Fixes #1416. * Update R/tidy-upkeep.R * Lots of little changes that GitHub's "batch commit" was refusing to let me make via the browser * Try to determine oldrel-4 dynamically * Update snapshot * Rename the issue * Add NEWS bullet * Add more hints and links Co-authored-by: Jennifer (Jenny) Bryan <[email protected]>
1 parent 8f10840 commit aadd06c

File tree

6 files changed

+157
-13
lines changed

6 files changed

+157
-13
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ usethis has a more sophisticated understanding of the default branch and gains s
104104
* `use_tidy_dependencies()` is a new function that sets up standard dependencies
105105
used by all tidyverse packages, except those that are designed to be
106106
dependency free (#1423).
107+
108+
* `use_tidy_upkeep_issue()` is a new function similar to `use_release_issue()`
109+
that creates a checklist-style issue to prompt various updates. It is aimed
110+
primarily at the maintainers of tidyverse, r-lib, and tidymodels packages
111+
(#1416).
107112

108113
## User-level configuration
109114

R/release.R

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,10 @@ release_checklist <- function(version, on_cran) {
6363
has_pkgdown <- uses_pkgdown()
6464
has_readme <- file_exists(proj_path("README.Rmd"))
6565

66-
todo <- function(x, cond = TRUE) {
67-
x <- glue(x, .envir = parent.frame())
68-
if (cond) {
69-
paste0("* [ ] ", x)
70-
}
71-
}
7266
c(
7367
if (!on_cran) c(
7468
"First release:",
7569
"",
76-
7770
todo("`usethis::use_cran_comments()`"),
7871
todo("Update (aspirational) install instructions in README"),
7972
todo("Proofread `Title:` and `Description:`"),
@@ -83,24 +76,19 @@ release_checklist <- function(version, on_cran) {
8376
todo("Review <https://github.com/DavisVaughan/extrachecks>"),
8477
""
8578
),
86-
8779
"Prepare for release:",
8880
"",
89-
9081
todo("Check [current CRAN check results]({cran_results})", on_cran),
91-
9282
todo("[Polish NEWS](https://style.tidyverse.org/news.html#news-release)", on_cran),
9383
todo("`devtools::build_readme()`", has_readme),
94-
9584
todo("`urlchecker::url_check()`"),
9685
todo("`devtools::check(remote = TRUE, manual = TRUE)`"),
9786
todo("`devtools::check_win_devel()`"),
9887
todo("`rhub::check_for_cran()`"),
9988
todo("`rhub::check(platform = 'ubuntu-rchk')`", has_src),
10089
todo("`rhub::check_with_sanitizers()`", has_src),
10190
todo("`revdepcheck::revdep_check(num_workers = 4)`", on_cran),
102-
103-
if (on_cran) todo("Update `cran-comments.md`"),
91+
todo("Update `cran-comments.md`", on_cran),
10492
todo("Review pkgdown reference index for, e.g., missing topics", has_pkgdown && type != "patch"),
10593
todo("Draft blog post", type != "patch"),
10694
release_extra(),
@@ -343,3 +331,10 @@ news_latest <- function(lines) {
343331

344332
paste0(news, "\n", collapse = "")
345333
}
334+
335+
todo <- function(x, cond = TRUE) {
336+
x <- glue(x, .envir = parent.frame())
337+
if (cond) {
338+
paste0("* [ ] ", x)
339+
}
340+
}

R/tidy-upkeep.R

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#' @export
2+
#' @rdname tidyverse
3+
#' @param year Approximate year when you last touched this package. If `NULL`,
4+
#' the default, will give you a full set of actions to perform.
5+
use_tidy_upkeep_issue <- function(year = NULL) {
6+
check_is_package("use_tidy_upkeep_issue()")
7+
8+
tr <- target_repo(github_get = TRUE)
9+
if (!isTRUE(tr$can_push)) {
10+
ui_line("
11+
It is very unusual to open an upkeep issue on a repo you can't push to:
12+
{ui_value(tr$repo_spec)}")
13+
if (ui_nope("Do you really want to do this?")) {
14+
ui_oops("Cancelling.")
15+
return(invisible())
16+
}
17+
}
18+
19+
checklist <- upkeep_checklist(year)
20+
21+
gh <- gh_tr(tr)
22+
issue <- gh(
23+
"POST /repos/{owner}/{repo}/issues",
24+
title = glue("Upkeep for {project_name()}"),
25+
body = paste0(checklist, "\n", collapse = "")
26+
)
27+
view_url(issue$html_url)
28+
}
29+
30+
upkeep_checklist <- function(year = NULL) {
31+
year <- year %||% 2000
32+
bullets <- c()
33+
34+
if (year <= 2000) {
35+
bullets <- c(bullets,
36+
"Pre-history",
37+
"",
38+
todo("`usethis::use_readme_rmd()`"),
39+
todo("`usethis::use_roxygen_md()`"),
40+
todo("
41+
`usethis::use_github_links()`
42+
It is advantageous if the link to your GitHub repo comes first, \\
43+
before any other URLs, e.g. pkgdown site."),
44+
todo("`usethis::use_pkgdown_github_pages()`"),
45+
todo("`usethis::use_tidy_labels()`"),
46+
todo("`usethis::use_tidy_style()`"),
47+
todo("`usethis::use_tidy_description()`"),
48+
todo("`urlchecker::url_check()`"),
49+
""
50+
)
51+
}
52+
if (year <= 2020) {
53+
bullets <- c(bullets,
54+
"2020",
55+
"",
56+
todo("
57+
`usethis::use_package_doc()`
58+
Consider letting usethis manage your `@importFrom` directives here.
59+
`usethis::use_import_from()` is handy for this."),
60+
todo("
61+
`usethis::use_testthat(3)` and upgrade to 3e, \\
62+
[testthat 3e vignette](https://testthat.r-lib.org/articles/third-edition.html)"),
63+
todo("
64+
Align the names of `R/` files and `test/` files for workflow happiness.
65+
`usethis::rename_files()` can be helpful."),
66+
""
67+
)
68+
}
69+
if (year <= 2021) {
70+
bullets <- c(bullets,
71+
"2021",
72+
"",
73+
todo("`usethis::use_tidy_description()`", year > 2000),
74+
todo("`usethis::use_tidy_dependencies()`"),
75+
todo("
76+
`usethis::use_tidy_github_actions()` and update artisanal actions to \\
77+
use `setup-r-dependencies`"),
78+
todo("Remove check environments section from `cran-comments.md`"),
79+
todo("Bump required R version in DESCRIPTION to {tidy_minimum_r_version()}"),
80+
todo("
81+
Use lifecycle instead of artisanal deprecation messages, as described \\
82+
in [Communicate lifecycle changes in your functions](https://lifecycle.r-lib.org/articles/communicate.html)"),
83+
""
84+
)
85+
}
86+
87+
bullets
88+
}
89+
90+
# https://www.tidyverse.org/blog/2019/04/r-version-support/
91+
tidy_minimum_r_version <- function() {
92+
con <- curl::curl("https://api.r-hub.io/rversions/r-oldrel/4")
93+
withr::defer(close(con))
94+
# I do not want a failure here to make use_tidy_upkeep_issue() fail
95+
json <- tryCatch(readLines(con, warn = FALSE), error = function(e) NULL)
96+
if (is.null(json)) {
97+
oldrel_4 <- "3.4"
98+
} else {
99+
version <- jsonlite::fromJSON(json)$version
100+
oldrel_4 <- re_match(version, "[0-9]+[.][0-9]+")$.match
101+
}
102+
oldrel_4
103+
}

R/tidyverse.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#' * [use_tidy_github_labels()] calls `use_github_labels()` to implement
4444
#' tidyverse conventions around GitHub issue label names and colours.
4545
#'
46+
#' * `use_tidy_upkeep_issue()` creates an issue containing a checklist of
47+
#' actions to bring your package up to current tidyverse standards.
48+
#'
4649
#' @section `use_tidy_style()`:
4750
#' Uses the [styler package](https://styler.r-lib.org) package to style all code
4851
#' in a package, project, or directory, according to the [tidyverse style
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# upkeep bullets don't change accidentally
2+
3+
Code
4+
cat(upkeep_checklist(), sep = "\n")
5+
Output
6+
Pre-history
7+
8+
* [ ] `usethis::use_readme_rmd()`
9+
* [ ] `usethis::use_roxygen_md()`
10+
* [ ] `usethis::use_github_links()`
11+
It is advantageous if the link to your GitHub repo comes first, before any other URLs, e.g. pkgdown site.
12+
* [ ] `usethis::use_pkgdown_github_pages()`
13+
* [ ] `usethis::use_tidy_labels()`
14+
* [ ] `usethis::use_tidy_style()`
15+
* [ ] `usethis::use_tidy_description()`
16+
* [ ] `urlchecker::url_check()`
17+
18+
2020
19+
20+
* [ ] `usethis::use_package_doc()`
21+
Consider letting usethis manage your `@importFrom` directives here.
22+
`usethis::use_import_from()` is handy for this.
23+
* [ ] `usethis::use_testthat(3)` and upgrade to 3e, [testthat 3e vignette](https://testthat.r-lib.org/articles/third-edition.html)
24+
* [ ] Align the names of `R/` files and `test/` files for workflow happiness.
25+
`usethis::rename_files()` can be helpful.
26+
27+
2021
28+
29+
* [ ] `usethis::use_tidy_dependencies()`
30+
* [ ] `usethis::use_tidy_github_actions()` and update artisanal actions to use `setup-r-dependencies`
31+
* [ ] Remove check environments section from `cran-comments.md`
32+
* [ ] Bump required R version in DESCRIPTION to 3.4
33+
* [ ] Use lifecycle instead of artisanal deprecation messages, as described in [Communicate lifecycle changes in your functions](https://lifecycle.r-lib.org/articles/communicate.html)
34+
35+

tests/testthat/test-tidy-upkeep.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test_that("upkeep bullets don't change accidentally", {
2+
expect_snapshot(cat(upkeep_checklist(), sep = "\n"))
3+
})

0 commit comments

Comments
 (0)