-
-
Notifications
You must be signed in to change notification settings - Fork 48
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 renv.lock
validation hook
#558
base: main
Are you sure you want to change the base?
Conversation
Interesting. However, I think I'd only want to support this hook if {renv} officially provided a schema. Did you talk to Kevin about it or open an issue for it? |
Also, please note that before submitting new PRs, discussion in an issue is encouraged as per our |
Ah, apologies, embarrassing that I missed that. Looks like this is the current state of what the {renv} maintainers think about having a schema:
I can open an issue to see if there's any interest. If not, I/you can close this PR. |
Yes, please open one and see what happens. I would like to offload the task of updating the schema upstream as well as how to deal with an evolving schema. These are core {renv} functionalities. As a strategy of last resort, you can also implement this hook in your own hook repo instead of here. It’s not too much work. |
My |
Glad to hear that you got this merged upstream. |
Working on this now! |
de4c267
to
bf64c5e
Compare
for more information, see https://pre-commit.ci
@lorenzwalthert I think I've got this figured out. Happy to take suggestions for improvements! 🚀 |
<!-- --> | ||
|
||
id: renv-lockfile-validate | ||
args: [--schema=<schema>] [--greedy --error --verbose --strict] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please link (with hyper-text-link) to docs for env::lockfile_validate()
since you just pass arguments there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's wait for rstudio/renv#2048?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
id: renv-lockfile-validate | ||
args: [--error] | ||
|
||
This hook does not modify files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add the version of {precommit} this hook was added to (similar to other hooks)?
for more information, see https://pre-commit.ci
As discussed in conversations above, I'll wait till the renv docs issue is resolved before bumping the precommit dev version and making the recommended updates the docs. I pushed some changes that should resolve most, maybe all, of the GHA tests. |
Any interest in adding a hook like this?
When used correctly, you should never really have to worry that your
renv.lock
file does not fit the schema. But in practice, especially with collaborators, you may want an extra check that no one has accidentally edited fields as this can cause difficult to diagnose errors. Never hurts to have an automated check!{renv} doesn't actually provide a schema, but I believe I've provided one that fits it. It may need to go into its own file instead of being a string, but I couldn't get the tests to pass when I had it in
inst/
.