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

Option to build/check package from the git tree #2579

Closed
assaron opened this issue Aug 28, 2024 · 2 comments
Closed

Option to build/check package from the git tree #2579

assaron opened this issue Aug 28, 2024 · 2 comments

Comments

@assaron
Copy link

assaron commented Aug 28, 2024

I find it useful to build/check package using only the changes in the git tree (committed and/or staged). Current build/check functions use all of the files in the package directory. These leads to a number of artifacts, like uncommitted files revealed at remote CI/CD stage, or R CMD build copying a lot of big and unnecessary files (see #2323 or r-lib/pkgbuild#59).

My current approach is to have a separate directory where the repository is checked out and no work is done, but it also not that great for many reasons.

The ideal solution would be a mix of what remotes::install_git and pkgbuild::build does. I'm not sure how to include staged changes, but it's not that necessary, as I can always make a commit and amend it in the process.

@jennybc
Copy link
Member

jennybc commented Aug 29, 2024

You've linked to issues that capture the problem, which comes from base R itself. To summarize that, for some reason base R copies everything and then applies .Rbuildignore, which has lots of downsides. (BTW, you are using .Rbuildignore, yes?)

Have you tried telling pkgbuild::build() about your desired copy strategy?

https://pkgbuild.r-lib.org/reference/build.html#description-entries

This is the feature that closed r-lib/pkgbuild#59 which you link to.

In any case, within the devtools world, anything we might do around this would actually happen in pkgbuild or rcmdcheck. devtools::check() is a user-friendly wrapper around those packages.

@jennybc jennybc closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
@assaron
Copy link
Author

assaron commented Aug 29, 2024

The issues I'm referenced correspond to just one aspect of what I'm talking about. Setting copy strategy to link does resolve problem of copying large files (although only on non-Windows machines).

It does not resolve the problem of uncommitted files being copied as well. It's not uncommon for me to realize I forgot to commit a file only after the CI/CD reports failure, even though I did successfully run the check locally beforehand. Having the build/check to checkout the actual git tree, before running the R CMD build command will make sure that only committed files are used to build the package. It will involve another round of copying files, but supposedly the actual code base is usually pretty small.

Going further, devtools::test() could also benefit from this, to have a mode for the package to be run from temp directory with only committed files.

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

No branches or pull requests

2 participants