Skip to content

Commit

Permalink
Change the default CRAN_mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsawriot committed Sep 27, 2023
1 parent 7feb212 commit 98e03b0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ BugReports: https://github.com/chainsawriot/rang/issues
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
withr
Config/testthat/edition: 3
Imports:
parsedate,
Expand Down
2 changes: 1 addition & 1 deletion R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NULL

.query_mirror_validity <- function(mirror) {
if (mirror == "https://cran.r-project.org/") {
if (mirror %in% c("https://cran.r-project.org/", "https://cloud.r-project.org/")) {
return(TRUE)
}
all_mirrors <- utils::getCRANmirrors()$URL
Expand Down
4 changes: 2 additions & 2 deletions R/installation.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
#' }
#' }
export_rang <- function(rang, path, rang_as_comment = TRUE, verbose = TRUE, lib = NA,
cran_mirror = "https://cran.r-project.org/", check_cran_mirror = TRUE,
cran_mirror = getOption("repos", "https://cloud.r-project.org/"), check_cran_mirror = TRUE,
bioc_mirror = "https://bioconductor.org/packages/") {
if (.is_r_version_older_than(rang, "1.3.1")) {
stop("`export_rang` doesn't support this R version (yet).")
Expand Down Expand Up @@ -448,7 +448,7 @@ export_renv <- function(rang, path = ".") {
dockerize <- function(rang, output_dir, materials_dir = NULL, post_installation_steps = NULL,
image = c("r-ver", "rstudio", "tidyverse", "verse", "geospatial"),
rang_as_comment = TRUE, cache = FALSE, verbose = TRUE, lib = NA,
cran_mirror = "https://cran.r-project.org/", check_cran_mirror = TRUE,
cran_mirror = getOption("repos", "https://cloud.r-project.org/"), check_cran_mirror = TRUE,
bioc_mirror = "https://bioconductor.org/packages/",
no_rocker = FALSE,
debian_version = c("lenny", "squeeze", "wheezy", "jessie", "stretch"),
Expand Down
2 changes: 1 addition & 1 deletion man/dockerize.Rd

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

2 changes: 1 addition & 1 deletion man/export_rang.Rd

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

4 changes: 3 additions & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
library(testthat)
library(rang)

test_check("rang")
withr::with_options(new = list(repo = "https://cloud.r-project.org/"), {
test_check("rang")
})
18 changes: 9 additions & 9 deletions tests/testthat/test_dockerize.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ test_that("integration of #16 in dockerize()", {
test_that("integration of #18 in dockerize()", {
rang_ok <- readRDS("../testdata/rang_ok.RDS")
temp_dir <- .generate_temp_dir()
dockerize(rang = rang_ok, output_dir = temp_dir) ## cran_mirror = "https://cran.r-project.org/"
dockerize(rang = rang_ok, output_dir = temp_dir)
x <- readLines(file.path(temp_dir, "rang.R"))
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
dockerize(rang = rang_ok, output_dir = temp_dir, cran_mirror = "cran.r-project.org")
x <- readLines(file.path(temp_dir, "rang.R"))
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
Expand All @@ -81,20 +81,20 @@ test_that("integration of #20 to dockerize()", {
rang_ok <- readRDS("../testdata/rang_ok.RDS")
expect_equal(rang_ok$r_version, "4.2.2")
temp_dir <- .generate_temp_dir()
dockerize(rang_ok, output_dir = temp_dir) ## cran_mirror = "https://cran.r-project.org/"
dockerize(rang_ok, output_dir = temp_dir)
x <- readLines(file.path(temp_dir, "rang.R"))
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
rang_ok <- readRDS("../testdata/rang_ok.RDS")
rang_ok$r_version <- "3.3.0"
dockerize(rang_ok, output_dir = temp_dir) ## cran_mirror = "https://cran.r-project.org/"
dockerize(rang_ok, output_dir = temp_dir)
x <- readLines(file.path(temp_dir, "rang.R"))
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
rang_ok <- readRDS("../testdata/rang_ok.RDS")
rang_ok$r_version <- "3.2.0"
dockerize(rang_ok, output_dir = temp_dir) ## cran_mirror = "https://cran.r-project.org/"
dockerize(rang_ok, output_dir = temp_dir)
x <- readLines(file.path(temp_dir, "rang.R"))
expect_false(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"http://cran\\.r\\-project\\.org/\"", x)))
expect_false(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"http://cloud\\.r\\-project\\.org/\"", x)))
})

test_that("sugars", {
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_expost_rang.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test_that("integration of mirror selection to `export_rang` #18", {
temp_r <- tempfile(fileext = ".R")
export_rang(rang_ok, path = temp_r) ## cran_mirror = "https://cran.r-project.org/"
x <- readLines(temp_r)
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
export_rang(rang_ok, path = temp_r, cran_mirror = "cran.r-project.org")
x <- readLines(temp_r)
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
Expand All @@ -83,20 +83,20 @@ test_that("integration of https to `export_rang` #20", {
temp_r <- tempfile(fileext = ".R")
export_rang(rang_ok, path = temp_r) ## cran_mirror = "https://cran.r-project.org/"
x <- readLines(temp_r)
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
rang_ok <- readRDS("../testdata/rang_ok.RDS")
rang_ok$r_version <- "3.3.0"
temp_r <- tempfile(fileext = ".R")
export_rang(rang_ok, path = temp_r) ## cran_mirror = "https://cran.r-project.org/"
x <- readLines(temp_r)
expect_true(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
rang_ok <- readRDS("../testdata/rang_ok.RDS")
rang_ok$r_version <- "3.2.0"
temp_r <- tempfile(fileext = ".R")
export_rang(rang_ok, path = temp_r) ## cran_mirror = "https://cran.r-project.org/"
x <- readLines(temp_r)
expect_false(any(grepl("^cran.mirror <- \"https://cran\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"http://cran\\.r\\-project\\.org/\"", x)))
expect_false(any(grepl("^cran.mirror <- \"https://cloud\\.r\\-project\\.org/\"", x)))
expect_true(any(grepl("^cran.mirror <- \"http://cloud\\.r\\-project\\.org/\"", x)))
})

test_that("Docker R < 1.3.1", {
Expand Down

0 comments on commit 98e03b0

Please sign in to comment.