Skip to content

Commit

Permalink
Add check_mac_release function to submit to the mac builder
Browse files Browse the repository at this point in the history
Fixes #2375
  • Loading branch information
jimhester committed Nov 16, 2021
1 parent 6e30ec2 commit 41f3976
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ VignetteBuilder:
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(build_vignettes)
export(check)
export(check_built)
export(check_dep_version)
export(check_mac_release)
export(check_man)
export(check_rhub)
export(check_win_devel)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# devtools (development version)

`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.
* New `check_mac_release()` function to check a package using the macOS builder at https://mac.r-project.org/macbuilder/submit.html (#2375)

* `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.

# devtools 2.4.2

Expand Down
71 changes: 71 additions & 0 deletions R/check-mac.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#' Check macOS package
#'
#' This function works by bundling source package, and then uploading to
#' <https://mac.r-project.org/macbuilder/submit.html>. Once building is
#' complete you'll receive a link to the built package in the email address
#' listed in the maintainer field.
#'
#' @template devtools
#' @inheritParams pkgbuild::build
#' @param email An alternative email to use, default `NULL` uses the package
#' Maintainer's email.
#' @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 = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) {
check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

pkg <- as.package(pkg)

if (!is.null(email)) {
desc_file <- path(pkg$path, "DESCRIPTION")
backup <- file_temp()
file_copy(desc_file, backup)
on.exit(file_move(backup, desc_file), add = TRUE)

change_maintainer_email(desc_file, email)

pkg <- as.package(pkg$path)
}

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, ...
)
on.exit(file_delete(built_path), add = TRUE)

url <- "https://mac.r-project.org/macbuilder/v1/submit"

res <- httr::POST(url,
body = list(
pkgfile = httr::upload_file(built_path)
),
headers = list(
"Content-Type" = "multipart/form-data"
),
encode = "multipart"
)

httr::stop_for_status(res)

response_url <- httr::content(res)$url

if (!quiet) {
time <- strftime(Sys.time() + 30 * 60, "%I:%M %p")

cli::cli_alert_success(
"[{Sys.Date()}] Check {.url {response_url}} for a link to results in 15-30 mins (~{time})."
)
}

invisible(response_url)
}
16 changes: 10 additions & 6 deletions man/check.Rd

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

48 changes: 48 additions & 0 deletions man/check_mac_release.Rd

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

1 change: 1 addition & 0 deletions man/check_rhub.Rd

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

1 change: 1 addition & 0 deletions man/check_win.Rd

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

0 comments on commit 41f3976

Please sign in to comment.