From 50be3cdafc29839d6598c5b9e255ff0645535410 Mon Sep 17 00:00:00 2001 From: wlandau Date: Fri, 24 May 2024 10:21:31 -0400 Subject: [PATCH] Improve names and infrastructure --- NAMESPACE | 8 ++- R/check_checks.R | 45 --------------- R/check_descriptions.R | 43 -------------- R/issues_checks.R | 40 +++++++++++++ R/issues_descriptions.R | 33 +++++++++++ R/{check_versions.R => issues_versions.R} | 10 ++-- R/meta_checks.R | 35 ++++++++++++ R/meta_packages.R | 25 +++++++++ R/record_issues.R | 28 +++++----- R/record_versions.R | 14 ++--- R/utils_check.R | 43 -------------- R/utils_issues.R | 10 ++++ _pkgdown.yml | 14 +++-- man/check_checks.Rd | 56 ------------------- man/issues_checks.Rd | 50 +++++++++++++++++ ...descriptions.Rd => issues_descriptions.Rd} | 35 +++++------- man/{check_versions.Rd => issues_versions.Rd} | 24 ++++---- man/meta_checks.Rd | 24 ++++++++ man/meta_packages.Rd | 23 ++++++++ man/record_issues.Rd | 15 +++-- man/record_versions.Rd | 8 +-- tests/testthat/helper-mock.R | 12 ++-- tests/testthat/test-check_descriptions.R | 17 ------ ...st-check_checks.R => test-issues_checks.R} | 9 +-- tests/testthat/test-issues_descriptions.R | 18 ++++++ ...heck_versions.R => test-issues_versions.R} | 8 +-- tests/testthat/test-meta_checks.R | 14 +++++ tests/testthat/test-meta_packages.R | 11 ++++ tests/testthat/test-record_issues.R | 18 +++--- 29 files changed, 385 insertions(+), 305 deletions(-) delete mode 100644 R/check_checks.R delete mode 100644 R/check_descriptions.R create mode 100644 R/issues_checks.R create mode 100644 R/issues_descriptions.R rename R/{check_versions.R => issues_versions.R} (92%) create mode 100644 R/meta_checks.R create mode 100644 R/meta_packages.R delete mode 100644 R/utils_check.R create mode 100644 R/utils_issues.R delete mode 100644 man/check_checks.Rd create mode 100644 man/issues_checks.Rd rename man/{check_descriptions.Rd => issues_descriptions.Rd} (60%) rename man/{check_versions.Rd => issues_versions.Rd} (84%) create mode 100644 man/meta_checks.Rd create mode 100644 man/meta_packages.Rd delete mode 100644 tests/testthat/test-check_descriptions.R rename tests/testthat/{test-check_checks.R => test-issues_checks.R} (88%) create mode 100644 tests/testthat/test-issues_descriptions.R rename tests/testthat/{test-check_versions.R => test-issues_versions.R} (89%) create mode 100644 tests/testthat/test-meta_checks.R create mode 100644 tests/testthat/test-meta_packages.R diff --git a/NAMESPACE b/NAMESPACE index 5bf93c0..f976b55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,10 +4,12 @@ export(aggregate_contributions) export(assert_cran_url) export(assert_package) export(assert_release_exists) -export(check_checks) -export(check_descriptions) -export(check_versions) export(get_current_versions) +export(issues_checks) +export(issues_descriptions) +export(issues_versions) +export(meta_checks) +export(meta_packages) export(record_issues) export(record_versions) export(review_pull_request) diff --git a/R/check_checks.R b/R/check_checks.R deleted file mode 100644 index 3dce20b..0000000 --- a/R/check_checks.R +++ /dev/null @@ -1,45 +0,0 @@ -#' @title Check R-universe package check results. -#' @export -#' @family package checks for production -#' @description Check R-universe package check results. -#' @details [check_checks()] function scrapes the R-universe check API -#' to scan all R-multiverse packages for issues that may have -#' happened during building and testing. -#' @inheritSection record_issues Package checks for production -#' @return A named list of information about packages which do not comply -#' with `DESCRPTION` checks. Each name is a package name, -#' and each element contains specific information about -#' non-compliance. -#' @inheritParams check_descriptions -#' @examples -#' issues <- check_checks( -#' # R-multiverse uses https://multiverse.r-multiverse.org -#' repo = "https://wlandau.r-universe.dev" -#' ) -#' str(issues) -check_checks <- function( - repo = "https://multiverse.r-multiverse.org", - mock = NULL -) { - fields_check <- c( - "_linuxdevel", - "_macbinary", - "_wasmbinary", - "_winbinary", - "_status" - ) - fields_info <- c( - "_buildurl" - ) - fields <- c(fields_check, fields_info) - index <- mock %|||% get_package_api(repo = repo, fields = fields) - for (field in fields) { - index[[field]][is.na(index[[field]])] <- "src-failure" - } - success <- rep(TRUE, nrow(index)) - for (field in fields_check) { - success <- success & (index[[field]] %in% c("success", "skipped")) - } - index <- index[!success,, drop = FALSE] # nolint - check_list(index[, c("Package", fields)]) -} diff --git a/R/check_descriptions.R b/R/check_descriptions.R deleted file mode 100644 index f613b47..0000000 --- a/R/check_descriptions.R +++ /dev/null @@ -1,43 +0,0 @@ -#' @title Check package `DESCRIPTION` files. -#' @export -#' @family package checks for production -#' @description Check the `DESCRIPTION` files of packages for specific -#' issues. -#' @details This function scrapes the `src/contrib/PACKAGES.json` file -#' of the universe to check the data in the `DESCRIPTION` files of packages -#' for compliance. Right now, the only field checked is `Remotes:`. -#' A packages with a `Remotes:` field in the `DESCRIPTION` file may -#' depend on development versions of other packages and so are -#' excluded from the production universe. -#' @inheritSection record_issues Package checks for production -#' @return A named list of information about packages which do not comply -#' with `DESCRPTION` checks. Each name is a package name, -#' and each element contains specific information about -#' non-compliance. -#' @param repo Character of length 1, URL of the repository -#' of R package candidates for production. -#' @param mock For testing purposes only, -#' an optional pre-computed data frame with details about packages -#' for this type of check. -#' @examples -#' issues <- check_descriptions( -#' # R-multiverse uses https://multiverse.r-multiverse.org -#' repo = "https://wlandau.r-universe.dev" -#' ) -#' str(issues) -check_descriptions <- function( - repo = "https://multiverse.r-multiverse.org", - mock = NULL -) { - fields <- "Remotes" - index <- mock %|||% get_package_index(repo = repo, fields = fields) - index <- check_descriptions_remotes(index) - index <- index[, c("Package", fields)] - check_list(index) -} - -check_descriptions_remotes <- function(index) { - index$Remotes <- index$Remotes %|||% replicate(nrow(index), NULL) - index$Remotes <- lapply(index$Remotes, function(x) x[nzchar(x)]) - index[vapply(index$Remotes, length, integer(1L)) > 0L, ] -} diff --git a/R/issues_checks.R b/R/issues_checks.R new file mode 100644 index 0000000..03fbc6d --- /dev/null +++ b/R/issues_checks.R @@ -0,0 +1,40 @@ +#' @title Report issues from R-universe package check results. +#' @export +#' @family issues +#' @description Check R-universe package check results. +#' @details [issues_checks()] function scrapes the R-universe check API +#' to scan all R-multiverse packages for issues that may have +#' happened during building and testing. +#' @inheritSection record_issues Package issues +#' @return A named list of information about packages which do not comply +#' with `DESCRPTION` checks. Each name is a package name, +#' and each element contains specific information about +#' non-compliance. +#' @param meta A data frame with R-universe package check results +#' returned by [meta_checks()]. +#' @examples +#' meta <- meta_checks(repo = "https://wlandau.r-universe.dev") +#' issues <- issues_checks(meta = meta) +#' str(issues) +issues_checks <- function(meta) { + fields_check <- c( + "_linuxdevel", + "_macbinary", + "_wasmbinary", + "_winbinary", + "_status" + ) + fields_info <- c( + "_buildurl" + ) + fields <- c(fields_check, fields_info) + for (field in fields) { + meta[[field]][is.na(meta[[field]])] <- "src-failure" + } + success <- rep(TRUE, nrow(meta)) + for (field in fields_check) { + success <- success & (meta[[field]] %in% c("success", "skipped")) + } + meta <- meta[!success,, drop = FALSE] # nolint + issues_list(meta[, c("package", fields)]) +} diff --git a/R/issues_descriptions.R b/R/issues_descriptions.R new file mode 100644 index 0000000..b77c0e0 --- /dev/null +++ b/R/issues_descriptions.R @@ -0,0 +1,33 @@ +#' @title Check package `DESCRIPTION` files. +#' @export +#' @family issues +#' @description Check the `DESCRIPTION` files of packages for specific +#' issues. +#' @details This function scrapes the `src/contrib/PACKAGES.json` file +#' of the universe to check the data in the `DESCRIPTION` files of packages +#' for compliance. Right now, the only field checked is `Remotes:`. +#' A packages with a `Remotes:` field in the `DESCRIPTION` file may +#' depend on development versions of other packages and so are +#' excluded from the production universe. +#' @inheritSection record_issues Package issues +#' @return A named list of information about packages which do not comply +#' with `DESCRPTION` checks. Each name is a package name, +#' and each element contains specific information about +#' non-compliance. +#' @param meta A data frame of package metadata returned by [meta_packages()]. +#' @examples +#' meta <- meta_packages(repo = "https://wlandau.r-universe.dev") +#' issues <- issues_descriptions(meta = meta) +#' str(issues) +issues_descriptions <- function(meta) { + meta <- issues_descriptions_remotes(meta) + fields <- "remotes" + meta <- meta[, c("package", fields)] + issues_list(meta) +} + +issues_descriptions_remotes <- function(meta) { + meta$remotes <- meta$remotes %|||% replicate(nrow(meta), NULL) + meta$remotes <- lapply(meta$remotes, function(x) x[nzchar(x)]) + meta[vapply(meta$remotes, length, integer(1L)) > 0L, ] +} diff --git a/R/check_versions.R b/R/issues_versions.R similarity index 92% rename from R/check_versions.R rename to R/issues_versions.R index 8e8cf40..523b643 100644 --- a/R/check_versions.R +++ b/R/issues_versions.R @@ -1,12 +1,12 @@ #' @title Check package versions. #' @export -#' @family package checks for production +#' @family issues #' @description Check package version number history for compliance. #' @details This function checks the version number history of packages #' in R-multiverse and reports any packages with issues. The current #' released version of a given package must be unique, and it must be #' greater than all the versions of all the previous package releases. -#' @inheritSection record_issues Package checks for production +#' @inheritSection record_issues Package issues #' @return A named list of information about packages which do not comply #' with version number history checks. Each name is a package name, #' and each element contains specific information about version @@ -51,13 +51,13 @@ #' ) #' versions <- tempfile() #' writeLines(lines, versions) -#' out <- check_versions(versions) +#' out <- issues_versions(versions) #' str(out) -check_versions <- function(versions) { +issues_versions <- function(versions) { history <- jsonlite::read_json(path = versions, simplifyVector = TRUE) aligned <- (history$version_current == history$version_highest) & (history$hash_current == history$hash_highest) aligned[is.na(aligned)] <- TRUE out <- history[!aligned,, drop = FALSE] # nolint - check_list(out) + issues_list(out) } diff --git a/R/meta_checks.R b/R/meta_checks.R new file mode 100644 index 0000000..a1bc56a --- /dev/null +++ b/R/meta_checks.R @@ -0,0 +1,35 @@ +#' @title List metadata about R-universe package checks +#' @export +#' @family list +#' @description List package checks results reported by the +#' R-universe package API. +#' @return A data frame with one row per package and columns with +#' package check results. +#' @param repo Character of length 1, URL of the package repository. +#' R-multiverse uses `"https://multiverse.r-multiverse.org"`. +#' @examples +#' meta_checks(repo = "https://wlandau.r-universe.dev") +meta_checks <- function(repo = "https://multiverse.r-multiverse.org") { + fields <- c( + "_buildurl", + "_linuxdevel", + "_macbinary", + "_wasmbinary", + "_winbinary", + "_status" + ) + listing <- file.path( + repo, + "api", + paste0("packages?stream=true&fields=", paste(fields, collapse = ",")) + ) + out <- jsonlite::stream_in( + con = gzcon(url(listing)), + verbose = FALSE, + simplifyVector = TRUE, + simplifyDataFrame = TRUE, + simplifyMatrix = TRUE + ) + colnames(out) <- tolower(colnames(out)) + out +} diff --git a/R/meta_packages.R b/R/meta_packages.R new file mode 100644 index 0000000..54ed0ca --- /dev/null +++ b/R/meta_packages.R @@ -0,0 +1,25 @@ +#' @title List package metadata +#' @export +#' @family meta +#' @description List package metadata in an R universe. +#' @return A data frame with one row per package and columns with package +#' metadata. +#' @inheritParams meta_checks +#' @examples +#' meta_packages(repo = "https://wlandau.r-universe.dev") +meta_packages <- function(repo = "https://multiverse.r-multiverse.org") { + fields <- c("Version", "Remotes", "RemoteSha") + listing <- file.path( + contrib.url(repos = repo, type = "source"), + paste0("PACKAGES.json?fields=", paste(fields, collapse = ",")) + ) + out <- jsonlite::stream_in( + con = gzcon(url(listing)), + verbose = FALSE, + simplifyVector = TRUE, + simplifyDataFrame = TRUE, + simplifyMatrix = TRUE + ) + colnames(out) <- tolower(colnames(out)) + out +} diff --git a/R/record_issues.R b/R/record_issues.R index b1fb577..3a2ca96 100644 --- a/R/record_issues.R +++ b/R/record_issues.R @@ -3,12 +3,12 @@ #' @keywords package check data management #' @description Record R-multiverse package issues in #' package-specific JSON files. -#' @section Package checks for production: -#' Functions like [check_versions()] and [check_descriptions()] +#' @section Package issues: +#' Functions like [issues_versions()] and [issues_descriptions()] #' perform health checks for all packages in R-multiverse. #' Only packages that pass these checks go to the production repository at #' . For a complete list of checks, see -#' the `check_*()` functions listed at +#' the `issues_*()` functions listed at #' . #' [record_versions()] updates the version number history #' of releases in R-multiverse, and [record_issues()] gathers @@ -24,16 +24,16 @@ #' an issue was first noticed. It automatically resets the next time #' all package are resolved. #' @return `NULL` (invisibly). -#' @inheritParams check_checks -#' @inheritParams check_versions +#' @inheritParams meta_checks +#' @inheritParams issues_checks +#' @inheritParams issues_versions #' @param output Character of length 1, file path to the folder to record #' new package issues. Each call to `record_issues()` overwrites the #' contents of the repo. #' @param mock For testing purposes only, a named list of data frames -#' for the `mock` argument of each type of check. +#' for inputs to various intermediate functions. #' @examples -#' # R-multiverse uses https://multiverse.r-multiverse.org as the repo. -#' repo <- "https://wlandau.r-universe.dev" # just for testing and examples +#' repo <- "https://wlandau.r-universe.dev" #' output <- tempfile() #' versions <- tempfile() #' record_versions( @@ -61,15 +61,17 @@ record_issues <- function( mock = NULL ) { today <- mock$today %|||% format(Sys.Date(), fmt = "yyyy-mm-dd") - list() |> - issues(check_checks(repo, mock$checks), "checks") |> - issues(check_descriptions(repo, mock$descriptions), "descriptions") |> - issues(check_versions(versions = versions), "versions") |> + checks <- mock$checks %|||% meta_checks(repo = repo) + packages <- mock$packages %|||% meta_packages(repo = repo) + issues <- list() |> + add_issues(issues_checks(meta = checks), "checks") |> + add_issues(issues_descriptions(meta = packages), "descriptions") |> + add_issues(issues_versions(versions = versions), "versions") |> overwrite_issues(output = output, today = today) invisible() } -issues <- function(total, subset, category) { +add_issues <- function(total, subset, category) { for (package in names(subset)) { total[[package]][[category]] <- subset[[package]] } diff --git a/R/record_versions.R b/R/record_versions.R index a3f875f..1504846 100644 --- a/R/record_versions.R +++ b/R/record_versions.R @@ -6,10 +6,10 @@ #' @details This function tracks a manifest containing the current version, #' the current hash, the highest version ever released, and #' the hash of the highest version ever released. -#' [check_versions()] uses this information +#' [issues_versions()] uses this information #' to determine whether the package complies with best #' practices for version numbers. -#' @inheritSection record_issues Package checks for production +#' @inheritSection record_issues Package issues #' @return `NULL` (invisibly). Writes a package version manifest #' and a manifest of version issues as JSON files. #' @param versions Character of length 1, file path to a JSON manifest @@ -61,11 +61,11 @@ record_versions <- function( get_current_versions <- function( repo = "https://multiverse.r-multiverse.org" ) { - index <- get_package_index(repo = repo, fields = "RemoteSha") - index <- index[, c("Package", "Version", "RemoteSha")] - colnames(index) <- c("package", "version_current", "hash_current") - rownames(index) <- NULL - index + meta <- meta_packages(repo = repo) + meta <- meta[, c("package", "version", "remotesha")] + colnames(meta) <- c("package", "version_current", "hash_current") + rownames(meta) <- NULL + meta } read_versions_previous <- function(versions) { diff --git a/R/utils_check.R b/R/utils_check.R deleted file mode 100644 index ad6d6ff..0000000 --- a/R/utils_check.R +++ /dev/null @@ -1,43 +0,0 @@ -check_list <- function(x) { - colnames(x) <- tolower(colnames(x)) - package <- x$package - x$package <- NULL - out <- lapply(split(x, seq_len(nrow(x))), as.list) - names(out) <- package - out[order(package)] -} - -get_package_index <- function( - repo = "https://multiverse.r-multiverse.org", - fields = character(0L) -) { - listing <- file.path( - contrib.url(repos = repo, type = "source"), - paste0("PACKAGES.json?fields=", paste(fields, collapse = ",")) - ) - jsonlite::stream_in( - con = gzcon(url(listing)), - verbose = FALSE, - simplifyVector = TRUE, - simplifyDataFrame = TRUE, - simplifyMatrix = TRUE - ) -} - -get_package_api <- function( - repo = "https://multiverse.r-multiverse.org", - fields = character(0L) -) { - listing <- file.path( - repo, - "api", - paste0("packages?stream=true&fields=", paste(fields, collapse = ",")) - ) - jsonlite::stream_in( - con = gzcon(url(listing)), - verbose = FALSE, - simplifyVector = TRUE, - simplifyDataFrame = TRUE, - simplifyMatrix = TRUE - ) -} diff --git a/R/utils_issues.R b/R/utils_issues.R new file mode 100644 index 0000000..4b7bf97 --- /dev/null +++ b/R/utils_issues.R @@ -0,0 +1,10 @@ +issues_list <- function(x) { + colnames(x) <- tolower(colnames(x)) + out <- list() + for (index in seq_len(nrow(x))) { + for (field in setdiff(colnames(x), "package")) { + out[[x$package[index]]][[field]] <- x[[field]][[index]] + } + } + out[order(as.character(names(out)))] +} diff --git a/_pkgdown.yml b/_pkgdown.yml index 3147161..e5e165f 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -9,12 +9,16 @@ reference: contents: - review_pull_request - review_pull_requests -- title: Package checks for production +- title: List metadata contents: - - check_checks - - check_descriptions - - check_versions -- title: Package check data management + - meta_checks + - meta_packages +- title: Check issues + contents: + - issues_checks + - issues_descriptions + - issues_versions +- title: Record issues contents: - record_issues - record_versions diff --git a/man/check_checks.Rd b/man/check_checks.Rd deleted file mode 100644 index 295bb76..0000000 --- a/man/check_checks.Rd +++ /dev/null @@ -1,56 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_checks.R -\name{check_checks} -\alias{check_checks} -\title{Check R-universe package check results.} -\usage{ -check_checks(repo = "https://multiverse.r-multiverse.org", mock = NULL) -} -\arguments{ -\item{repo}{Character of length 1, URL of the repository -of R package candidates for production.} - -\item{mock}{For testing purposes only, -an optional pre-computed data frame with details about packages -for this type of check.} -} -\value{ -A named list of information about packages which do not comply -with \code{DESCRPTION} checks. Each name is a package name, -and each element contains specific information about -non-compliance. -} -\description{ -Check R-universe package check results. -} -\details{ -\code{\link[=check_checks]{check_checks()}} function scrapes the R-universe check API -to scan all R-multiverse packages for issues that may have -happened during building and testing. -} -\section{Package checks for production}{ - -Functions like \code{\link[=check_versions]{check_versions()}} and \code{\link[=check_descriptions]{check_descriptions()}} -perform health checks for all packages in R-multiverse. -Only packages that pass these checks go to the production repository at -\url{https://production.r-multiverse.org}. For a complete list of checks, see -the \verb{check_*()} functions listed at -\url{https://r-multiverse.org/multiverse.internals/reference.html}. -\code{\link[=record_versions]{record_versions()}} updates the version number history -of releases in R-multiverse, and \code{\link[=record_issues]{record_issues()}} gathers -together all the issues about R-multiverse packages. -} - -\examples{ - issues <- check_checks( - # R-multiverse uses https://multiverse.r-multiverse.org - repo = "https://wlandau.r-universe.dev" - ) - str(issues) -} -\seealso{ -Other package checks for production: -\code{\link{check_descriptions}()}, -\code{\link{check_versions}()} -} -\concept{package checks for production} diff --git a/man/issues_checks.Rd b/man/issues_checks.Rd new file mode 100644 index 0000000..560502c --- /dev/null +++ b/man/issues_checks.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/issues_checks.R +\name{issues_checks} +\alias{issues_checks} +\title{Report issues from R-universe package check results.} +\usage{ +issues_checks(meta) +} +\arguments{ +\item{meta}{A data frame with R-universe package check results +returned by \code{\link[=meta_checks]{meta_checks()}}.} +} +\value{ +A named list of information about packages which do not comply +with \code{DESCRPTION} checks. Each name is a package name, +and each element contains specific information about +non-compliance. +} +\description{ +Check R-universe package check results. +} +\details{ +\code{\link[=issues_checks]{issues_checks()}} function scrapes the R-universe check API +to scan all R-multiverse packages for issues that may have +happened during building and testing. +} +\section{Package issues}{ + +Functions like \code{\link[=issues_versions]{issues_versions()}} and \code{\link[=issues_descriptions]{issues_descriptions()}} +perform health checks for all packages in R-multiverse. +Only packages that pass these checks go to the production repository at +\url{https://production.r-multiverse.org}. For a complete list of checks, see +the \verb{issues_*()} functions listed at +\url{https://r-multiverse.org/multiverse.internals/reference.html}. +\code{\link[=record_versions]{record_versions()}} updates the version number history +of releases in R-multiverse, and \code{\link[=record_issues]{record_issues()}} gathers +together all the issues about R-multiverse packages. +} + +\examples{ + meta <- meta_checks(repo = "https://wlandau.r-universe.dev") + issues <- issues_checks(meta = meta) + str(issues) +} +\seealso{ +Other issues: +\code{\link{issues_descriptions}()}, +\code{\link{issues_versions}()} +} +\concept{issues} diff --git a/man/check_descriptions.Rd b/man/issues_descriptions.Rd similarity index 60% rename from man/check_descriptions.Rd rename to man/issues_descriptions.Rd index 5343165..722e8aa 100644 --- a/man/check_descriptions.Rd +++ b/man/issues_descriptions.Rd @@ -1,18 +1,13 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_descriptions.R -\name{check_descriptions} -\alias{check_descriptions} +% Please edit documentation in R/issues_descriptions.R +\name{issues_descriptions} +\alias{issues_descriptions} \title{Check package \code{DESCRIPTION} files.} \usage{ -check_descriptions(repo = "https://multiverse.r-multiverse.org", mock = NULL) +issues_descriptions(meta) } \arguments{ -\item{repo}{Character of length 1, URL of the repository -of R package candidates for production.} - -\item{mock}{For testing purposes only, -an optional pre-computed data frame with details about packages -for this type of check.} +\item{meta}{A data frame of package metadata returned by \code{\link[=meta_packages]{meta_packages()}}.} } \value{ A named list of information about packages which do not comply @@ -32,13 +27,13 @@ A packages with a \verb{Remotes:} field in the \code{DESCRIPTION} file may depend on development versions of other packages and so are excluded from the production universe. } -\section{Package checks for production}{ +\section{Package issues}{ -Functions like \code{\link[=check_versions]{check_versions()}} and \code{\link[=check_descriptions]{check_descriptions()}} +Functions like \code{\link[=issues_versions]{issues_versions()}} and \code{\link[=issues_descriptions]{issues_descriptions()}} perform health checks for all packages in R-multiverse. Only packages that pass these checks go to the production repository at \url{https://production.r-multiverse.org}. For a complete list of checks, see -the \verb{check_*()} functions listed at +the \verb{issues_*()} functions listed at \url{https://r-multiverse.org/multiverse.internals/reference.html}. \code{\link[=record_versions]{record_versions()}} updates the version number history of releases in R-multiverse, and \code{\link[=record_issues]{record_issues()}} gathers @@ -46,15 +41,13 @@ together all the issues about R-multiverse packages. } \examples{ - issues <- check_descriptions( - # R-multiverse uses https://multiverse.r-multiverse.org - repo = "https://wlandau.r-universe.dev" - ) + meta <- meta_packages(repo = "https://wlandau.r-universe.dev") + issues <- issues_descriptions(meta = meta) str(issues) } \seealso{ -Other package checks for production: -\code{\link{check_checks}()}, -\code{\link{check_versions}()} +Other issues: +\code{\link{issues_checks}()}, +\code{\link{issues_versions}()} } -\concept{package checks for production} +\concept{issues} diff --git a/man/check_versions.Rd b/man/issues_versions.Rd similarity index 84% rename from man/check_versions.Rd rename to man/issues_versions.Rd index 2d1dc05..c6d8796 100644 --- a/man/check_versions.Rd +++ b/man/issues_versions.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_versions.R -\name{check_versions} -\alias{check_versions} +% Please edit documentation in R/issues_versions.R +\name{issues_versions} +\alias{issues_versions} \title{Check package versions.} \usage{ -check_versions(versions) +issues_versions(versions) } \arguments{ \item{versions}{Character of length 1, file path to a JSON manifest @@ -30,13 +30,13 @@ in R-multiverse and reports any packages with issues. The current released version of a given package must be unique, and it must be greater than all the versions of all the previous package releases. } -\section{Package checks for production}{ +\section{Package issues}{ -Functions like \code{\link[=check_versions]{check_versions()}} and \code{\link[=check_descriptions]{check_descriptions()}} +Functions like \code{\link[=issues_versions]{issues_versions()}} and \code{\link[=issues_descriptions]{issues_descriptions()}} perform health checks for all packages in R-multiverse. Only packages that pass these checks go to the production repository at \url{https://production.r-multiverse.org}. For a complete list of checks, see -the \verb{check_*()} functions listed at +the \verb{issues_*()} functions listed at \url{https://r-multiverse.org/multiverse.internals/reference.html}. \code{\link[=record_versions]{record_versions()}} updates the version number history of releases in R-multiverse, and \code{\link[=record_issues]{record_issues()}} gathers @@ -80,12 +80,12 @@ together all the issues about R-multiverse packages. ) versions <- tempfile() writeLines(lines, versions) - out <- check_versions(versions) + out <- issues_versions(versions) str(out) } \seealso{ -Other package checks for production: -\code{\link{check_checks}()}, -\code{\link{check_descriptions}()} +Other issues: +\code{\link{issues_checks}()}, +\code{\link{issues_descriptions}()} } -\concept{package checks for production} +\concept{issues} diff --git a/man/meta_checks.Rd b/man/meta_checks.Rd new file mode 100644 index 0000000..eca1627 --- /dev/null +++ b/man/meta_checks.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/meta_checks.R +\name{meta_checks} +\alias{meta_checks} +\title{List metadata about R-universe package checks} +\usage{ +meta_checks(repo = "https://multiverse.r-multiverse.org") +} +\arguments{ +\item{repo}{Character of length 1, URL of the package repository. +R-multiverse uses \code{"https://multiverse.r-multiverse.org"}.} +} +\value{ +A data frame with one row per package and columns with +package check results. +} +\description{ +List package checks results reported by the +R-universe package API. +} +\examples{ +meta_checks(repo = "https://wlandau.r-universe.dev") +} +\concept{list} diff --git a/man/meta_packages.Rd b/man/meta_packages.Rd new file mode 100644 index 0000000..08de109 --- /dev/null +++ b/man/meta_packages.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/meta_packages.R +\name{meta_packages} +\alias{meta_packages} +\title{List package metadata} +\usage{ +meta_packages(repo = "https://multiverse.r-multiverse.org") +} +\arguments{ +\item{repo}{Character of length 1, URL of the package repository. +R-multiverse uses \code{"https://multiverse.r-multiverse.org"}.} +} +\value{ +A data frame with one row per package and columns with package +metadata. +} +\description{ +List package metadata in an R universe. +} +\examples{ +meta_packages(repo = "https://wlandau.r-universe.dev") +} +\concept{meta} diff --git a/man/record_issues.Rd b/man/record_issues.Rd index f35f00a..31d3d97 100644 --- a/man/record_issues.Rd +++ b/man/record_issues.Rd @@ -12,8 +12,8 @@ record_issues( ) } \arguments{ -\item{repo}{Character of length 1, URL of the repository -of R package candidates for production.} +\item{repo}{Character of length 1, URL of the package repository. +R-multiverse uses \code{"https://multiverse.r-multiverse.org"}.} \item{versions}{Character of length 1, file path to a JSON manifest tracking the history of released versions of packages. @@ -26,7 +26,7 @@ new package issues. Each call to \code{record_issues()} overwrites the contents of the repo.} \item{mock}{For testing purposes only, a named list of data frames -for the \code{mock} argument of each type of check.} +for inputs to various intermediate functions.} } \value{ \code{NULL} (invisibly). @@ -35,13 +35,13 @@ for the \code{mock} argument of each type of check.} Record R-multiverse package issues in package-specific JSON files. } -\section{Package checks for production}{ +\section{Package issues}{ -Functions like \code{\link[=check_versions]{check_versions()}} and \code{\link[=check_descriptions]{check_descriptions()}} +Functions like \code{\link[=issues_versions]{issues_versions()}} and \code{\link[=issues_descriptions]{issues_descriptions()}} perform health checks for all packages in R-multiverse. Only packages that pass these checks go to the production repository at \url{https://production.r-multiverse.org}. For a complete list of checks, see -the \verb{check_*()} functions listed at +the \verb{issues_*()} functions listed at \url{https://r-multiverse.org/multiverse.internals/reference.html}. \code{\link[=record_versions]{record_versions()}} updates the version number history of releases in R-multiverse, and \code{\link[=record_issues]{record_issues()}} gathers @@ -62,8 +62,7 @@ all package are resolved. } \examples{ - # R-multiverse uses https://multiverse.r-multiverse.org as the repo. - repo <- "https://wlandau.r-universe.dev" # just for testing and examples + repo <- "https://wlandau.r-universe.dev" output <- tempfile() versions <- tempfile() record_versions( diff --git a/man/record_versions.Rd b/man/record_versions.Rd index 608723b..62d1235 100644 --- a/man/record_versions.Rd +++ b/man/record_versions.Rd @@ -34,17 +34,17 @@ and their hashes. This function tracks a manifest containing the current version, the current hash, the highest version ever released, and the hash of the highest version ever released. -\code{\link[=check_versions]{check_versions()}} uses this information +\code{\link[=issues_versions]{issues_versions()}} uses this information to determine whether the package complies with best practices for version numbers. } -\section{Package checks for production}{ +\section{Package issues}{ -Functions like \code{\link[=check_versions]{check_versions()}} and \code{\link[=check_descriptions]{check_descriptions()}} +Functions like \code{\link[=issues_versions]{issues_versions()}} and \code{\link[=issues_descriptions]{issues_descriptions()}} perform health checks for all packages in R-multiverse. Only packages that pass these checks go to the production repository at \url{https://production.r-multiverse.org}. For a complete list of checks, see -the \verb{check_*()} functions listed at +the \verb{issues_*()} functions listed at \url{https://r-multiverse.org/multiverse.internals/reference.html}. \code{\link[=record_versions]{record_versions()}} updates the version number history of releases in R-multiverse, and \code{\link[=record_issues]{record_issues()}} gathers diff --git a/tests/testthat/helper-mock.R b/tests/testthat/helper-mock.R index 4f1742a..062e116 100644 --- a/tests/testthat/helper-mock.R +++ b/tests/testthat/helper-mock.R @@ -1,6 +1,6 @@ -mock_checks <- structure( +mock_meta_checks <- structure( list( - Package = c( + package = c( "tinytest", "tidytensor", "secretbase", "multiverse.internals", "SBC", "duckdb", "httpgd", "targetsketch", "stantargets", "zstdlite", "INLA", "audio.whisper", "tidypolars", @@ -102,20 +102,20 @@ mock_checks <- structure( row.names = c(NA, 19L) ) -mock_descriptions <- structure( +mock_meta_packages <- structure( list( - Package = c( + package = c( "SBC", "audio.vadwebrtc", "audio.whisper", "cmdstanr", "duckdb", "httpgd", "multitools", "multiverse.internals", "nanonext", "polars", "secretbase", "stantargets", "string2path", "targetsketch", "tidypolars", "tidytensor", "tinytest", "zstdlite" ), - Version = c( + version = c( "0.3.0.9000", "0.2", "0.4.1", "0.8.0", "0.10.1", "2.0.1", "0.1.0", "0.1.4", "1.0.0", "0.16.4", "0.5.0", "0.1.1", "0.1.6", "0.0.1", "0.7.0", "1.0.0", "1.4.1.1", "0.2.6" ), - Remotes = list( + remotes = list( NULL, NULL, "bnosac/audio.vadwebrtc", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, c("hyunjimoon/SBC", "stan-dev/cmdstanr", ""), diff --git a/tests/testthat/test-check_descriptions.R b/tests/testthat/test-check_descriptions.R deleted file mode 100644 index f906e91..0000000 --- a/tests/testthat/test-check_descriptions.R +++ /dev/null @@ -1,17 +0,0 @@ -test_that("check_descriptions() mocked", { - issues <- check_descriptions(mock = mock_descriptions) - expected <- list( - audio.whisper = list(remotes = list("bnosac/audio.vadwebrtc")), - stantargets = list( - remotes = list(c("hyunjimoon/SBC", "stan-dev/cmdstanr")) - ), - tidypolars = list(remotes = list("markvanderloo/tinytest/pkg")) - ) - expect_equal(issues, expected) -}) - -test_that("check_descriptions() on a small repo", { - issues <- check_descriptions(repo = "https://wlandau.r-universe.dev") - expect_true(is.list(issues)) - expect_named(issues) -}) diff --git a/tests/testthat/test-check_checks.R b/tests/testthat/test-issues_checks.R similarity index 88% rename from tests/testthat/test-check_checks.R rename to tests/testthat/test-issues_checks.R index 6ff5467..862a994 100644 --- a/tests/testthat/test-check_checks.R +++ b/tests/testthat/test-issues_checks.R @@ -1,5 +1,5 @@ -test_that("check_checks() mocked", { - issues <- check_checks(mock = mock_checks) +test_that("issues_checks() mocked", { + issues <- issues_checks(meta = mock_meta_checks) url <- "https://github.com/r-universe/r-multiverse/actions/runs" expected <- list( httpgd = list( @@ -45,8 +45,9 @@ test_that("check_checks() mocked", { expect_equal(issues[order(names(issues))], expected[order(names(expected))]) }) -test_that("check_checks() on a small repo", { - issues <- check_checks(repo = "https://wlandau.r-universe.dev") +test_that("issues_checks() on a small repo", { + meta <- meta_checks(repo = "https://wlandau.r-universe.dev") + issues <- issues_checks(meta = meta) expect_true(is.list(issues)) expect_named(issues) }) diff --git a/tests/testthat/test-issues_descriptions.R b/tests/testthat/test-issues_descriptions.R new file mode 100644 index 0000000..706f9de --- /dev/null +++ b/tests/testthat/test-issues_descriptions.R @@ -0,0 +1,18 @@ +test_that("issues_descriptions() mocked", { + issues <- issues_descriptions(meta = mock_meta_packages) + expected <- list( + audio.whisper = list(remotes = "bnosac/audio.vadwebrtc"), + stantargets = list( + remotes = c("hyunjimoon/SBC", "stan-dev/cmdstanr") + ), + tidypolars = list(remotes = "markvanderloo/tinytest/pkg") + ) + expect_equal(issues, expected) +}) + +test_that("issues_descriptions() on a small repo", { + meta <- meta_packages(repo = "https://wlandau.r-universe.dev") + issues <- issues_descriptions(meta = meta) + expect_true(is.list(issues)) + expect_named(issues) +}) diff --git a/tests/testthat/test-check_versions.R b/tests/testthat/test-issues_versions.R similarity index 89% rename from tests/testthat/test-check_versions.R rename to tests/testthat/test-issues_versions.R index 6aa29c8..12816c8 100644 --- a/tests/testthat/test-check_versions.R +++ b/tests/testthat/test-issues_versions.R @@ -1,4 +1,4 @@ -test_that("check_versions() mocked", { +test_that("issues_versions() mocked", { # Temporary files used in the mock test. versions <- tempfile() # First update to the manifest. @@ -13,12 +13,12 @@ test_that("check_versions() mocked", { hash_current = rep("hash_1.0.0", 4L) ) record_versions(versions = versions, current = contents) - expect_equal(unname(check_versions(versions)), list()) + expect_equal(unname(issues_versions(versions)), list()) # Update the manifest after no changes to packages or versions. suppressMessages( record_versions(versions = versions, current = contents) ) - expect_equal(unname(check_versions(versions)), list()) + expect_equal(unname(issues_versions(versions)), list()) # Update the packages in all the ways indicated above. index <- contents$package == "version_decremented" contents$version_current[index] <- "0.0.1" @@ -34,7 +34,7 @@ test_that("check_versions() mocked", { versions = versions, current = contents ) - out <- check_versions(versions) + out <- issues_versions(versions) expect_equal( out, list( diff --git a/tests/testthat/test-meta_checks.R b/tests/testthat/test-meta_checks.R new file mode 100644 index 0000000..5720e15 --- /dev/null +++ b/tests/testthat/test-meta_checks.R @@ -0,0 +1,14 @@ +test_that("meta_checks()", { + out <- meta_checks(repo = "https://wlandau.r-universe.dev") + expect_true(is.data.frame(out)) + expect_gt(nrow(out), 1L) + fields <- c( + "_status", + "_winbinary", + "_macbinary", + "_wasmbinary", + "_linuxdevel", + "_buildurl" + ) + expect_true(all(fields %in% colnames(out))) +}) diff --git a/tests/testthat/test-meta_packages.R b/tests/testthat/test-meta_packages.R new file mode 100644 index 0000000..712844f --- /dev/null +++ b/tests/testthat/test-meta_packages.R @@ -0,0 +1,11 @@ +test_that("meta_packages()", { + out <- meta_packages(repo = "https://wlandau.r-universe.dev") + expect_true(is.data.frame(out)) + expect_gt(nrow(out), 1L) + fields <- c( + "package", + "version", + "remotesha" + ) + expect_true(all(fields %in% colnames(out))) +}) diff --git a/tests/testthat/test-record_issues.R b/tests/testthat/test-record_issues.R index ad97cd4..ff2db97 100644 --- a/tests/testthat/test-record_issues.R +++ b/tests/testthat/test-record_issues.R @@ -3,8 +3,8 @@ test_that("record_issues() mocked", { record_issues( versions = mock_versions(), mock = list( - checks = mock_checks, - descriptions = mock_descriptions, + checks = mock_meta_checks, + packages = mock_meta_packages, today = "2024-01-01" ), output = output @@ -57,7 +57,7 @@ test_that("record_issues() mocked", { "_buildurl" = file.path(runs, "8998732490") ), descriptions = list( - remotes = matrix(c("hyunjimoon/SBC", "stan-dev/cmdstanr"), nrow = 1) + remotes = c("hyunjimoon/SBC", "stan-dev/cmdstanr") ), date = "2024-01-01" ) @@ -99,8 +99,8 @@ test_that("record_issues() date works", { record_issues( versions = mock_versions(), mock = list( - checks = mock_checks, - descriptions = mock_descriptions, + checks = mock_meta_checks, + packages = mock_meta_packages, today = "2024-01-01" ), output = output @@ -108,8 +108,8 @@ test_that("record_issues() date works", { record_issues( versions = mock_versions(), mock = list( - checks = mock_checks, - descriptions = mock_descriptions + checks = mock_meta_checks, + packages = mock_meta_packages ), output = output ) @@ -136,8 +136,8 @@ test_that("record_issues() date works", { record_issues( versions = mock_versions(), mock = list( - checks = mock_checks, - descriptions = mock_descriptions + checks = mock_meta_checks, + packages = mock_meta_packages ), output = output )