catch more errors in building to harden tryCatch calls

This commit is contained in:
Patrick Schratz 2024-07-29 17:31:08 +02:00
commit e83b43ad1e
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -29,6 +29,8 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
# create directory structure
dir_out_bin <- set_bin_path(r_minor_version, build_for_minor, local_build_root, codename)
local_bin_path <- set_bin_path(r_minor_version, build_for_minor, local_build_root = local_build_root, codename)
if (debug) {
cli::cli_alert_warning("DEBUG: dir_out_bin {dir_out_bin}.")
}
@ -92,17 +94,19 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
{
p()
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir, platform = platform, debug = debug)
store_build_metadata(x, y, platform, error_occurred = FALSE, force = force)
cli::cli_alert_success("Successfully built package {.pkg {x}} with tag {.field {y}}.")
con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
)
dbDisconnect(con)
# if for some reason an underlying error didnt' get caught in the tryCatch calls, we check again here for the existence of the binary file on disk and mark the build as failed if it is not found
tarball_name <- sprintf("%s_%s.tar.gz", x, y)
if (file.exists(sprintf("%s/%s", local_bin_path, tarball_name))) {
store_build_metadata(x, y, platform, error_occurred = FALSE, force = force)
cli::cli_alert_success("Successfully built package {.pkg {x}} with tag {.field {y}}.")
} else {
cli::cli_alert_warning("Error in building package {.pkg {x}} with tag {.field {y}}: Uncommon/unspecific error during build.")
store_build_metadata(x, y, platform, error_occurred = TRUE, force = TRUE, error = "Uncommon/unspecific error during build")
}
},
error = function(e) {
cli::cli_alert_warning("Error in starting build command for package {.pkg {package_name}} with tag {.field {tag}}: {e}")
cli::cli_alert_warning("Error in building package {.pkg {package_name}} with tag {.field {tag}}: {e}")
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, x, y)
unlink(local_clone_dir_single, force = TRUE, recursive = TRUE)
# only stderr contains the important information why the build failed