Skip to content

Commit d247d52

Browse files
authored
Add check_mac_release function to submit to the mac builder (#2387)
* Add check_mac_release function to submit to the mac builder Fixes #2375 * Updates after review - Removed the email argument - added support for custom dependencies - added `task` argument to `stop_for_status()`
1 parent 37fd5d8 commit d247d52

8 files changed

Lines changed: 136 additions & 8 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ VignetteBuilder:
6767
Encoding: UTF-8
6868
Language: en-US
6969
Roxygen: list(markdown = TRUE)
70-
RoxygenNote: 7.1.1
70+
RoxygenNote: 7.1.2

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export(build_vignettes)
1313
export(check)
1414
export(check_built)
1515
export(check_dep_version)
16+
export(check_mac_release)
1617
export(check_man)
1718
export(check_rhub)
1819
export(check_win_devel)

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# devtools (development version)
22

3-
`release()` and `submit_cran()` now record submission details using the Debian Control File format, for better machine-readability. This file has a new name, CRAN-SUBMISSION (instead of CRAN-RELEASE) and now includes package version, in addition to the full SHA and a timestamp.
3+
* New `check_mac_release()` function to check a package using the macOS builder at https://mac.r-project.org/macbuilder/submit.html (#2375)
4+
5+
* `release()` and `submit_cran()` now record submission details using the Debian Control File format, for better machine-readability. This file has a new name, CRAN-SUBMISSION (instead of CRAN-RELEASE) and now includes package version, in addition to the full SHA and a timestamp.
46

57
# devtools 2.4.2
68

R/check-mac.R

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#' Check macOS package
2+
#'
3+
#' This function works by bundling source package, and then uploading to
4+
#' <https://mac.r-project.org/macbuilder/submit.html>. This function returns a
5+
#' link to the page with the check results.
6+
#'
7+
#' @template devtools
8+
#' @inheritParams pkgbuild::build
9+
#' @param dep_pkgs Additional custom dependencies to install prior to checking the package.
10+
#' @param quiet If `TRUE`, suppresses output.
11+
#' @param ... Additional arguments passed to [pkgbuild::build()].
12+
#' @family build functions
13+
#' @return The url with the check results (invisibly)
14+
#' @export
15+
check_mac_release <- function(pkg = ".", dep_pkgs = ".", args = NULL, manual = TRUE, quiet = FALSE, ...) {
16+
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))
17+
18+
pkg <- as.package(pkg)
19+
20+
if (!quiet) {
21+
cli::cli_alert_info(
22+
"Building macOS version of {.pkg {pkg$package}} ({pkg$version})",
23+
"with https://mac.r-project.org/macbuilder/submit.html."
24+
)
25+
}
26+
27+
built_path <- pkgbuild::build(pkg$path, tempdir(),
28+
args = args,
29+
manual = manual, quiet = quiet, ...
30+
)
31+
32+
dep_built_paths <- character()
33+
for (i in seq_along(dep_pkgs)) {
34+
dep_pkg <- as.package(dep_pkgs[[i]])$path
35+
dep_built_paths[[i]] <- pkgbuild::build(dep_pkg, tempdir(),
36+
args = args,
37+
manual = manual, quiet = quiet, ...
38+
)
39+
}
40+
on.exit(file_delete(c(built_path, dep_built_paths)), add = TRUE)
41+
42+
url <- "https://mac.r-project.org/macbuilder/v1/submit"
43+
44+
body <- list(pkgfile = httr::upload_file(built_path))
45+
46+
if (length(dep_built_paths) > 0) {
47+
uploads <- lapply(dep_built_paths, httr::upload_file)
48+
names(uploads) <- rep("depfiles", length(uploads))
49+
body <- append(body, uploads)
50+
}
51+
52+
res <- httr::POST(url,
53+
body = body,
54+
headers = list(
55+
"Content-Type" = "multipart/form-data"
56+
),
57+
encode = "multipart"
58+
)
59+
60+
httr::stop_for_status(res, task = "Uploading package")
61+
62+
response_url <- httr::content(res)$url
63+
64+
if (!quiet) {
65+
time <- strftime(Sys.time() + 10 * 60, "%I:%M %p")
66+
67+
cli::cli_alert_success(
68+
"[{Sys.Date()}] Check {.url {response_url}} for the results in 5-10 mins (~{time})."
69+
)
70+
}
71+
72+
invisible(response_url)
73+
}

man/check.Rd

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_mac_release.Rd

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_rhub.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_win.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)