Skip to content

Commit

Permalink
r_versions arg
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Aug 22, 2024
1 parent 9e059bc commit 6894fbd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
11 changes: 10 additions & 1 deletion R/propose_snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#' @param types Character vector, what to pass to the `types` field in the
#' snapshot API URL. Controls the types of binaries and documentation
#' included in the snapshot.
#' @param r_versions Character vector of `major.minor` versions of R
#' to download binaries. For example, `r_versions = c("4.4", "4.3")`.
#' Set to `NULL` to let R-universe choose default versions.
#' @examples
#' \dontrun{
#' url_staging = "https://github.com/r-multiverse/staging"
Expand All @@ -36,6 +39,7 @@ propose_snapshot <- function(
path_staging,
repo_staging = "https://staging.r-multiverse.org",
types = c("win", "mac"),
r_versions = NULL,
mock = NULL
) {
issues <- list.files(
Expand All @@ -59,9 +63,14 @@ propose_snapshot <- function(
staging$remotesha <- NULL
file_snapshot <- file.path(path_staging, "snapshot.json")
jsonlite::write_json(staging, file_snapshot, pretty = TRUE)
if (!is.null(r_versions)) {
r_versions <- paste0("&binaries=", paste(r_versions, collapse = ","))
}
url <- paste0(
"https://staging.r-multiverse.org/api/snapshot/zip?types=",
"https://staging.r-multiverse.org/api/snapshot/zip",
"?types=",
paste(types, collapse = ","),
r_versions,
"&packages=",
paste(staging$package, collapse = ",")
)
Expand Down
5 changes: 5 additions & 0 deletions man/propose_snapshot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions tests/testthat/test-propose_snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,23 @@ test_that("propose_snapshot()", {
)
expect_equal(json_snapshot$branch, rep("original", 2L))
expect_equal(ncol(json_snapshot), 3L)
url <- readLines(file.path(path_staging, "snapshot.url"))
expect_equal(
url,
readLines(file.path(path_staging, "snapshot.url")),
paste0(
"https://staging.r-multiverse.org/api/snapshot/zip",
"?types=win,mac&packages=good1,good2"
)
)
propose_snapshot(
path_staging = path_staging,
mock = list(staging = meta_staging),
r_versions = c("4.5", "4.4")
)
expect_equal(
readLines(file.path(path_staging, "snapshot.url")),
paste0(
"https://staging.r-multiverse.org/api/snapshot/zip",
"?types=win,mac&binaries=4.5,4.4&packages=good1,good2"
)
)
})

0 comments on commit 6894fbd

Please sign in to comment.