From 44919b7c39cc8b516f150ab2d3e54f665ca6ef3f Mon Sep 17 00:00:00 2001 From: vincent guyader Date: Fri, 19 Jul 2024 12:17:49 +0200 Subject: [PATCH] RC 0.2.3 (#74) * Set the minimum version of the {pak} package to 0.6.0. Parameterize the sysreqs_platform used to find system dependencies in pkg_sysreqs * Update NEWS.md * Update DESCRIPTION * update news and README * skip test on r-devel (even on linux...) --- DESCRIPTION | 5 ++--- NEWS.md | 9 +++++--- R/dock_from_renv.R | 9 +++----- README.md | 6 +++--- dev/flat_dock_from_renv.Rmd | 26 +++++++++++++---------- man/dock_from_renv.Rd | 3 +++ tests/testthat/setup_cache_dir.R | 3 +++ tests/testthat/test-dock_from_desc.R | 31 ++++++++++++++++++++++------ tests/testthat/test-dock_from_renv.R | 17 ++++++++++----- tests/testthat/test-dockerbuild.R | 1 + tests/testthat/test-get_sysreqs.R | 1 + 11 files changed, 74 insertions(+), 37 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b06e63b..e43fbe1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dockerfiler Title: Easy Dockerfile Creation from R -Version: 0.2.2.9003 +Version: 0.2.3 Authors@R: c( person("Colin", "Fay", , "contact@colinfay.me", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-7343-1846")), @@ -25,12 +25,11 @@ Imports: glue (>= 1.4.2), jsonlite (>= 1.7.2), memoise, - pak (>= 0.2.0), + pak (>= 0.6.0), pkgbuild (>= 1.2.0), purrr, R6 (>= 2.5.0), remotes (>= 2.2.0), - renv, usethis (>= 2.0.1), utils Suggests: diff --git a/NEWS.md b/NEWS.md index a8bdb64..a8e205a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,11 +1,14 @@ -# 0.2.2.xxxx +# dockerfile 0.2.3 - remove sysreqs.r-hub.io to use {pak} instead for system requirement detection - move from `pak::pkg_system_requirements` to `pak::pkg_sysreqs()` thanks to @B0ydT - `dock_from_renv` allow to specify user to use in Dockerfile - the `dependencies` parameter in `dock_from_renv` if set to `TRUE` will install required dependencies plus optional and development dependencies. defaut is `NA` only required (hard) dependencies, +- Set the minimum version of the {pak} package to 0.6.0. +- Parameterize the `sysreqs_platform` used to find system dependencies in pkg_sysreqs (only debian/ubuntu based images are supported) -# dockerfile 0.2.2 + +# dockerfiler 0.2.2 - fix : create a `use_pak` parameters in `dock_from_renv` to set `renv.config.pak.enabled = FALSE` instead of `renv.config.pak.enabled = TRUE` to avoid issues with {pak} during `renv::restore()` @@ -22,7 +25,7 @@ - feat: Added `renv_version` parameter to `dock_from_renv` to be able to fix the renv version to use during `renv::restore()` (@campbead) -# dockerfile 0.2.0 +# dockerfiler 0.2.0 - fix: graceful failing in case no internet diff --git a/R/dock_from_renv.R b/R/dock_from_renv.R index ac15120..c4e31a2 100644 --- a/R/dock_from_renv.R +++ b/R/dock_from_renv.R @@ -31,6 +31,7 @@ pkg_sysreqs_mem <- memoise::memoise( #' dependencies, #' - `FALSE`: do not install any dependencies. (You might end up with a #' non-working package, and/or the installation might fail.) +#' @param sysreqs_platform System requirements platform.`ubuntu` by default. If `NULL`, then the current platform is used. Can be : "ubuntu-22.04" if needed to fit with the `FROM` Operating System. Only debian or ubuntu based images are supported #' @importFrom utils getFromNamespace #' @return A R6 object of class `Dockerfile`. #' @details @@ -67,6 +68,7 @@ dock_from_renv <- function( use_pak = FALSE, user = NULL, dependencies = NA, + sysreqs_platform = "ubuntu", renv_version ) { try(dockerfiler::renv$initialize(),silent=TRUE) @@ -100,12 +102,7 @@ dock_from_renv <- function( ) - # ici il faut connaire l'image utilisé par l'image. - - - # distro_args <- list(sysreqs_platform = "ubuntu-22.04") - - distro_args <- list(sysreqs_platform = "ubuntu") + distro_args <- list(sysreqs_platform = sysreqs_platform) install_cmd <- "apt-get install -y" update_cmd <-"apt-get update -y" diff --git a/README.md b/README.md index 3d29d14..96a2768 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ You’re reading the doc about version : ``` r desc::desc_get_version() -#> [1] '0.2.2' +#> [1] '0.2.3' ``` The check results are: @@ -26,8 +26,8 @@ The check results are: ``` r devtools::check(quiet = TRUE) #> ℹ Loading dockerfiler -#> ── R CMD check results ────────────────────────────────── dockerfiler 0.2.2 ──── -#> Duration: 1m 0.6s +#> ── R CMD check results ────────────────────────────────── dockerfiler 0.2.3 ──── +#> Duration: 1m 31.3s #> #> 0 errors ✔ | 0 warnings ✔ | 0 notes ✔ ``` diff --git a/dev/flat_dock_from_renv.Rmd b/dev/flat_dock_from_renv.Rmd index 65fc061..19db82b 100644 --- a/dev/flat_dock_from_renv.Rmd +++ b/dev/flat_dock_from_renv.Rmd @@ -75,6 +75,7 @@ pkg_sysreqs_mem <- memoise::memoise( #' dependencies, #' - `FALSE`: do not install any dependencies. (You might end up with a #' non-working package, and/or the installation might fail.) +#' @param sysreqs_platform System requirements platform.`ubuntu` by default. If `NULL`, then the current platform is used. Can be : "ubuntu-22.04" if needed to fit with the `FROM` Operating System. Only debian or ubuntu based images are supported #' @importFrom utils getFromNamespace #' @return A R6 object of class `Dockerfile`. #' @details @@ -106,6 +107,7 @@ dock_from_renv <- function( use_pak = FALSE, user = NULL, dependencies = NA, + sysreqs_platform = "ubuntu", renv_version ) { try(dockerfiler::renv$initialize(),silent=TRUE) @@ -139,12 +141,7 @@ dock_from_renv <- function( ) - # ici il faut connaire l'image utilisé par l'image. - - - # distro_args <- list(sysreqs_platform = "ubuntu-22.04") - - distro_args <- list(sysreqs_platform = "ubuntu") + distro_args <- list(sysreqs_platform = sysreqs_platform) install_cmd <- "apt-get install -y" update_cmd <-"apt-get update -y" @@ -330,10 +327,12 @@ writeLines(renv_file, file.path(dir_build, "renv.lock")) # dock_from_renv ---- test_that("dock_from_renv works", { + + # testthat::skip_on_cran() # skip_if_not(interactive()) # Create Dockerfile - + skip_if(is_rdevel, "skip on R-devel") out <- dock_from_renv( lockfile = the_lockfile, FROM = "rocker/verse", @@ -346,8 +345,7 @@ test_that("dock_from_renv works", { out, "R6" ) - #python3 is not a direct dependencies from custom_packages - expect_false( any(grepl("python3",out$Dockerfile))) + # read Dockerfile out$write( @@ -373,7 +371,10 @@ test_that("dock_from_renv works", { 1 ) - + skip_if(is_rdevel, "Skip R-devel") + #python3 is not a direct dependencies from custom_packages + expect_false( any(grepl("python3",out$Dockerfile))) + # System dependencies are different when build in interactive environment? # yes. strange. skip_if_not(interactive()) @@ -409,7 +410,7 @@ test_that("dock_from_renv works with full dependencies", { # testthat::skip_on_cran() # skip_if_not(interactive()) # Create Dockerfile - +skip_if(is_rdevel, "skip on R-devel") out <- dock_from_renv( dependencies = TRUE, lockfile = the_lockfile, @@ -423,6 +424,7 @@ test_that("dock_from_renv works with full dependencies", { out, "R6" ) + skip_if(is_rdevel, "Skip R-devel") #python3 is a un-direct dependencies from custom_packages expect_true( any(grepl("python3",out$Dockerfile))) }) @@ -468,6 +470,8 @@ test_that("gen_base_image works", { test_that("dock_from_renv works with specific renv", { + + skip_if(is_rdevel, "skip on R-devel") # testthat::skip_on_cran() the_lockfile1.0.0 <- system.file("renv_with_1.0.0.lock",package = "dockerfiler") diff --git a/man/dock_from_renv.Rd b/man/dock_from_renv.Rd index 8692541..b26fa11 100644 --- a/man/dock_from_renv.Rd +++ b/man/dock_from_renv.Rd @@ -16,6 +16,7 @@ dock_from_renv( use_pak = FALSE, user = NULL, dependencies = NA, + sysreqs_platform = "ubuntu", renv_version ) } @@ -53,6 +54,8 @@ dependencies, non-working package, and/or the installation might fail.) }} +\item{sysreqs_platform}{System requirements platform.\code{ubuntu} by default. If \code{NULL}, then the current platform is used. Can be : "ubuntu-22.04" if needed to fit with the \code{FROM} Operating System. Only debian or ubuntu based images are supported} + \item{renv_version}{character. The renv version to use in the generated Dockerfile. By default, it is set to the version specified in the \code{renv.lock} file. If the \code{renv.lock} file does not specify a renv version, the version of renv bundled with dockerfiler, diff --git a/tests/testthat/setup_cache_dir.R b/tests/testthat/setup_cache_dir.R index eaa3871..a9d7ad8 100644 --- a/tests/testthat/setup_cache_dir.R +++ b/tests/testthat/setup_cache_dir.R @@ -1,3 +1,6 @@ R_USER_CACHE_DIR<-tempfile() dir.create(R_USER_CACHE_DIR) Sys.setenv("R_USER_CACHE_DIR"=R_USER_CACHE_DIR) +r_version <- R.Version()$version.string +is_rdevel <- grepl("unstable", r_version) +# is_debian <- grepl("debian", tolower(Sys.info()['release'])) diff --git a/tests/testthat/test-dock_from_desc.R b/tests/testthat/test-dock_from_desc.R index 587fed1..effc6eb 100644 --- a/tests/testthat/test-dock_from_desc.R +++ b/tests/testthat/test-dock_from_desc.R @@ -37,6 +37,9 @@ withr::with_dir( descdir, { test_that("dock_from_desc works", { + + skip_if(is_rdevel, "skip on R-devel") + my_dock <- dock_from_desc(file.path(".", "DESCRIPTION__")) expect_s3_class(my_dock, "R6") @@ -57,12 +60,8 @@ withr::with_dir( tpf ) ) - expect_true( - grepl( - "apt-get update && apt-get install", - tpf - ) - ) + + expect_true( grepl( "mkdir /build_zone", @@ -92,6 +91,26 @@ withr::with_dir( # Only if package I guess # expect_true(file.exists(file.path(descdir, ".Rbuildignore"))) expect_true(file.exists(file.path(descdir, ".dockerignore"))) + + + + + + + + + + skip_if(is_rdevel, "Skippé sous R-devel") + + expect_true( + grepl( + "apt-get update && apt-get install", + tpf + ) + ) + + + }) } ) diff --git a/tests/testthat/test-dock_from_renv.R b/tests/testthat/test-dock_from_renv.R index 4f6d753..42e8cfb 100644 --- a/tests/testthat/test-dock_from_renv.R +++ b/tests/testthat/test-dock_from_renv.R @@ -36,10 +36,12 @@ writeLines(renv_file, file.path(dir_build, "renv.lock")) # dock_from_renv ---- test_that("dock_from_renv works", { + + # testthat::skip_on_cran() # skip_if_not(interactive()) # Create Dockerfile - + skip_if(is_rdevel, "skip on R-devel") out <- dock_from_renv( lockfile = the_lockfile, FROM = "rocker/verse", @@ -52,8 +54,7 @@ test_that("dock_from_renv works", { out, "R6" ) - #python3 is not a direct dependencies from custom_packages - expect_false( any(grepl("python3",out$Dockerfile))) + # read Dockerfile out$write( @@ -79,7 +80,10 @@ test_that("dock_from_renv works", { 1 ) - + skip_if(is_rdevel, "Skip R-devel") + #python3 is not a direct dependencies from custom_packages + expect_false( any(grepl("python3",out$Dockerfile))) + # System dependencies are different when build in interactive environment? # yes. strange. skip_if_not(interactive()) @@ -115,7 +119,7 @@ test_that("dock_from_renv works with full dependencies", { # testthat::skip_on_cran() # skip_if_not(interactive()) # Create Dockerfile - +skip_if(is_rdevel, "skip on R-devel") out <- dock_from_renv( dependencies = TRUE, lockfile = the_lockfile, @@ -129,6 +133,7 @@ test_that("dock_from_renv works with full dependencies", { out, "R6" ) + skip_if(is_rdevel, "Skip R-devel") #python3 is a un-direct dependencies from custom_packages expect_true( any(grepl("python3",out$Dockerfile))) }) @@ -174,6 +179,8 @@ test_that("gen_base_image works", { test_that("dock_from_renv works with specific renv", { + + skip_if(is_rdevel, "skip on R-devel") # testthat::skip_on_cran() the_lockfile1.0.0 <- system.file("renv_with_1.0.0.lock",package = "dockerfiler") diff --git a/tests/testthat/test-dockerbuild.R b/tests/testthat/test-dockerbuild.R index 33a355a..0db2e48 100644 --- a/tests/testthat/test-dockerbuild.R +++ b/tests/testthat/test-dockerbuild.R @@ -1,5 +1,6 @@ n_temp <- tempdir() file.copy("renv.lock", n_temp) +skip_if(is_rdevel, "skip on R-devel") withr::with_dir( n_temp, { diff --git a/tests/testthat/test-get_sysreqs.R b/tests/testthat/test-get_sysreqs.R index f72b3c7..ac7d795 100644 --- a/tests/testthat/test-get_sysreqs.R +++ b/tests/testthat/test-get_sysreqs.R @@ -1,5 +1,6 @@ test_that("get_sysreqs works", { skip_on_cran() + skip_if(is_rdevel, "Skip R-devel") res <- get_sysreqs( c("mongolite"), quiet = TRUE