-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f3f16a
commit bf64c5e
Showing
8 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ Suggests: | |
docopt (>= 0.7.1), | ||
git2r, | ||
glue, | ||
jsonvalidate, | ||
knitr, | ||
lintr, | ||
pkgload, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
"Validate renv lockfiles | ||
See `?renv::lockfile_validate()`. | ||
Usage: | ||
lockfile_validate [--schema=<schema>] [--greedy --error --verbose --strict] <files>... | ||
Options: | ||
--schema Path. Path to a custom schema. | ||
--greedy Continue after first error? | ||
--error Throw an error on parse failure? | ||
--verbose If `TRUE`, then an attribute `errors` will list validation failures as a `data.frame`. | ||
--strict Set whether the schema should be parsed strictly or not. | ||
" -> doc | ||
|
||
if (!require(renv, quietly = TRUE)) { | ||
stop("{renv} could not be loaded, please install it.") | ||
} | ||
if (packageVersion("renv") < package_version("1.0.8")) { | ||
rlang::abort("You need at least version 1.0.8 of {renv} to run this hook.") | ||
} | ||
if (!require(jsonvalidate, quietly = TRUE)) { | ||
stop("{jsonvalidate} could not be loaded, please install it.") | ||
} | ||
|
||
arguments <- precommit::precommit_docopt(doc) | ||
arguments$files <- normalizePath(arguments$files) | ||
if (!is.null(arguments$schema)) { | ||
arguments$schema <- normalizePath(arguments$schema) | ||
} | ||
|
||
renv::lockfile_validate( | ||
lockfile = arguments$files, | ||
schema = arguments$schema, | ||
greedy = arguments$greedy, | ||
error = arguments$error, | ||
verbose = arguments$verbose, | ||
strict = arguments$strict | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"R": { | ||
"Version": "4.2.3", | ||
"Repositories": [ | ||
{ | ||
"Name": "CRAN", | ||
"URL": "https://cloud.r-project.org" | ||
} | ||
] | ||
}, | ||
"Packages": { | ||
"markdown": { | ||
"Package": "markdown", | ||
"Version": "1.0", | ||
"Source": "Repository", | ||
"Repository": "CRAN", | ||
"Hash": "2324" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"R": { | ||
"Version": "4.2.3", | ||
"Repositories": [ | ||
{ | ||
"Name": "CRAN", | ||
"URL": "https://cloud.r-project.org" | ||
} | ||
] | ||
}, | ||
"Packages": { | ||
"markdown": { | ||
"Package": "markdown", | ||
"Version": "1.0", | ||
"Source": "Repository", | ||
"Repository": "CRAN" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# success | ||
run_test("renv-lockfile-validate", | ||
file_name = "renv-success", | ||
suffix = ".lock", cmd_args = c("--error"), | ||
std_err = NULL | ||
) | ||
# fail | ||
run_test("renv-lockfile-validate", | ||
file_name = "renv-fail", | ||
suffix = ".lock", cmd_args = c("--error"), | ||
std_err = "error validating json" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters