-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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()`
- Loading branch information
Showing
8 changed files
with
136 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#' Check macOS package | ||
#' | ||
#' This function works by bundling source package, and then uploading to | ||
#' <https://mac.r-project.org/macbuilder/submit.html>. This function returns a | ||
#' link to the page with the check results. | ||
#' | ||
#' @template devtools | ||
#' @inheritParams pkgbuild::build | ||
#' @param dep_pkgs Additional custom dependencies to install prior to checking the package. | ||
#' @param quiet If `TRUE`, suppresses output. | ||
#' @param ... Additional arguments passed to [pkgbuild::build()]. | ||
#' @family build functions | ||
#' @return The url with the check results (invisibly) | ||
#' @export | ||
check_mac_release <- function(pkg = ".", dep_pkgs = ".", args = NULL, manual = TRUE, quiet = FALSE, ...) { | ||
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) | ||
|
||
pkg <- as.package(pkg) | ||
|
||
if (!quiet) { | ||
cli::cli_alert_info( | ||
"Building macOS version of {.pkg {pkg$package}} ({pkg$version})", | ||
"with https://mac.r-project.org/macbuilder/submit.html." | ||
) | ||
} | ||
|
||
built_path <- pkgbuild::build(pkg$path, tempdir(), | ||
args = args, | ||
manual = manual, quiet = quiet, ... | ||
) | ||
|
||
dep_built_paths <- character() | ||
for (i in seq_along(dep_pkgs)) { | ||
dep_pkg <- as.package(dep_pkgs[[i]])$path | ||
dep_built_paths[[i]] <- pkgbuild::build(dep_pkg, tempdir(), | ||
args = args, | ||
manual = manual, quiet = quiet, ... | ||
) | ||
} | ||
on.exit(file_delete(c(built_path, dep_built_paths)), add = TRUE) | ||
|
||
url <- "https://mac.r-project.org/macbuilder/v1/submit" | ||
|
||
body <- list(pkgfile = httr::upload_file(built_path)) | ||
|
||
if (length(dep_built_paths) > 0) { | ||
uploads <- lapply(dep_built_paths, httr::upload_file) | ||
names(uploads) <- rep("depfiles", length(uploads)) | ||
body <- append(body, uploads) | ||
} | ||
|
||
res <- httr::POST(url, | ||
body = body, | ||
headers = list( | ||
"Content-Type" = "multipart/form-data" | ||
), | ||
encode = "multipart" | ||
) | ||
|
||
httr::stop_for_status(res, task = "Uploading package") | ||
|
||
response_url <- httr::content(res)$url | ||
|
||
if (!quiet) { | ||
time <- strftime(Sys.time() + 10 * 60, "%I:%M %p") | ||
|
||
cli::cli_alert_success( | ||
"[{Sys.Date()}] Check {.url {response_url}} for the results in 5-10 mins (~{time})." | ||
) | ||
} | ||
|
||
invisible(response_url) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.