diff --git a/.crow/weekly-audit-missing-alpine-322-arm64.yaml b/.crow/weekly-audit-missing-alpine-322-arm64.yaml index 8e6e4cc..1815163 100644 --- a/.crow/weekly-audit-missing-alpine-322-arm64.yaml +++ b/.crow/weekly-audit-missing-alpine-322-arm64.yaml @@ -20,6 +20,8 @@ steps: from_secret: REPO_RO_TOKEN GITHUB_PAT: from_secret: GITHUB_PAT + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN PLATFORM: alpine-322 ARCH: arm64 R_LIBS_USER: /mnt/cache/R-pkgs diff --git a/local/weekly-missing-binaries-audit.R b/local/weekly-missing-binaries-audit.R index 9c2b4ae..9a295d2 100644 --- a/local/weekly-missing-binaries-audit.R +++ b/local/weekly-missing-binaries-audit.R @@ -118,15 +118,36 @@ if (file.exists(excluded_path)) { # 5. Query PostgreSQL for known build failures # --------------------------------------------------------------------------- cat("Connecting to PostgreSQL...\n") -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "require" -) +pg_connect <- function() { + DBI::dbConnect( + RPostgres::Postgres(), + dbname = "build_metadata", + host = "r-binaries.devxy.io", + port = 15432, + user = "rpkgs", + password = Sys.getenv("PGPASS"), + sslmode = "require" + ) +} + +con <- NULL +for (attempt in seq_len(3)) { + con <- tryCatch(pg_connect(), error = function(e) NULL) + if (!is.null(con) && DBI::dbIsValid(con)) { + tryCatch({ + DBI::dbGetQuery(con, "SELECT 1") + break + }, error = function(e) { + try(DBI::dbDisconnect(con), silent = TRUE) + con <<- NULL + }) + } + if (attempt < 3) { + cat(sprintf("PostgreSQL connection attempt %d failed, retrying...\n", attempt)) + Sys.sleep(2 * attempt) + } +} +if (is.null(con) || !DBI::dbIsValid(con)) stop("Failed to connect to PostgreSQL after 3 attempts") on.exit(DBI::dbDisconnect(con), add = TRUE) errored_pkgs <- DBI::dbGetQuery(