Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for renv lockfiles (#55) #80

Merged
merged 9 commits into from
Feb 26, 2023
Merged

add support for renv lockfiles (#55) #80

merged 9 commits into from
Feb 26, 2023

Conversation

schochastics
Copy link
Member

still WIP

This was referenced Feb 24, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 24, 2023

Codecov Report

Merging #80 (207521b) into v0.2 (6c256ea) will increase coverage by 0.71%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             v0.2      #80      +/-   ##
==========================================
+ Coverage   95.94%   96.65%   +0.71%     
==========================================
  Files           6        6              
  Lines         690      718      +28     
==========================================
+ Hits          662      694      +32     
+ Misses         28       24       -4     
Impacted Files Coverage Δ
R/resolve.R 96.20% <ø> (+1.01%) ⬆️
R/as_pkgrefs.R 100.00% <100.00%> (+10.00%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@schochastics schochastics changed the title added as_pkgrefs.renv_lockfile (#55) add support for renv lockfiles (#55) Feb 26, 2023
@schochastics
Copy link
Member Author

@chainsawriot can I get you opinion on the current implementation? Do you think this makes sense and is it in line with how you envision as_pkgrefs?

@chainsawriot
Copy link
Collaborator

@schochastics Thanks! Several suggestions in the review.

@schochastics
Copy link
Member Author

@chainsawriot can you link your comments? I cant find suggestions anywhere

@chainsawriot
Copy link
Collaborator

chainsawriot commented Feb 26, 2023

@schochastics Can you see them in this view?

https://github.com/chainsawriot/rang/pull/80/files/0448b1fe9976267ec8ef782cc95b29878f7bbeb2

I just found that I need to submit my comments. Sorry for that.

.extract_pkgref_renv_lockfile <- function(path){
lockfile <- .parse_renv_lockfile(path)
sources <- vapply(lockfile[["Packages"]],`[[`,character(1),"Source",USE.NAMES = FALSE)
pkgs <- c()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit better to name this pkgrefs

R/as_pkgrefs.R Outdated
if(isFALSE(file.exists(path))){
return(FALSE)
}
if(grepl("renv.lock$",path)){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (isFALSE(grepl("renv.lock$", path))) {
    return(FALSE)
}
TRUE

Copy link
Collaborator

@chainsawriot chainsawriot Feb 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A slightly more robust method is basename(path) == "renv.lock"

It prevent the matching of hello_1231212renv.lock

@@ -91,3 +91,8 @@ test_that("as_pkgrefs_packageDescription", {
## expect_equal(res, c("github::chainsawriot/grafzahl", "cran::rtoot", "local::/home/chainsawriot/dev/rang", "cran::testthat")
expect_equal(res, c("github::chainsawriot/grafzahl", "cran::rtoot", "cran::rang", "cran::testthat"))
})

test_that("as_pkgrefs renv_lockfile", {
res <- as_pkgrefs("../testdata/renv.lock")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one more test

expect_false(.detect_renv_lockfile("./testdata/graph.RDS"))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect_false(.detect_renv_lockfile(c("./testdata/graph.RDS", "../testdata/renv.lock")))

Should this be false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least from the logic I am using. Which is that a renv lockfile occurs as a the only imput. Should we accept vector input for renv lock files, i.e. mixing types?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schochastics I actually agree that this should be FALSE. A vector of lock files is too arcane a situation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jep thats what I thought

@@ -212,7 +212,7 @@
#'
#' This function recursively queries dependencies of R packages at a specific snapshot time. The dependency graph can then be used to recreate the computational environment. The data on dependencies are provided by R-hub.
#'
#' @param pkgs `pkgs` can be 1) a character vector of R packages to resolve, or 2) a data structure that [as_pkgrefs()] can convert to a character vector of package references. For 1) `pkgs` can be either in shorthands, e.g. "rtoot", "ropensci/readODS", or in package references, e.g. "cran::rtoot", "github::ropensci/readODS". Please refer to the [Package References documentation](https://r-lib.github.io/pkgdepends/reference/pkg_refs.html) of `pak` for details. Currently, this package supports only cran and github packages. For 2) [as_pkgrefs()] support the output of [sessionInfo()].
#' @param pkgs `pkgs` can be 1) a character vector of R packages to resolve, 2) a path to a [`renv` lockfile](https://rstudio.github.io/renv/articles/lockfile.html), or 3) a data structure that [as_pkgrefs()] can convert to a character vector of package references. For 1) `pkgs` can be either in shorthands, e.g. "rtoot", "ropensci/readODS", or in package references, e.g. "cran::rtoot", "github::ropensci/readODS". Please refer to the [Package References documentation](https://r-lib.github.io/pkgdepends/reference/pkg_refs.html) of `pak` for details. Currently, this package supports only cran and github packages. For 2) [as_pkgrefs()] support the output of [sessionInfo()].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to add an integration test to test_resolve.R

testthat("integration of renv to resolve", {
    expect_error(X <- resolve("../testdata/renv.lock", snapshot_date = "2023-01-01"), NA)
    ### more things
})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chainsawriot should I move all tests there or do a new set of tests?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this test. In general, the last part of test_resolve.R is for all tests that require internet.

@schochastics schochastics marked this pull request as ready for review February 26, 2023 15:14
@schochastics
Copy link
Member Author

@chainsawriot I think I incorporated everything now

@chainsawriot chainsawriot merged commit 3d1b46e into gesistsa:v0.2 Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants