Skip to content
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
4 changes: 3 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# https://github.com/r-lib/actions/blob/v2/examples/check-standard.yaml
# https://github.com/r-lib/actions/blob/v2/examples/check-standard.yaml (2024-09-30)
on:
push:
branches: [main, master]
Expand All @@ -10,6 +10,8 @@ on:

name: R-CMD-check

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# https://github.com/r-lib/actions/blob/v2/examples/lint.yaml
# https://github.com/r-lib/actions/blob/v2/examples/lint.yaml (2024-09-30)
on:
push:
branches: [main, master]
Expand All @@ -10,12 +10,13 @@ on:

name: lint

permissions: read-all

jobs:
lint:
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/missing-deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# https://github.com/r-lib/actions/blob/v2/examples/test-coverage.yaml
# https://github.com/r-lib/actions/blob/v2/examples/test-coverage.yaml (2025-03-19)
on:
push:
branches: [main, master]
Expand All @@ -10,6 +10,8 @@ on:

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: macos-latest
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rdev
Title: R Development Tools
Version: 1.14.1
Version: 1.15.0
Authors@R:
person("John", "Benninghoff", , "jbenninghoff@mac.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6230-4742"))
Expand All @@ -23,6 +23,7 @@ Imports:
fs,
gert,
gh,
glue,
languageserver,
lintr (>= 3.0.0),
miniUI,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2024
YEAR: 2025
COPYRIGHT HOLDER: John Benninghoff
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2024 John Benninghoff
Copyright (c) 2025 John Benninghoff

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export(style_all)
export(to_document)
export(unfreeze)
export(update_wordlist_notebooks)
export(upkeep_checklist)
export(url_check)
export(url_update)
export(use_analysis_package)
Expand All @@ -42,6 +43,7 @@ export(use_rdev_pkgdown)
export(use_rprofile)
export(use_spelling)
export(use_todo)
export(use_upkeep_issue)
importFrom(cyclocomp,cyclocomp)
importFrom(languageserver,run)
importFrom(miniUI,miniPage)
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# rdev 1.15.0

* Added functions `use_upkeep_issue()` and `upkeep_checklist()`, used to open an issue in the package repository with a checklist of maintenance tasks, based on `usethis::use_upkeep_issue()` and `usethis::use_tidy_upkeep_issue()`

* Updated base GitHub Actions (`R-CMD-check`, `lint`, `missing-deps`) (update `use_rdev_package()`)

* Updated code coverage GitHub Action (`test-coverage`) (update `use_codecov()`)

* Updated Get Started vignette with additional notes on replacing [RStudio](https://posit.co/download/rstudio-desktop/) with [Positron](https://github.com/posit-dev/positron)

# rdev 1.14.1

* Improved checks for `merge_release()`
Expand Down
1 change: 1 addition & 0 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ create_github_repo <- function(repo_name, repo_desc = "", private = FALSE, org =
writeLines("and run either setup_ananlysis() or setup_rdev() to finish configuration.")

if (Sys.info()["sysname"] == "Darwin" && rlang::is_interactive()) {
# TODO: replace open with view_url
system(paste0("open ", create$html_url, "/settings"))
system(paste0("github ", fs_path))
}
Expand Down
206 changes: 206 additions & 0 deletions R/upkeep.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# workaround for ::: per https://stat.ethz.ch/pipermail/r-devel/2013-August/067210.html
`%:::%` <- function(pkg, fun) {
get(fun,
envir = asNamespace(pkg),
inherits = FALSE
)
}

#' Create an upkeep checklist in a GitHub issue
#'
#' Opens an issue in the package repository with a checklist of tasks for regular maintenance and
#' adherence to rdev package standards. Some tasks are meant to be done only once, and others should
#' be reviewed periodically. Adapted from [usethis::use_upkeep_issue()] and
#' [usethis::use_tidy_upkeep_issue()].
#'
#' @param last_upkeep Year of last upkeep. By default, the `Config/rdev/last-upkeep` field in
#' `DESCRIPTION` is consulted for this, if it's defined. If there's no information on the last
#' upkeep, the issue will contain the full checklist.
#'
#' @export
use_upkeep_issue <- function(last_upkeep = last_upkeep_year()) {
checkmate::assert_integerish(last_upkeep, len = 1, null.ok = TRUE)

gh_repo <- get_github_repo()
checklist <- upkeep_checklist(last_upkeep = last_upkeep)
title_year <- format(Sys.Date(), "%Y")
project_name <- desc::desc_get_field("Package")

issue <- gh::gh(
"POST /repos/{owner}/{repo}/issues",
owner = gh_repo$username,
repo = gh_repo$repo,
title = glue::glue("Upkeep for {project_name} ({title_year})"),
body = paste0(checklist, "\n", collapse = "")
)
Sys.sleep(1)
view_url(issue$html_url)

record_upkeep_date(Sys.Date())
}

#' Create upkeep checklist
#'
#' Build an upkeep checklist following the format of [usethis::use_tidy_upkeep_issue()].
#'
#' @param last_upkeep Year when upkeep was last performed.
#'
#' @return Upkeep checklist for current year as a GitHub markdown array.
#'
#' @export
upkeep_checklist <- function(last_upkeep = last_upkeep_year()) {
lic <- get_license()
ptype <- package_type()

bullets <- c(
"### New branch",
"",
todo('`rdev::new_branch("upkeep-{format(Sys.Date(), "%Y-%m")}")`'),
""
)

if (last_upkeep <= 2021) {
bullets <- c(
bullets,
"### Prehistory",
"",
todo("`usethis::use_roxygen_md()`"),
todo("`usethis::use_github_links()`"),
todo("`usethis::use_testthat(3)`"),
""
)
}
if (last_upkeep <= 2022) {
bullets <- c(
bullets,
"### 2022",
"",
todo("`rdev::use_spelling()`"),
todo("`rdev::use_codecov()`", length(fs::dir_ls("R")) > 1),
todo("Add `rdev.license.copyright` to `.Rprofile`", lic == "mit"),
""
)
}
if (last_upkeep <= 2023) {
bullets <- c(
bullets,
"### 2023",
"",
todo("`rdev::use_rprofile()`"),
todo("`setup-r`"),
""
)
}
if (last_upkeep <= 2024) {
bullets <- c(
bullets,
"### 2024",
"",
todo("`rdev::use_rdev_pkgdown()`", ptype == "rdev"),
todo("`rdev::use_analysis_package(use_quarto = FALSE)`", ptype == "analysis"),
""
)
}
if (last_upkeep <= 2025) {
bullets <- c(
bullets,
"### 2025",
"",
todo("`rdev::use_lintr()`"),
todo("`rdev::use_gitattributes()`"),
todo("`rdev::use_analysis_package(use_quarto = TRUE)`", ptype == "quarto"),
""
)
}

minimum_r_version <- pkg_minimum_r_version()
if (is.na(minimum_r_version) || "3.6.3" > minimum_r_version) minimum_r_version <- "3.6.3"
if (package_type() %in% c("analysis", "quarto") && "4.1.0" > minimum_r_version) {
minimum_r_version <- "4.1.0"
}
deps <- desc::desc_get_deps()
r_version <- deps[deps$package == "R", "version"]
r_version <- substr(r_version, 4, nchar(r_version))
bullets <- c(
bullets,
"### Recurring tasks",
"",
todo(
"Consider changing default branch from `master` to `main`",
usethis::git_default_branch() == "master"
),
todo(
'`usethis::use_package("R", "Depends", "{minimum_r_version}")`',
length(r_version) == 0 || minimum_r_version > r_version
),
todo(
"Check for GitHub Action updates since {last_upkeep_date()}",
desc::desc_get_field("Package") == "rdev"
),
todo("`rdev::use_rdev_package()`"),
todo("`build_quarto_site(unfreeze = TRUE)`", ptype == "quarto"),
todo(
'`usethis::use_mit_license(copyright_holder = getOption("rdev.license.copyright")`',
lic == "mit"
),
todo(
'`usethis::use_proprietary_license(getOption("rdev.license.copyright"))`',
lic == "proprietary"
),
todo(
"Update year in `inst/templates/`",
fs::dir_exists("inst/templates/") && length(fs::dir_ls("inst/templates/")) >= 1
),
todo(
"Update year in `inst/rmarkdown/templates`",
fs::dir_exists("inst/rmarkdown/templates") &&
length(fs::dir_ls("inst/rmarkdown/templates")) >= 1
),
todo(
"Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for \\
examples and https://pkgdown.r-lib.org/articles/accessibility.html for additional guidance."
),
""
)
c(bullets, checklist_footer())
}

# upkeep helpers

last_upkeep_date <- function() {
as.Date(
desc::desc_get_field("Config/rdev/last-upkeep", "2021-01-01"),
format = "%Y-%m-%d"
)
}

last_upkeep_year <- function() {
as.integer(format(last_upkeep_date(), "%Y"))
}

record_upkeep_date <- function(date) {
desc::desc_set("Config/rdev/last-upkeep", format(date, "%Y-%m-%d"), normalize = TRUE)
}

todo <- function(x, cond = TRUE) {
x <- glue::glue(x, .envir = parent.frame())
if (cond) {
paste0("- [ ] ", x)
}
}

pkg_minimum_r_version <- "usethis" %:::% "pkg_minimum_r_version"

checklist_footer <- function() {
glue::glue(
'<sup>\\
Created on {Sys.Date()} with `rdev::use_upkeep_issue()`, using \\
[rdev v{utils::packageVersion("rdev")}](https://jabenninghoff.github.io/rdev/)\\
</sup>'
)
}

view_url <- function(url, open = rlang::is_interactive()) {
if (open) utils::browseURL(url)
invisible(url)
}
8 changes: 0 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# workaround for ::: per https://stat.ethz.ch/pipermail/r-devel/2013-August/067210.html
`%:::%` <- function(pkg, fun) {
get(fun,
envir = asNamespace(pkg),
inherits = FALSE
)
}

#' Sort file
#'
#' Sorts a file using R [sort()].
Expand Down
Loading