Some checks failed
ci/crow/manual/weekly-rebuild-missing/6 Pipeline is pending
ci/crow/manual/weekly-rebuild-missing/8 Pipeline is pending
ci/crow/manual/weekly-rebuild-missing/10 Pipeline is pending
ci/crow/manual/weekly-rebuild-missing/12 Pipeline is pending
ci/crow/manual/weekly-rebuild-missing/14 Pipeline is pending
ci/crow/manual/weekly-rebuild-missing/2 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/4 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/9 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/11 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/3 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/1 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/5 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/7 Pipeline was canceled
ci/crow/manual/weekly-rebuild-missing/13 Pipeline was canceled
## Motivation The weekly rebuild hit GitHub's per-user REST rate limit (HTTP 403 "API rate limit exceeded for user ID ..."). The root cause and the shared fix live in bincraft (rpkgs/bincraft#74): version resolution now comes from CRAN metadata instead of the GitHub tags API, and ABI classification is cached. This PR wires the consumer side. ## Changes - `local/build-one.R`: `classify()` no longer clones `github.com/cran` and calls `bincraft::needs_per_minor_recompile()` itself. It now delegates to the newly exported `bincraft::classify_r_minor_sensitive()`, passing the metadata-DB parameters so the verdict is fetched from the CRAN source tarball (no GitHub) and cached in the `abi_classification` table. Repeated runs and new-OS full rebuilds reuse the cached verdict. ## Behaviour change - No functional change to what gets built or where; only how sensitivity is determined (cached, CRAN-tarball-based, no GitHub clone in this path). ## Dependency - Requires a bincraft release that includes rpkgs/bincraft#74 (exports `classify_r_minor_sensitive()`). Merge and release that first; this branch only takes effect once CI installs the updated bincraft. Reviewed-on: #136
142 lines
4.5 KiB
R
142 lines
4.5 KiB
R
# Targeted (re)build of specific versions of a single package.
|
|
# Invoked inside a build-env container (see docker/build-one.Dockerfile).
|
|
# Usage: build-one.R [--sensitive-only] <package> <version> [<version> ...]
|
|
# Sensitivity is auto-detected per version via bincraft's ABI classifier:
|
|
# risky packages go to the per-minor slot, everything else to the generic slot.
|
|
# With --sensitive-only, non-risky versions are skipped (used for the extra
|
|
# per-minor passes under non-primary R versions).
|
|
|
|
options(crayon.enabled = TRUE, future.globals.onReference = NULL)
|
|
|
|
args <- commandArgs(trailingOnly = TRUE)
|
|
sensitive_only <- "--sensitive-only" %in% args
|
|
args <- args[args != "--sensitive-only"]
|
|
if (length(args) < 2L) {
|
|
stop(
|
|
"usage: build-one.R [--sensitive-only] <package> <version> [<version> ...]",
|
|
call. = FALSE
|
|
)
|
|
}
|
|
package <- args[1L]
|
|
versions <- args[-1L]
|
|
|
|
library(bincraft, quietly = TRUE)
|
|
|
|
s3 <- list(
|
|
s3_endpoint = "https://s3.eu-central-003.backblazeb2.com",
|
|
s3_region = "eu-central-003",
|
|
s3_bucket = "devxy-rpkgs-binaries",
|
|
s3_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"),
|
|
s3_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY")
|
|
)
|
|
|
|
# Ask bincraft's ABI classifier whether a version must be rebuilt per R minor.
|
|
# The classifier downloads the CRAN source tarball (no GitHub) and caches the
|
|
# verdict in the metadata DB keyed on package+version, so repeated runs and
|
|
# new-OS rebuilds reuse it. Fails safe to TRUE inside bincraft so a
|
|
# possibly-fragile binary is never served from the cross-minor generic slot.
|
|
classify <- function(pkg, ver) {
|
|
bincraft::classify_r_minor_sensitive(
|
|
pkg,
|
|
ver,
|
|
metadata_db_host = "r-binaries.devxy.io",
|
|
metadata_db_name = "build_metadata",
|
|
metadata_db_port = 15432,
|
|
metadata_db_user = "rpkgs",
|
|
metadata_db_password = Sys.getenv("PGPASS"),
|
|
metadata_db_sslmode = "require"
|
|
)
|
|
}
|
|
|
|
minor <- paste(
|
|
R.version$major,
|
|
strsplit(R.version$minor, ".", fixed = TRUE)[[1L]][1L],
|
|
sep = "."
|
|
)
|
|
touched_generic <- FALSE
|
|
touched_minor <- FALSE
|
|
|
|
for (ver in versions) {
|
|
sensitive <- classify(package, ver)
|
|
if (sensitive_only && !sensitive) {
|
|
message(sprintf(
|
|
"Skipping %s %s under R %s (not r-minor-sensitive)",
|
|
package,
|
|
ver,
|
|
minor
|
|
))
|
|
next
|
|
}
|
|
cat(sprintf(
|
|
"Building %s %s (r_minor_sensitive=%s, R %s)\n",
|
|
package,
|
|
ver,
|
|
sensitive,
|
|
minor
|
|
))
|
|
bincraft::build_binary_package(
|
|
package,
|
|
tag = ver,
|
|
is_r_minor_sensitive = sensitive,
|
|
force = TRUE,
|
|
upload = TRUE,
|
|
archive = TRUE,
|
|
patches = "local/patches",
|
|
store_build_metadata = TRUE,
|
|
s3_endpoint = s3$s3_endpoint,
|
|
s3_region = s3$s3_region,
|
|
s3_bucket = s3$s3_bucket,
|
|
s3_access_key_id = s3$s3_access_key_id,
|
|
s3_secret_access_key = s3$s3_secret_access_key,
|
|
metadata_db_host = "r-binaries.devxy.io",
|
|
metadata_db_name = "build_metadata",
|
|
metadata_db_table = "single_builds",
|
|
metadata_db_user = "rpkgs",
|
|
metadata_db_password = Sys.getenv("PGPASS"),
|
|
metadata_db_sslmode = "require",
|
|
metadata_db_port = 15432
|
|
)
|
|
if (sensitive) touched_minor <- TRUE else touched_generic <- TRUE
|
|
}
|
|
|
|
# Signal the container wrapper whether per-minor passes are warranted (a single
|
|
# package's sensitivity is the same across R minors, so a non-sensitive package
|
|
# need not touch any other minor's library).
|
|
if (touched_minor) {
|
|
file.create(".r_minor_sensitive")
|
|
}
|
|
|
|
# Refresh the PACKAGES index for each slot we wrote to, so the (re)built binary
|
|
# is immediately resolvable by clients.
|
|
codename <- bincraft::set_codename(NULL)
|
|
# cranlike keeps a working PACKAGES.db in the CWD; clear any copy left by a
|
|
# previous pass so each per-slot index is built fresh. Otherwise the 2nd index
|
|
# update in the same container fails with "table packages already exists".
|
|
clean_index_workdir <- function() {
|
|
unlink(c("PACKAGES", "PACKAGES.gz", "PACKAGES.rds", "PACKAGES.db"))
|
|
}
|
|
if (touched_generic) {
|
|
cat("Refreshing generic index\n")
|
|
clean_index_workdir()
|
|
bincraft::upload_package_index(
|
|
codename = codename,
|
|
s3_endpoint = s3$s3_endpoint,
|
|
s3_region = s3$s3_region,
|
|
s3_bucket = s3$s3_bucket,
|
|
s3_access_key_id = s3$s3_access_key_id,
|
|
s3_secret_access_key = s3$s3_secret_access_key
|
|
)
|
|
}
|
|
if (touched_minor) {
|
|
cat(sprintf("Refreshing per-minor index %s\n", minor))
|
|
clean_index_workdir()
|
|
bincraft::upload_package_index(
|
|
codename = codename,
|
|
r_minor = minor,
|
|
s3_endpoint = s3$s3_endpoint,
|
|
s3_region = s3$s3_region,
|
|
s3_bucket = s3$s3_bucket,
|
|
s3_access_key_id = s3$s3_access_key_id,
|
|
s3_secret_access_key = s3$s3_secret_access_key
|
|
)
|
|
}
|