From d668dd96c2fbde0668585c78c588f42d75156a4e Mon Sep 17 00:00:00 2001 From: pat-s Date: Tue, 16 Jun 2026 09:04:17 +0200 Subject: [PATCH] feat(build): skip already-built package versions on workflow restart build-all reads a static pkgs_to_build.rds produced once by the install-deps step, so a restarted build job re-cycles every package an interrupted run already produced. Query the build-metadata DB at job start and drop the (Package, Version) pairs already built successfully for this platform/arch, so a restart only processes what is genuinely left. Relies on bincraft writing the success row only after a confirmed S3 upload (rpkgs/bincraft#56), so a DB success guarantees the binary is published. --- local/build-all.R | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/local/build-all.R b/local/build-all.R index 102d18c..d46e27a 100644 --- a/local/build-all.R +++ b/local/build-all.R @@ -25,6 +25,31 @@ sprintf("# of package versions for this job: %s", nrow(chunk)) exclude <- jsonlite::fromJSON("local/excluded-packages.json")[["package"]] chunk <- chunk[!chunk$Package %in% exclude, ] +# Skip package versions already built in a previous run. +# pkgs_to_build.rds is a static snapshot from the install-deps step, so on a +# restart it still lists everything an interrupted run already produced. The +# metadata DB reflects that progress, so we re-derive the remaining set here. +platform <- paste(Sys.getenv("OS"), gsub("[.]", "", Sys.getenv("OS_VERSION")), sep = "-") +arch <- Sys.getenv("ARCH") +con <- DBI::dbConnect( + RPostgres::Postgres(), + dbname = "build_metadata", + host = "r-binaries.devxy.io", + port = 15432, + user = "rpkgs", + password = Sys.getenv("PGPASS"), + sslmode = "require" +) +built <- DBI::dbGetQuery( + con, + "SELECT name, tag FROM single_builds WHERE platform = $1 AND arch = $2 AND error_occurred = FALSE", + params = list(platform, arch) +) +DBI::dbDisconnect(con) +before <- nrow(chunk) +chunk <- chunk[!paste(chunk$Package, chunk$Version) %in% paste(built$name, built$tag), ] +sprintf("Skipped %d already-built package versions; %d remaining for this job", before - nrow(chunk), nrow(chunk)) + # Read pre-computed S3 listing from install-deps step # This avoids loading s3fs/reticulate/Python in the build container, # saving significant memory for pak subprocess forks