diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index 1864a7b..e8d85d7 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -29,6 +29,9 @@ steps: # rscript_startup arg: required to pass down global option to future workers https://github.com/HenrikBengtsson/future/issues/134#issuecomment-2245666169 - git clone https://pat-s:$$git_ro_token@git.devxy.io/devxy/arm64-r-binaries.git && cd arm64-r-binaries - R -q -e 'install.packages(".", repos = NULL, quiet = FALSE); packageVersion("rBinaries")' + # manually install some packages into the cache so that some builds don't fail + # Hmisc -> ABCanalysis + - R -q -e 'pak::pak("Hmisc")' - R -q -e 'options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = "error"); pkgs = tools::CRAN_package_db()[[1]][1:500]; library(rBinaries); future::plan("multisession", workers = 4, rscript_startup = quote(options(crayon.enabled = TRUE))); foo = lapply(pkgs, function(x) build_binary_package(x, build_for_minor=FALSE, debug = FALSE, force = TRUE))' backend_options: kubernetes: diff --git a/R/build_binaries.R b/R/build_binaries.R index 419d7bb..46fe92e 100644 --- a/R/build_binaries.R +++ b/R/build_binaries.R @@ -88,26 +88,29 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL, tryCatch( { p() - store_build_metadata(x, y, platform, error_occurred = FALSE, force = force) 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) con <- DBI::dbConnect(RPostgres::Postgres(), 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)) - } + # 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() - store_build_metadata(x, y, platform, error_occurred = TRUE, force = TRUE, error = e) + # error <- paste("Call:", deparse(conditionCall(e)), "\nMessage:", conditionMessage(e), sep = " ") + store_build_metadata(x, y, platform, error_occurred = TRUE, force = TRUE, error = e$stderr) } ) }, package_name, tag, future.seed = TRUE) diff --git a/R/metadata-build.R b/R/metadata-build.R index 95af938..3da2e31 100644 --- a/R/metadata-build.R +++ b/R/metadata-build.R @@ -13,12 +13,16 @@ store_build_metadata <- function( package_name, "' AND tag = '", tag, "'" )) + if (is.null(error)) { + error <- NA + } + if (nrow(existing_entries) >= 1 && !force) { cli::cli_alert("{.fun store_build_metadata}: Build metadata for {.field {.pkg package_name}} {.field {tag}} already exists.") } else if (nrow(existing_entries) >= 1 && force) { cli::cli_alert_info("{.fun store_build_metadata}: Force overwriting build metadata for {.pkg {package_name}} {.field {tag}} because {.code force = TRUE} was set.") - DBI::dbExecute(con, sprintf("UPDATE single_builds SET build_timestamp = '%s', error_occurred = %s, error = '%s' WHERE package_name = '%s' and tag = '%s'", format(Sys.time(), "%Y-%m-%d %H:%M:%S"), error_occurred, error, package_name, tag)) + DBI::dbExecute(con, "UPDATE single_builds SET build_timestamp = $1, error_occurred = $2, error = $3 WHERE package_name = $4 and tag = $5", params = list(format(Sys.time(), "%Y-%m-%d %H:%M:%S"), error_occurred, error, package_name, tag)) } else if (nrow(existing_entries) == 0) { cli::cli_alert("{.fun store_build_metadata}: Storing build metadata for {.pkg {package_name}} {.field {tag}}.") # Create a data frame with the metadata