improve detection for failed builds

This commit is contained in:
Patrick Schratz 2024-07-24 22:08:43 +02:00
commit 0facfb0556
Signed by: pat-s
GPG key ID: 3C6318841EF78925
2 changed files with 11 additions and 4 deletions

View file

@ -45,6 +45,12 @@ store_build_metadata <- function(
dbWriteTable(con, "single_builds", metadata, append = TRUE)
}
# 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'", package_name, tag))
if (is.na(val)) {
dbExecute(con, sprintf("UPDATE single_builds SET error_occurred = TRUE WHERE package_name = '%s' and tag = '%s'", package_name, tag))
}
# Close the SQLite connection
dbDisconnect(con)

View file

@ -6,7 +6,7 @@
#' @importFrom pkgbuild build
#' @export
build_binary_package <- function(package_name, tag = NULL, codename = NULL,
r_version_minor = NULL, build_for_minor = TRUE,
r_minor_version = NULL, build_for_minor = TRUE,
local_build_root = "/root",
local_clone_dir = "/tmp",
platform = "redhat-9",
@ -20,12 +20,12 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
cli::cli_alert_warning("DEBUG: codename {codename}.")
}
if (is.null(r_version_minor)) {
r_version_minor <- sub("R version (\\d+\\.\\d+).*", "\\1", R.Version()$version.string)
if (is.null(r_minor_version)) {
r_minor_version <- sub("R version (\\d+\\.\\d+).*", "\\1", R.Version()$version.string)
}
# create directory structure
dir_out_bin <- set_bin_path(r_version_minor, build_for_minor, local_build_root, codename)
dir_out_bin <- set_bin_path(r_minor_version, build_for_minor, local_build_root, codename)
if (debug) {
cli::cli_alert_warning("DEBUG: dir_out_bin {dir_out_bin}.")
@ -95,6 +95,7 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
message(sprintf("Error in processing package %s with tag %s: %s", x, y, 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()
store_build_metadata(x, y, platform, error_occurred = TRUE, force = force)
}
)