cleanup and reorg
This commit is contained in:
parent
995ca841d6
commit
2e5939ace8
1 changed files with 103 additions and 68 deletions
|
|
@ -1,7 +1,9 @@
|
|||
#' Build R binary packages
|
||||
#' @import progressr
|
||||
#' @importFrom future plan
|
||||
#' @importFrom future.apply future_mapply
|
||||
#' @importFrom gert git_config_set
|
||||
#' @importFrom progressr with_progress progressor
|
||||
#' @importFrom gert git_config_global_set git_clone
|
||||
#' @importFrom pak local_install_dev_deps
|
||||
#' @importFrom pkgbuild build
|
||||
#' @export
|
||||
|
|
@ -45,7 +47,6 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
gert::git_config_global_set("advice.detachedHead", "false")
|
||||
|
||||
if (is.null(tag)) {
|
||||
# get all tags of package
|
||||
gert::git_clone(sprintf("https://github.com/cran/%s", package_name),
|
||||
path = sprintf("%s/%s", tempdir(), "tmp1"),
|
||||
verbose = FALSE
|
||||
|
|
@ -58,14 +59,6 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
unlink(sprintf("%s/%s", tempdir(), "tmp1"), force = TRUE, recursive = TRUE)
|
||||
tag <- all_tags$name
|
||||
package_name <- rep(package_name, length(tag))
|
||||
|
||||
# if (reset_db_metadata) {
|
||||
# cli::cli_alert_warning("{.fun build_binary_package}: Resetting metadata for {.pkg {package_name}}.")
|
||||
|
||||
# con <- dbConnect(RSQLite::SQLite(), dbname = "metadata_summary.db")
|
||||
# # Remove all entries from the metadata_summary table
|
||||
# dbExecute(con, "DELETE FROM metadata_summary")
|
||||
# }
|
||||
}
|
||||
|
||||
### Install system dependencies
|
||||
|
|
@ -84,7 +77,7 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
|
||||
out <- progressr::with_progress({
|
||||
p <- progressr::progressor(along = tag)
|
||||
future_mapply(function(x, y) {
|
||||
future::future_mapply(function(x, y) {
|
||||
tryCatch(
|
||||
{
|
||||
p()
|
||||
|
|
@ -95,21 +88,13 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
|
||||
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
|
||||
)
|
||||
# here we check if build_duration is empty and take this as an indicator that the build failed. I.e. we set error_occurred = TRUE
|
||||
# val <- dbGetQuery(con, sprintf("SELECT build_duration FROM single_builds WHERE package_name = '%s' and tag = '%s'", x, y))
|
||||
# if (is.na(val)) {
|
||||
# dbExecute(con, sprintf("UPDATE single_builds SET error_occurred = TRUE WHERE package_name = '%s' and tag = '%s'", x, y))
|
||||
# }
|
||||
dbDisconnect(con)
|
||||
},
|
||||
error = function(e) {
|
||||
message(sprintf("Error in processing package %s with tag %s: %s", x, y, e))
|
||||
# print(e)
|
||||
# str(e)
|
||||
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, x, y)
|
||||
unlink(local_clone_dir_single, force = TRUE, recursive = TRUE)
|
||||
# NB: this does not always work, which is why we are using the lack of build_duration as a secondary factor in store_metadata()
|
||||
# error <- paste("Call:", deparse(conditionCall(e)), "\nMessage:", conditionMessage(e), sep = " ")
|
||||
# only stderr contains the important information why the build failed
|
||||
store_build_metadata(x, y, platform, error_occurred = TRUE, force = TRUE, error = e$stderr)
|
||||
}
|
||||
)
|
||||
|
|
@ -122,7 +107,7 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
cli::cli_h2("Uploading ({.pkg {package_name[1]}})")
|
||||
out <- progressr::with_progress({
|
||||
p <- progressr::progressor(along = tag)
|
||||
future_mapply(function(x, y) {
|
||||
future::future_mapply(function(x, y) {
|
||||
tryCatch(
|
||||
{
|
||||
p()
|
||||
|
|
@ -137,14 +122,14 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
|
||||
cli::cli_h2("Updating package index for package ({.pkg {package_name[1]}})")
|
||||
|
||||
add_to_package_index(package_name[1], debug = debug)
|
||||
# add_to_package_index(package_name[1], debug = debug)
|
||||
|
||||
return(invisible(TRUE))
|
||||
}
|
||||
|
||||
#' @importFrom cli cli_alert
|
||||
#' @importFrom pkgbuild build
|
||||
#' @importFrom fs file_size
|
||||
#' @importFrom fs file_size file_move
|
||||
#' @export
|
||||
build_single_tag <- function(
|
||||
package_name, tag = NULL,
|
||||
|
|
@ -156,7 +141,7 @@ build_single_tag <- function(
|
|||
|
||||
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, package_name, tag)
|
||||
|
||||
# Using system git here as {gert} does not provide this functionality
|
||||
# Using system git here as {gert} does not provide this functionality to checkout a branch by tag
|
||||
system2("git", args = c(
|
||||
"clone", "-q", sprintf("--branch=%s", tag),
|
||||
sprintf("https://github.com/cran/%s", package_name), local_clone_dir_single
|
||||
|
|
|
|||
Loading…
Reference in a new issue