build-cran-binaries/local/r-minor-helpers.R
pat-s cdfdcd035d
perf: seed pure-R binaries into a new slot, interleave shards, and stop builds before the timeout
- Add local/seed-pure-r.R, opt-in via SEED_FROM on install-deps: copy pure-R
  binaries server-side from a slot of the same OS family and arch, after
  verifying each is a binary, has no compiled code, was built by the primary
  R minor, and passes bincraft's cross-minor ABI check; write the
  single_builds and abi_flat_safety rows an upload would.
- Interleave build-all shards with shard_slice() instead of contiguous
  alphabetical blocks, which ranged from 0.1h to 28h per shard.
- Share one BUILD_DEADLINE (BUILD_BUDGET_HOURS, default 44h) across every
  build pass of a build-all-versions step so long runs stop cleanly and
  still archive and index what they built.
- Derive the single_builds platform with codename_platform() instead of a
  hard-coded list.
2026-10-24 01:58:25 +00:00

63 lines
2.2 KiB
R

# Metadata-only ABI triage so the full build avoids downloading every source.
# Mirrors bincraft::abi_classify rules 1-2; "ambiguous" packages still need a
# source grep via bincraft::needs_per_minor_recompile().
classify_from_metadata <- function(needs_compilation, linking_to, risky_deps) {
nc <- if (length(needs_compilation) == 0L || is.na(needs_compilation)) {
""
} else {
tolower(trimws(needs_compilation))
}
if (!identical(nc, "yes")) {
return("not-sensitive")
}
lt <- if (length(linking_to) == 0L || is.na(linking_to)) "" else linking_to
linked <- trimws(unlist(strsplit(lt, "[,\n]")))
linked <- sub("\\s*\\(.*\\)$", "", linked) # strip "(>= x)" constraints
linked <- linked[nzchar(linked)]
if (any(linked %in% risky_deps)) {
return("sensitive")
}
"ambiguous"
}
parse_build_args <- function(args) {
sensitive_only <- "--sensitive-only" %in% args
pos <- args[!startsWith(args, "--")]
list(
sensitive_only = sensitive_only,
split_into = as.integer(pos[1L]),
split_index = as.integer(pos[2L]),
ncpus = as.integer(pos[3L])
)
}
# The `single_builds` platform name for a bincraft codename, e.g. alpine324 ->
# "alpine-324", rhel9 -> "redhat-9". NA for a codename this repo does not build.
codename_platform <- function(codename) {
ubuntu <- c(jammy = "2204", noble = "2404", resolute = "2604")
if (codename %in% names(ubuntu)) {
return(paste0("ubuntu-", ubuntu[[codename]]))
}
if (grepl("^rhel[0-9]+$", codename)) {
return(sub("^rhel", "redhat-", codename))
}
if (grepl("^alpine[0-9]+$", codename)) {
return(sub("^alpine", "alpine-", codename))
}
NA_character_
}
# The wall-clock deadline a build loop must stop at, from BUILD_DEADLINE (epoch
# seconds). The pipeline sets it once per step, so every pass in the step shares
# one budget and the steps after the builds (archiving, the index upload) still
# get to run before Crow's timeout kills the step. Unset or unparsable means no
# deadline.
build_deadline <- function(value = Sys.getenv("BUILD_DEADLINE", unset = "")) {
deadline <- suppressWarnings(as.numeric(value))
if (length(deadline) != 1L || is.na(deadline)) Inf else deadline
}
deadline_reached <- function(deadline, now = as.numeric(Sys.time())) {
now >= deadline
}