feat(local): metadata-only ABI triage helper

This commit is contained in:
Patrick Schratz 2026-06-13 20:46:49 +02:00
commit dbf26d7786
Signed by: pat-s
GPG key ID: 3C6318841EF78925
2 changed files with 38 additions and 0 deletions

22
local/r-minor-helpers.R Normal file
View file

@ -0,0 +1,22 @@
# 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"
}

View file

@ -0,0 +1,16 @@
source(file.path("..", "r-minor-helpers.R"))
test_that("pure-r (NeedsCompilation != yes) is not sensitive", {
expect_identical(classify_from_metadata("no", NA, c("Rcpp")), "not-sensitive")
expect_identical(classify_from_metadata("", "Rcpp", c("Rcpp")), "not-sensitive")
})
test_that("LinkingTo a risky dep is sensitive (version constraints stripped)", {
expect_identical(classify_from_metadata("yes", "Rcpp (>= 1.0)", c("Rcpp")), "sensitive")
expect_identical(classify_from_metadata("yes", "R6,\n cpp11", c("Rcpp", "cpp11")), "sensitive")
})
test_that("compiled but no risky LinkingTo is ambiguous (needs source)", {
expect_identical(classify_from_metadata("yes", "R6", c("Rcpp", "cpp11")), "ambiguous")
expect_identical(classify_from_metadata("yes", NA, c("Rcpp")), "ambiguous")
})