Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: multiverse.internals
Title: Internal Infrastructure for R-multiverse
Description: R-multiverse requires this internal infrastructure package to
automate contribution reviews and populate universes.
Version: 1.0.10
Version: 1.0.11
License: MIT + file LICENSE
URL:
https://r-multiverse.org/multiverse.internals/,
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# multiverse.internals 1.0.11

* Use `tools::analyze_license()` for continuous license checks because `utils::available.packages(repos = "https://community.r-multiverse.org", filters = "license/FOSS")` no longer returns output.
* Strengthen continuous license checks: an `NA` license (from a failed source build) is no longer acceptable.

# multiverse.internals 1.0.10

* Allow `review_pull_request()` to get advisories and organizations if not supplied.
Expand Down
5 changes: 1 addition & 4 deletions R/assert_package_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ assert_parsed_description <- function(name, description) {
)
}
license <- description$get("License")
license_data <- tools::analyze_license(license)
license_okay <- isTRUE(license_data$is_canonical) &&
(isTRUE(license_data$is_FOSS) || isTRUE(license_data$is_verified))
if (!license_okay) {
if (!all(license_okay(license))) {
return(
paste(
"Detected license",
Expand Down
2 changes: 1 addition & 1 deletion R/issues_licenses.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#' issues_licenses()
#' }
issues_licenses <- function(meta = meta_packages()) {
meta$foss[is.na(meta$foss)] <- TRUE
meta$foss[is.na(meta$foss)] <- FALSE # deliberately redundant
meta[!meta$foss, c("package", "license"), drop = FALSE]
}
25 changes: 16 additions & 9 deletions R/meta_packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ meta_packages <- function(repo = "https://community.r-multiverse.org") {
meta_api <- get_meta_api(repo)
meta_json <- get_meta_json(repo)
meta_cran <- get_meta_cran()
foss <- get_foss(repo)
data <- merge(x = meta_api, y = meta_json, all.x = TRUE, all.y = FALSE)
data <- merge(x = data, y = meta_cran, all.x = TRUE, all.y = FALSE)
data$foss[data$package %in% foss] <- TRUE
data$license[is.na(data$license)] <- "NOT FOUND"
data$foss <- get_foss(data$license)
data
}

Expand All @@ -34,19 +34,26 @@ get_meta_json <- function(repo) {
simplifyMatrix = TRUE
)
data <- clean_meta(data)
data$foss <- FALSE
if (is.null(data$remote)) {
data$remotes <- replicate(nrow(data), NULL, simplify = FALSE)
}
data[, c("package", "remotes", "foss")]
data[, c("package", "remotes")]
}

get_foss <- function(repo) {
data <- utils::available.packages(
repos = trim_url(repo),
filters = "license/FOSS"
get_foss <- function(license) {
license <- trimws(license)
foss <- rep(FALSE, length(license))
# Pre-compute most common license types because tools::analyze_license()
# is slow to iterate on large vectors of license specifications.
common <- c(
"MIT + file LICENSE",
"GPL-3",
"GPL-2"
)
as.character(data[, "Package"])
is_common <- foss %in% common
foss[is_common] <- TRUE
foss[!is_common] <- license_okay(license[!is_common])
foss
}

get_meta_cran <- function() {
Expand Down
9 changes: 9 additions & 0 deletions R/utils_license.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
license_okay <- Vectorize(
function(license) {
license_data <- tools::analyze_license(license)
isTRUE(license_data$is_canonical) &&
(isTRUE(license_data$is_FOSS) || isTRUE(license_data$is_verified))
},
"license",
USE.NAMES = FALSE
)
5 changes: 3 additions & 2 deletions tests/testthat/helper-mock.R
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ mock_meta_packages <- structure(list(
"MIT + file LICENSE", "MIT + file LICENSE", "MIT + file LICENSE",
"MIT + file LICENSE", "MIT + file LICENSE", "MIT + file LICENSE",
"AGPL-3", "MIT + file LICENSE", "GPL (>= 2)", "GPL (>= 3)",
"GPL (>= 2)", "MIT + file LICENSE", NA, "MIT + file LICENSE",
"GPL (>= 2)", "MIT + file LICENSE", "NOT FOUND", "MIT + file LICENSE",
"MIT + file LICENSE", "MIT + file LICENSE", "MIT + file LICENSE",
"MIT + file LICENSE", "GPL (>= 3)", "MIT + file LICENSE",
"MIT + file LICENSE", "Apache License (>= 2)", "GPL (>= 3)",
Expand Down Expand Up @@ -1063,7 +1063,7 @@ mock_meta_packages <- structure(list(
TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
NA, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE
), cran = c(
Expand Down Expand Up @@ -1228,6 +1228,7 @@ mock_status <- list(
success = FALSE,
published = "2025-03-06 02:51:02.348 UTC", version = "19.09.03",
remote_hash = "0fa332471d2e19548cc0f63e36873e31dbd685be",
license = "NOT FOUND",
r_cmd_check = list(issues = list(
linux = "MISSING", mac = "MISSING",
win = "MISSING", source = "FAILURE"
Expand Down