From 8174510590ef9d19df72813f6633e815f2f67f00 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 8 Mar 2021 13:26:23 +0100 Subject: [PATCH 01/75] add renv.lock only --- .Rbuildignore | 1 + renv.lock | 658 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 659 insertions(+) create mode 100644 renv.lock diff --git a/.Rbuildignore b/.Rbuildignore index f8befe49f..d2f4a8df6 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ +^renv\.lock$ ^README\.Rmd$ ^.*\.Rproj$ ^\.Rproj\.user$ diff --git a/renv.lock b/renv.lock new file mode 100644 index 000000000..63c46d406 --- /dev/null +++ b/renv.lock @@ -0,0 +1,658 @@ +{ + "R": { + "Version": "4.0.3", + "Repositories": [ + { + "Name": "CRAN", + "URL": "https://cran.rstudio.com" + } + ] + }, + "Packages": { + "Matrix": { + "Package": "Matrix", + "Version": "1.3-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ff280503079ad8623d3c4b1519b24ea2" + }, + "R.cache": { + "Package": "R.cache", + "Version": "0.14.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1ca02d43e1a4d49e616bd23bb39b17e6" + }, + "R.methodsS3": { + "Package": "R.methodsS3", + "Version": "1.8.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4bf6453323755202d5909697b6f7c109" + }, + "R.oo": { + "Package": "R.oo", + "Version": "1.24.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5709328352717e2f0a9c012be8a97554" + }, + "R.utils": { + "Package": "R.utils", + "Version": "2.10.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a9e316277ff12a43997266f2f6567780" + }, + "R6": { + "Package": "R6", + "Version": "2.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b203113193e70978a696b2809525649d" + }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "dbb5e436998a7eba5a9d682060533338" + }, + "askpass": { + "Package": "askpass", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e8a22846fff485f0be3770c2da758713" + }, + "assertthat": { + "Package": "assertthat", + "Version": "0.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "50c838a310445e954bc13f26f26a6ecf" + }, + "backports": { + "Package": "backports", + "Version": "1.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "644043219fc24e190c2f620c1a380a69" + }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, + "brew": { + "Package": "brew", + "Version": "1.0-6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "92a5f887f9ae3035ac7afde22ba73ee9" + }, + "brio": { + "Package": "brio", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "36758510e65a457efeefa50e1e7f0576" + }, + "callr": { + "Package": "callr", + "Version": "3.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b7d7f1e926dfcd57c74ce93f5c048e80" + }, + "cli": { + "Package": "cli", + "Version": "2.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "26fb4f0871c8e5b84d77f6dc22f2ee0a" + }, + "clipr": { + "Package": "clipr", + "Version": "0.7.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaa97ac99cc2daf04e77eecc7b781d7" + }, + "codetools": { + "Package": "codetools", + "Version": "0.2-18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "019388fc48e48b3da0d3a76ff94608a8" + }, + "commonmark": { + "Package": "commonmark", + "Version": "1.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0f22be39ec1d141fd03683c06f3a6e67" + }, + "crayon": { + "Package": "crayon", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e75525c55c70e5f4f78c9960a4b402e9" + }, + "credentials": { + "Package": "credentials", + "Version": "1.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a96728288c75a814c900af9da84387be" + }, + "curl": { + "Package": "curl", + "Version": "4.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2b7d10581cc730804e9ed178c8374bd6" + }, + "cyclocomp": { + "Package": "cyclocomp", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "53cbed70a2f7472d48fb6aef08442f25" + }, + "desc": { + "Package": "desc", + "Version": "1.2.0.9000", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "desc", + "RemoteUsername": "r-lib", + "RemoteRef": "HEAD", + "RemoteSha": "b4e84816666dd788be4cc8eb886dc2f44358b41d", + "Hash": "304bb37b58052aa55306466167b84b09" + }, + "diffobj": { + "Package": "diffobj", + "Version": "0.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "55fae7ec1418d2a47bd552571673d1af" + }, + "digest": { + "Package": "digest", + "Version": "0.6.27", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a0cbe758a531d054b537d16dff4d58a1" + }, + "docopt": { + "Package": "docopt", + "Version": "0.7.1", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "docopt.R", + "RemoteUsername": "docopt", + "RemoteRef": "HEAD", + "RemoteSha": "b9f031ee6bf8c0add1548ea64360791d9dcb05c0", + "Hash": "9975c22e69171d62dcd9ce4454b848d4" + }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fd2844b3a43ae2d27e70ece2df1b4e2a" + }, + "evaluate": { + "Package": "evaluate", + "Version": "0.14", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ec8ca05cffcc70569eaaad8469d2a3a7" + }, + "fansi": { + "Package": "fansi", + "Version": "0.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fea074fb67fe4c25d47ad09087da847d" + }, + "fs": { + "Package": "fs", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "44594a07a42e5f91fac9f93fda6d0109" + }, + "gert": { + "Package": "gert", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "dcbfac00cf60125f43791a135ef68285" + }, + "gh": { + "Package": "gh", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "05129b4387282404780d2f8593636388" + }, + "git2r": { + "Package": "git2r", + "Version": "0.28.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f64fd34026f6025de71a4354800e6d79" + }, + "gitcreds": { + "Package": "gitcreds", + "Version": "0.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f3aefccc1cc50de6338146b62f115de8" + }, + "glue": { + "Package": "glue", + "Version": "1.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6efd734b14c6471cfe443345f3e35e29" + }, + "here": { + "Package": "here", + "Version": "1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "24b224366f9c2e7534d2344d10d59211" + }, + "highr": { + "Package": "highr", + "Version": "0.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4dc5bb88961e347a0f4d8aad597cbfac" + }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "af2c2531e55df5cf230c4b5444fc973c" + }, + "httr": { + "Package": "httr", + "Version": "1.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a525aba14184fec243f9eaec62fbed43" + }, + "hunspell": { + "Package": "hunspell", + "Version": "3.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3987784c19192ad0f2261c456d936df1" + }, + "ini": { + "Package": "ini", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6154ec2223172bce8162d4153cda21f7" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "1.7.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "98138e0994d41508c7a6b84a0600cfcb" + }, + "knitr": { + "Package": "knitr", + "Version": "1.31", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c3994c036d19fc22c5e2a209c8298bfb" + }, + "lattice": { + "Package": "lattice", + "Version": "0.20-41", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd9285028b0263d76d18c95ae51a53d" + }, + "lazyeval": { + "Package": "lazyeval", + "Version": "0.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d908914ae53b04d4c0c0fd72ecc35370" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3471fb65971f1a7b2d4ae7848cf2db8d" + }, + "lintr": { + "Package": "lintr", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "023cecbdc0a32f86ad3cb1734c018d2e" + }, + "magrittr": { + "Package": "magrittr", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "41287f1ac7d28a92f0a286ed507928d3" + }, + "markdown": { + "Package": "markdown", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "61e4a10781dd00d7d81dd06ca9b94e95" + }, + "mime": { + "Package": "mime", + "Version": "0.10", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "26fa77e707223e1ce042b2b5d09993dc" + }, + "openssl": { + "Package": "openssl", + "Version": "1.4.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a399e4773075fc2375b71f45fca186c4" + }, + "pillar": { + "Package": "pillar", + "Version": "1.4.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3b3dd89b2ee115a8b54e93a34cd546b4" + }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "725fcc30222d4d11ec68efb8ff11a9af" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "01f28d4278f15c76cddbea05899c5d6f" + }, + "pkgload": { + "Package": "pkgload", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b6b150cd4709e0c0c9b5d51ac4376282" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a555924add98c99d2f411e37e7d25e9f" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" + }, + "processx": { + "Package": "processx", + "Version": "3.4.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "22aab6098cb14edd0a5973a8438b569b" + }, + "ps": { + "Package": "ps", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaed51a03411fd5cfc1e12d9079b353" + }, + "purrr": { + "Package": "purrr", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "97def703420c8ab10d8f0e6c72101e02" + }, + "rappdirs": { + "Package": "rappdirs", + "Version": "0.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5e3c5dc0b071b21fa128676560dbe94d" + }, + "rematch2": { + "Package": "rematch2", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "76c9e04c712a05848ae7a23d2f170a40" + }, + "remotes": { + "Package": "remotes", + "Version": "2.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "430a0908aee75b1fcba0e62857cab0ce" + }, + "renv": { + "Package": "renv", + "Version": "0.12.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5c0cdb37f063c58cdab3c7e9fbb8bd2c" + }, + "reticulate": { + "Package": "reticulate", + "Version": "1.18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd35cac6ae7554d0e4f440bca1adf3a" + }, + "rex": { + "Package": "rex", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "093584b944440c5cd07a696b3c8e0e4c" + }, + "rlang": { + "Package": "rlang", + "Version": "0.4.10", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "599df23c40a4fce9c7b4764f28c37857" + }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "edbf4cb1aefae783fd8d3a008ae51943" + }, + "roxygen2": { + "Package": "roxygen2", + "Version": "7.1.1.9001", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "roxygen2", + "RemoteUsername": "r-lib", + "RemoteRef": "HEAD", + "RemoteSha": "6c1e42f061e9435a14bd3a0e01c7f08fc7aa9160", + "Hash": "ab1efef67b07177d14c8100ce43c75d6" + }, + "rprojroot": { + "Package": "rprojroot", + "Version": "2.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "249d8cd1e74a8f6a26194a91b47f21d1" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.13", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "06c85365a03fdaf699966cc1d3cf53ea" + }, + "spelling": { + "Package": "spelling", + "Version": "2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b8c899a5c83f0d897286550481c91798" + }, + "stringi": { + "Package": "stringi", + "Version": "1.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a063ebea753c92910a4cca7b18bc1f05" + }, + "stringr": { + "Package": "stringr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0759e6b6c0957edb1311028a49a35e76" + }, + "styler": { + "Package": "styler", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "60b23effde8d08a56a64ebeb92a32749" + }, + "sys": { + "Package": "sys", + "Version": "3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b227d13e29222b4574486cfcbde077fa" + }, + "testthat": { + "Package": "testthat", + "Version": "3.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "495e0434d9305716b6a87031570ce109" + }, + "tibble": { + "Package": "tibble", + "Version": "3.0.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9c6c10e594f32096ede0c7d373ccbddd" + }, + "tinytex": { + "Package": "tinytex", + "Version": "0.29", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f0b0ba735febac9a8344253ae6fa93f5" + }, + "usethis": { + "Package": "usethis", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "360e904f9e623286e1a0c6ca0a98c5f6" + }, + "utf8": { + "Package": "utf8", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4a5081acfb7b81a572e4384a7aaf2af1" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.3.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5cf1957f93076c19fdc81d01409d240b" + }, + "waldo": { + "Package": "waldo", + "Version": "0.2.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "29df52c781e572c967f90de9713423c4" + }, + "whisker": { + "Package": "whisker", + "Version": "0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ca970b96d894e90397ed20637a0c1bbe" + }, + "withr": { + "Package": "withr", + "Version": "2.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "caf4781c674ffa549a4676d2d77b13cc" + }, + "xfun": { + "Package": "xfun", + "Version": "0.21", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f3ddcca198959a42e8cb6b06c30d4f1e" + }, + "xml2": { + "Package": "xml2", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d4d71a75dd3ea9eb5fa28cc21f9585e2" + }, + "xmlparsedata": { + "Package": "xmlparsedata", + "Version": "1.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "373bcee7aad3980799936749cfca6f24" + }, + "yaml": { + "Package": "yaml", + "Version": "2.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2826c5d9efb0a88f657c7a679c7106db" + }, + "zip": { + "Package": "zip", + "Version": "2.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3bc8405c637d988801ec5ea88372d0c2" + } + } +} From 508aa390feb9cc7d2d84b50b03ae910aab184113 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 8 Mar 2021 13:42:49 +0100 Subject: [PATCH 02/75] Explicitly make this a package --- DESCRIPTION | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c50e0bcfa..509f2eadb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,14 @@ +Type: Package Package: precommit Title: Pre-Commit Hooks Version: 0.1.3.9000 Author: Lorenz Walthert Maintainer: Lorenz Walthert -Description: Useful git hooks for R building on top of the - multi-language framework 'pre-commit' for hook management. This - package provides git hooks for common tasks like formatting files with - 'styler' or spell checking as well as wrapper functions to access the - 'pre-commit' executable. +Description: Useful git hooks for R building on top of the multi-language + framework 'pre-commit' for hook management. This package provides git + hooks for common tasks like formatting files with 'styler' or spell + checking as well as wrapper functions to access the 'pre-commit' + executable. License: GPL-3 URL: https://lorenzwalthert.github.io/precommit/, https://github.com/lorenzwalthert/precommit @@ -41,8 +42,8 @@ VignetteBuilder: Remotes: r-lib/styler Encoding: UTF-8 -Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", - "collate", if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" - else { warning("Please install r-lib/pkgapi to make sure the file API - is kept up to date"); NULL} ) ) +Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate", + if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else { + warning("Please install r-lib/pkgapi to make sure the file API is kept + up to date"); NULL} ) ) RoxygenNote: 7.1.1 From 7eee4379418928f2b9a593ce1ab92b955bc98208 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 8 Mar 2021 13:50:16 +0100 Subject: [PATCH 03/75] bump for hash From 9d05c3baf6f4fb16e5ee7b4b7e9b5cb71e6513e4 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 8 Mar 2021 15:36:50 +0100 Subject: [PATCH 04/75] bump for testing From ca3282f28c67224be46b5cb04d8c7c8f7ac2b4ae Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 8 Mar 2021 16:46:46 +0100 Subject: [PATCH 05/75] bump for test From 3b51d375c806bb4e70e6e37aeba8df88dc277337 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 9 Mar 2021 12:59:52 +0100 Subject: [PATCH 06/75] bump From 1c75f350b96819135595f61339e5c99950d6ec1d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 16 Mar 2021 17:20:34 +0100 Subject: [PATCH 07/75] add activate script by default --- renv/.gitignore | 4 + renv/activate.R | 431 ++++++++++++++++++++++++++++++++++++++++++++++ renv/settings.dcf | 7 + 3 files changed, 442 insertions(+) create mode 100644 renv/.gitignore create mode 100644 renv/activate.R create mode 100644 renv/settings.dcf diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 000000000..62e60ad4a --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,4 @@ +library/ +lock/ +python/ +staging/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 000000000..36b5038ca --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,431 @@ + +local({ + + # the requested version of renv + version <- "0.12.5" + + # the project directory + project <- getwd() + + # avoid recursion + if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) { + return(invisible(TRUE)) + } + + # signal that we're loading renv during R startup + Sys.setenv("RENV_R_INITIALIZING" = "true") + on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # check to see if renv has already been loaded + if ("renv" %in% loadedNamespaces()) { + + # if renv has already been loaded, and it's the requested version of renv, + # nothing to do + spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") + if (identical(spec[["version"]], version)) { + return(invisible(TRUE)) + } + + # otherwise, unload and attempt to load the correct version of renv + unloadNamespace("renv") + } + + # load bootstrap tools + bootstrap <- function(version, library) { + + # attempt to download renv + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) { + stop("failed to download renv ", version) + } + + # now attempt to install + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) { + stop("failed to install renv ", version) + } + } + + renv_bootstrap_tests_running <- function() { + getOption("renv.tests.running", default = FALSE) + } + + renv_bootstrap_repos <- function() { + + # check for repos override + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (!is.na(repos)) { + return(repos) + } + + # if we're testing, re-use the test repositories + if (renv_bootstrap_tests_running()) { + return(getOption("renv.tests.repos")) + } + + # retrieve current repos + repos <- getOption("repos") + + # ensure @CRAN@ entries are resolved + repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" + + # add in renv.bootstrap.repos if set + default <- c(CRAN = "https://cloud.r-project.org") + extra <- getOption("renv.bootstrap.repos", default = default) + repos <- c(repos, extra) + + # remove duplicates that might've snuck in + dupes <- duplicated(repos) | duplicated(names(repos)) + repos[!dupes] + } + + renv_bootstrap_download <- function(version) { + + # if the renv version number has 4 components, assume it must + # be retrieved via github + nv <- numeric_version(version) + components <- unclass(nv)[[1]] + + methods <- if (length(components) == 4L) { + list( + renv_bootstrap_download_github + ) + } else { + list( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive + ) + } + + for (method in methods) { + path <- tryCatch(method(version), error = identity) + if (is.character(path) && file.exists(path)) { + return(path) + } + } + + stop("failed to download renv ", version) + } + + renv_bootstrap_download_impl <- function(url, destfile) { + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) { + mode <- "w+b" + } + + utils::download.file( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + } + + renv_bootstrap_download_cran_latest <- function(version) { + repos <- renv_bootstrap_download_cran_latest_find(version) + + message("* Downloading renv ", version, " from CRAN ... ", appendLF = FALSE) + + info <- tryCatch( + utils::download.packages( + pkgs = "renv", + repos = repos, + destdir = tempdir(), + quiet = TRUE + ), + condition = identity + ) + + if (inherits(info, "condition")) { + message("FAILED") + return(FALSE) + } + + message("OK") + info[1, 2] + } + + renv_bootstrap_download_cran_latest_find <- function(version) { + all <- renv_bootstrap_repos() + + for (repos in all) { + db <- tryCatch( + as.data.frame( + x = utils::available.packages(repos = repos), + stringsAsFactors = FALSE + ), + error = identity + ) + + if (inherits(db, "error")) { + next + } + + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) { + next + } + + return(repos) + } + + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + } + + renv_bootstrap_download_cran_archive <- function(version) { + name <- sprintf("renv_%s.tar.gz", version) + repos <- renv_bootstrap_repos() + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + message("* Downloading renv ", version, " from CRAN archive ... ", appendLF = FALSE) + + for (url in urls) { + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) { + message("OK") + return(destfile) + } + } + + message("FAILED") + return(FALSE) + } + + renv_bootstrap_download_github <- function(version) { + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) { + return(FALSE) + } + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) { + message("FAILED") + return(FALSE) + } + + message("OK") + return(destfile) + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) + dir.create(library, showWarnings = FALSE, recursive = TRUE) + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + r <- file.path(bin, exe) + args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status + } + + renv_bootstrap_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) { + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + } + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- Sys.getenv("RENV_PATHS_PREFIX") + if (nzchar(prefix)) { + components <- c(prefix, components) + } + + # build prefix + paste(components, collapse = "/") + } + + renv_bootstrap_library_root_name <- function(project) { + + # use project name as-is if requested + asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") + if (asis) { + return(basename(project)) + } + + # otherwise, disambiguate based on project's path + id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) + paste(basename(project), id, sep = "-") + } + + renv_bootstrap_library_root <- function(project) { + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) { + return(path) + } + + path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(path)) { + name <- renv_bootstrap_library_root_name(project) + return(file.path(path, name)) + } + + file.path(project, "renv/library") + } + + renv_bootstrap_validate_version <- function(version) { + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) { + return(TRUE) + } + + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) { + paste("rstudio/renv", loadedversion, sep = "@") + } else { + paste("renv", loadedversion, sep = "@") + } + + fmt <- paste( + "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", + "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + sep = "\n" + ) + + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) + + FALSE + } + + renv_bootstrap_hash_text <- function(text) { + hashfile <- tempfile("renv-hash-") + on.exit(unlink(hashfile), add = TRUE) + + writeLines(text, con = hashfile) + tools::md5sum(hashfile) + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + return(FALSE) + } + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # load the project + renv::load(project) + + TRUE + } + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # attempt to load + if (renv_bootstrap_load(project, libpath, version)) { + return(TRUE) + } + + # load failed; inform user we're about to bootstrap + prefix <- paste("# Bootstrapping renv", version) + postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") + header <- paste(prefix, postfix) + message(header) + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) { + return(TRUE) + } + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("* Successfully installed and loaded renv ", version, ".") + return(renv::load()) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) +}) diff --git a/renv/settings.dcf b/renv/settings.dcf new file mode 100644 index 000000000..175521fb7 --- /dev/null +++ b/renv/settings.dcf @@ -0,0 +1,7 @@ +external.libraries: +ignored.packages: +package.dependency.fields: Imports, Depends, LinkingTo +r.version: +snapshot.type: explicit +use.cache: TRUE +vcs.ignore.library: TRUE From d4f9d09144cad6244f95084c0bfbafea8e582b5f Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 16 Mar 2021 23:55:27 +0100 Subject: [PATCH 08/75] adapt docs to virtualenv support --- NEWS.md | 6 ++ README.Rmd | 102 ++++++++++++++-------------------- README.md | 67 +++++++--------------- vignettes/FAQ.Rmd | 41 ++++++-------- vignettes/available-hooks.Rmd | 12 ++-- 5 files changed, 93 insertions(+), 135 deletions(-) diff --git a/NEWS.md b/NEWS.md index fa8dbf763..6375a8235 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,12 @@ `{R.cache}` cache set up. You can silence the warning with the hook argument `--no-warn-cache` (#225). +**Major Changes** + +- {precommit} now uses [`language: r`](https://pre-commit.com/#r) instead of + `language: script` from the [pre-commit framework](https://pre-commit.com). + This requires `pre-commit >= 2.11.1`. All hooks and dependencies are now + contained in a virtual environment with [`{renv}`](https://rstudio.github.io/renv/). **Minor changes** diff --git a/README.Rmd b/README.Rmd index 63fa0a472..69e5c28d4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,8 @@ knitr::opts_chunk$set( status](https://www.r-pkg.org/badges/version/precommit)](https://CRAN.R-project.org/package=precommit) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) -[![R build status](https://github.com/lorenzwalthert/precommit/workflows/R-CMD-check/badge.svg)](https://github.com/lorenzwalthert/precommit/actions) +[![R build +status](https://github.com/lorenzwalthert/precommit/workflows/R-CMD-check/badge.svg)](https://github.com/lorenzwalthert/precommit/actions) [Pre-commit hooks](https://pre-commit.com) are tests that run each time you @@ -29,7 +30,8 @@ forgotten a comma, brace or quote. The goal of this package is to twofold: -- Provide a [set of hooks](https://lorenzwalthert.github.io/precommit/articles/available-hooks.html) +- Provide a [set of + hooks](https://lorenzwalthert.github.io/precommit/articles/available-hooks.html) that are useful when your git repo contains R code. - Provide [usethis](https://github.com/r-lib/usethis)-like functionality for @@ -39,7 +41,14 @@ The following online docs are available: - [latest CRAN release](https://lorenzwalthert.github.io/precommit/). -- [GitHub development version](https://lorenzwalthert.github.io/precommit/dev/). +- [GitHub development + version](https://lorenzwalthert.github.io/precommit/dev/). + +These only cover the functionality added on top of the pre-commit framework by +this package. Everything else is covered in the extensive [online +documentation](https://pre-commit.com) of the pre-commit framework itself, +including how to create hooks for actions like `git push` or `git checkout`, +create local hooks etc. ## Installation @@ -50,21 +59,22 @@ install.packages("precommit") ``` To access pre-commit functionality from R, you also need to install the -[pre-commit framework](https://pre-commit.com). The following command line methods are tested to work with -this R package (and accessing them from outside R is easier and use is slightly faster): +[pre-commit framework](https://pre-commit.com) on which the hook from this repo +build. The following command line methods are tested to work with this R package +(and accessing them from outside R is easier and use is slightly faster): -- `$ pip3 install pre-commit --user` (macOS, Linux and Windows) **outside** a +- `$ pip3 install pre-commit --user` (macOS, Linux and Windows) **outside** a conda or virtual environment. - `$ brew install pre-commit` (macOS). -Alternatively, you can handle the installation from R using +Alternatively, you can handle the installation from R using [miniconda](https://docs.conda.io/en/latest/miniconda.html): -- install miniconda if you don't have it already: `reticulate::install_miniconda()`. - This needs reticulate >= 1.14. +- install miniconda if you don't have it already: + `reticulate::install_miniconda()`. This needs reticulate >= 1.14. -- install the pre-commit framework with `precommit::install_precommit()` into +- install the pre-commit framework with `precommit::install_precommit()` into the conda environment `r-precommit`. Do not install other packages into this environment. @@ -92,14 +102,14 @@ function `precommit::open_config()` let's you open and edit the `.pre-commit-config.yaml` conveniently from the RStudio console. When any file is changed due to running a hook or the hook script errors, the commit will fail. You can inspect the changes introduced by the hook and if satisfied, you -can add the changes made by the hook to the index with `git add path/to/file` -and attempt to commit again. Some hooks change files, like the styler hook, so -all you need to do to make the hook pass is `git add` the changes -introduced by the hook. Other hooks, like the parsable-R hook, will need -your action, e.g. add a missing closing brace to a call like `library(styler`, -before they pass at the next attempt. If all hooks pass, the commit is made. You -can also [temporarily disable hooks](https://pre-commit.com/#temporarily-disabling-hooks). -If you succeed, it should look like this: +can add the changes made by the hook to the index with `git add path/to/file` +and attempt to commit again. Some hooks change files, like the styler hook, so +all you need to do to make the hook pass is `git add` the changes introduced by +the hook. Other hooks, like the parsable-R hook, will need your action, e.g. add +a missing closing brace to a call like `library(styler`, before they pass at the +next attempt. If all hooks pass, the commit is made. You can also [temporarily +disable hooks](https://pre-commit.com/#temporarily-disabling-hooks). If you +succeed, it should look like this: ```{r, echo = FALSE, eval = TRUE} knitr::include_graphics("man/figures/screenshot.png") @@ -120,53 +130,25 @@ To update the hook revisions, run `precommit::autoupdate()`. ## Caution -- **Do not abort while hooks are running in RStudio git tab.** Non-staged - changes are stashed to a temp directory and when you abort in RStudio, these - changes are not brought back to you repo. Upvote [this - issue](https://github.com/rstudio/rstudio/issues/6471) to change this. We hope - that in the future, the changes will be recovered in RStudio too. Note that - this is only an issue with RStudio. Stashes are restored when you abort a `git - commit` with `INT` (e.g. Ctrl+C) on the command line. To restore stashes, - manually after hitting *abort* in the RStudio git tab, you can `git - apply /path/to/patch_with_id` whereas you find the patch under your pre-commit - cache, which is usually under `$HOME/.cache/pre-commit/`. - -- Because R is not officially supported as a language in the pre-commit - framework (yet), there is no R package dependency management for the R hooks - provided in this repo. If an R package that is needed by a hook is not yet - installed, you might get this error: - -```{r} -# > Error in loadNamespace(name) : there is no package called ‘__name_of_package__’ -``` - In that case, just install the package with `install.packages()` once and - try to commit again. - All R dependencies of the pre-commit hooks provided in this repo are suggested - dependencies of this R package, so if you want to install them all, just - `install.packages("precommit", dependencies = c("Imports", "Suggests"))`. - -## Documentation - -The [online -documentation](https://lorenzwalthert.github.io/precommit/index.html) of this -package only covers the functionality added on top of pre-commit by this -package. Everything else is covered in the extensive [online -documentation](https://pre-commit.com) of the pre-commit framework itself, -including how to: - -- create pre-push hooks - -- create local hooks - -- and more +**Do not abort while hooks are running in RStudio git tab.** Non-staged changes +are stashed to a temp directory and when you abort in RStudio, these changes are +not brought back to you repo. Upvote [this +issue](https://github.com/rstudio/rstudio/issues/6471) to change this. We hope +that in the future, the changes will be recovered in RStudio too. Note that this +is only an issue with RStudio. Stashes are restored when you abort a `git +commit` with `INT` (e.g. Ctrl+C) on the command line. To restore stashes, +manually after hitting *abort* in the RStudio git tab, you can `git apply +/path/to/patch_with_id` whereas you find the patch under your pre-commit cache, +which is usually under `$HOME/.cache/pre-commit/`. ## Update -To update the pre-commit executable, use the update utilities provided by -your installation method. If you chose conda, you can use +To update the pre-commit executable, use the update utilities provided by your +installation method. If you chose conda, you can use `precommit::update_precommit()`. -You can check the version of you executable with `precommit::version_precommit()`. +You can check the version of you executable with +`precommit::version_precommit()`. ## Uninstallation diff --git a/README.md b/README.md index 6219db7de..f8bfa7ba2 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ The following online docs are available: - [GitHub development version](https://lorenzwalthert.github.io/precommit/dev/). +These only cover the functionality added on top of the pre-commit +framework by this package. Everything else is covered in the extensive +[online documentation](https://pre-commit.com) of the pre-commit +framework itself, including how to create hooks for actions like +`git push` or `git checkout`, create local hooks etc. + ## Installation You can install the package from CRAN: @@ -44,9 +50,10 @@ install.packages("precommit") ``` To access pre-commit functionality from R, you also need to install the -[pre-commit framework](https://pre-commit.com). The following command -line methods are tested to work with this R package (and accessing them -from outside R is easier and use is slightly faster): +[pre-commit framework](https://pre-commit.com) on which the hook from +this repo build. The following command line methods are tested to work +with this R package (and accessing them from outside R is easier and use +is slightly faster): - `$ pip3 install pre-commit --user` (macOS, Linux and Windows) **outside** a conda or virtual environment. @@ -114,49 +121,17 @@ To update the hook revisions, run `precommit::autoupdate()`. ## Caution -- **Do not abort while hooks are running in RStudio git tab.** - Non-staged changes are stashed to a temp directory and when you - abort in RStudio, these changes are not brought back to you repo. - Upvote [this issue](https://github.com/rstudio/rstudio/issues/6471) - to change this. We hope that in the future, the changes will be - recovered in RStudio too. Note that this is only an issue with - RStudio. Stashes are restored when you abort a `git commit` with - `INT` (e.g. Ctrl+C) on the command line. To restore stashes, - manually after hitting *abort* in the RStudio git tab, you can - `git apply /path/to/patch_with_id` whereas you find the patch - under your pre-commit cache, which is usually under - `$HOME/.cache/pre-commit/`. - -- Because R is not officially supported as a language in the - pre-commit framework (yet), there is no R package dependency - management for the R hooks provided in this repo. If an R package - that is needed by a hook is not yet installed, you might get this - error: - -``` r -# > Error in loadNamespace(name) : there is no package called ‘__name_of_package__’ -``` - -In that case, just install the package with `install.packages()` once -and try to commit again. All R dependencies of the pre-commit hooks -provided in this repo are suggested dependencies of this R package, so -if you want to install them all, just -`install.packages("precommit", dependencies = c("Imports", "Suggests"))`. - -## Documentation - -The [online -documentation](https://lorenzwalthert.github.io/precommit/index.html) of -this package only covers the functionality added on top of pre-commit by -this package. Everything else is covered in the extensive [online -documentation](https://pre-commit.com) of the pre-commit framework -itself, including how to: - -- create pre-push hooks - -- create local hooks - -- and more +**Do not abort while hooks are running in RStudio git tab.** Non-staged +changes are stashed to a temp directory and when you abort in RStudio, +these changes are not brought back to you repo. Upvote [this +issue](https://github.com/rstudio/rstudio/issues/6471) to change this. +We hope that in the future, the changes will be recovered in RStudio +too. Note that this is only an issue with RStudio. Stashes are restored +when you abort a `git commit` with `INT` (e.g. Ctrl+C) on the command +line. To restore stashes, manually after hitting *abort* in the RStudio +git tab, you can `git apply /path/to/patch_with_id` whereas you find the +patch under your pre-commit cache, which is usually under +`$HOME/.cache/pre-commit/`. ## Update diff --git a/vignettes/FAQ.Rmd b/vignettes/FAQ.Rmd index a89b5a9c6..bca68b54a 100644 --- a/vignettes/FAQ.Rmd +++ b/vignettes/FAQ.Rmd @@ -24,7 +24,7 @@ directory, people wrote frameworks to basically maintain these files. One of them is [pre-commit.com](https://pre-commit.com). So you call git to commit, git calls its internal hooks, these hooks (bash scripts in the simplest case) are provided by the pre-commit framework. And where does pre-commit get all it's nice hooks -from? From us. +from? From us. ## How are hooks accessed? What happens if there's no internet connection? @@ -32,9 +32,20 @@ Internet connection is required during installation (`precommit::install_precommit()`) and project initialization (`precommit::use_precommit()`) as well as when hooks are updated (`precommit::autoupdate()`). Otherwise, no internet connection is required. -Hooks will be placed into `.git/` during calling the -`precommit::use_precommit()` and afterwards you can `precommit::autoupdate()` -to replace the hooks with their new version (that's what I think happens). +During initialization, hooks from this repo will be placed in a virtual +environment within the user cache and upon committing, they are called from a +generic hook helper in `.git/hooks/`. + +## Why do some hooks not give me the same results as running the command interactively? + +Note that starting with `precommit > 0.1.3`, hooks run in an isolated +[`{renv}`](https://rstudio.github.io/renv/), leveraging [R as a supported language](https://pre-commit.com/#r) in the pre-commit framework. The version of a package you use interactively +(e.g. `{roxygen2}` to document) might for that reason be different from the one +`{precommit}` uses. Since pre-commit will do all the work for you and sometimes +even caches results for speed, we don't recommend running these things manually. +If you need to know which package versions are used, look for the `renv.lock` +file in https://github.com/lorenzwalthert/precommit at the tag specified under +`rev:` in your `.pre-commit-config.yaml`. ## Can you use it outside RStudio? @@ -42,12 +53,9 @@ Yes, all but the `open_config()` and `open_wordlist()` to open files in RStudio. ## Can I use the hooks provided in this package without installing the R package? -Yes, apart from the `roxygenize` hook (which uses an exported function from -{precommit}). The hooks work even if you don't have the R package installed -because all you need to have for the hooks to work is the pre-commit executable. -It will `git clone` the hooks from this repo into `.git/hooks` or similar. All -exported functions of this package are just for the users convenience. - +Yes, you don't need to manually install this package. Although technically +speaking, this package will get installed into a virtual environment isolated +from your global and project library. ## How can I make sure that my contributors are using the hooks? @@ -83,19 +91,6 @@ described [here](https://pre-commit.com/#temporarily-disabling-hooks). How to contribute new hooks is explained in [`CONTRIBUTING.md`](https://github.com/lorenzwalthert/precommit/blob/master/CONTRIBUTING.md). -## Why are my hooks running slowly? - -Some of the hooks depend on R functions that run slowly, e.g. the `style-files` -hook depends on `styler`, which is not very fast. Also, note that for each hook, -R is started. Make sure your startup process is quick for non-interactive use, -e.g. your `.Rprofile` and related files do not have a long execution time when -pre-commit calls them. You can wrap code in `if (interactive()) ` to only -execute it in an interactive session or wrap it in -`if (Sys.getenv("PRE_COMMIT") != "1")` (if you have `pre-commit >= 2.5.0`), so -it won't run when pre-commit hooks are ran. Find out more about the startup -process with `?startup`. - - *** There is more. Check out the documentation of the [pre-commit](https://pre-commit.com) framework. diff --git a/vignettes/available-hooks.Rmd b/vignettes/available-hooks.Rmd index 65d5f0d03..8b602cbac 100644 --- a/vignettes/available-hooks.Rmd +++ b/vignettes/available-hooks.Rmd @@ -165,6 +165,11 @@ exists, the hook emits a warning which you can silence with args: [--no-warn-cache] ``` +Because the hook will write the version of `{roxygen2}` to `DESCRIPTON`, you +should either make sure the version you use when you call `{roxygen2}` +interactively matches the one + + This hook does not modify input files, but writes to `.Rd` files in `man/`, `NAMESPACE` and potentially others depending on which roxygen roclets you specified in `DESCRIPTION`. @@ -183,12 +188,7 @@ Flag not set by default, i.e. the hook will fail if such a call is found. This hook does not modify the file `DESCRIPTION` because the user should decide for each package if it should go to `Imports:` or `Suggests:`, which can be done -easily with `usethis::use_package()`. For those who use -`usethis::use_package()`: As long as the CRAN version of the dependency {desc} -is `v1.2.0`, we recommend you to install the GitHub version because otherwise, -the new dependencies won't be added in alphabetical order and after adding a -dependency, `use-tidy-description` will fail in most cases -(#85)[https://github.com/r-lib/desc/pull/85]. +easily with `usethis::use_package()`. ## `use-tidy-description` From f153aadf0592f652db5ace5e1921f7bc6d8da144 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 11:49:53 +0100 Subject: [PATCH 09/75] make clear that this is setting up things for a repo --- R/setup.R | 4 ++-- man/precommit-package.Rd | 10 +++++----- man/use_precommit.Rd | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/setup.R b/R/setup.R index e1a5fcccb..6dcb10fba 100644 --- a/R/setup.R +++ b/R/setup.R @@ -1,6 +1,6 @@ -#' Set up pre-commit +#' Get started with pre-commit #' -#' Get started. +#' This function sets up pre-commit for your git repo. #' @param install_hooks Whether to install environments for all available hooks. #' If `FALSE`, environments are installed with first commit. #' @param legacy_hooks How to treat hooks already in the repo which are not diff --git a/man/precommit-package.Rd b/man/precommit-package.Rd index 0e621f0a8..fb117b524 100644 --- a/man/precommit-package.Rd +++ b/man/precommit-package.Rd @@ -6,11 +6,11 @@ \alias{precommit-package} \title{precommit: Pre-Commit Hooks} \description{ -Useful git hooks for R building on top of the - multi-language framework 'pre-commit' for hook management. This - package provides git hooks for common tasks like formatting files with - 'styler' or spell checking as well as wrapper functions to access the - 'pre-commit' executable. +Useful git hooks for R building on top of the multi-language + framework 'pre-commit' for hook management. This package provides git + hooks for common tasks like formatting files with 'styler' or spell + checking as well as wrapper functions to access the 'pre-commit' + executable. } \seealso{ Useful links: diff --git a/man/use_precommit.Rd b/man/use_precommit.Rd index 2fb7c293b..666137da4 100644 --- a/man/use_precommit.Rd +++ b/man/use_precommit.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/setup.R \name{use_precommit} \alias{use_precommit} -\title{Set up pre-commit} +\title{Get started with pre-commit} \usage{ use_precommit( config_source = getOption("precommit.config_source"), @@ -40,7 +40,7 @@ If \code{FALSE}, environments are installed with first commit.} \code{NULL} (invisibly). The function is called for its side effects. } \description{ -Get started. +This function sets up pre-commit for your git repo. } \section{When to call this function?}{ From 92be882bf35f23f8a589fe3e84b178472c3aa586 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 11:53:06 +0100 Subject: [PATCH 10/75] intro venv --- vignettes/FAQ.Rmd | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vignettes/FAQ.Rmd b/vignettes/FAQ.Rmd index bca68b54a..31e962757 100644 --- a/vignettes/FAQ.Rmd +++ b/vignettes/FAQ.Rmd @@ -41,10 +41,11 @@ generic hook helper in `.git/hooks/`. Note that starting with `precommit > 0.1.3`, hooks run in an isolated [`{renv}`](https://rstudio.github.io/renv/), leveraging [R as a supported language](https://pre-commit.com/#r) in the pre-commit framework. The version of a package you use interactively (e.g. `{roxygen2}` to document) might for that reason be different from the one -`{precommit}` uses. Since pre-commit will do all the work for you and sometimes -even caches results for speed, we don't recommend running these things manually. -If you need to know which package versions are used, look for the `renv.lock` -file in https://github.com/lorenzwalthert/precommit at the tag specified under +pre-commit uses. The point of using pre-commit is to take mental burden off your +shoulders (and sometimes even caches results for speed), so there is no need to +run functionality covered by the hooks manually anyways. If you need to know +which package versions are used, look for the `renv.lock` file in +https://github.com/lorenzwalthert/precommit at the git tag specified under `rev:` in your `.pre-commit-config.yaml`. ## Can you use it outside RStudio? From 2c92d9c152ded08d83809206be4d72c46ea3e790 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 11:57:39 +0100 Subject: [PATCH 11/75] rename to test file --- tests/testthat/{test-all.R => test-hooks.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/testthat/{test-all.R => test-hooks.R} (100%) diff --git a/tests/testthat/test-all.R b/tests/testthat/test-hooks.R similarity index 100% rename from tests/testthat/test-all.R rename to tests/testthat/test-hooks.R From 9156093fdfc64a3899fa7434ba42c4d7c7330a01 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 14:59:35 +0100 Subject: [PATCH 12/75] temporarily disable R cmd check --- .github/workflows/R-CMD-check.yaml | 131 ----------------------------- 1 file changed, 131 deletions(-) delete mode 100644 .github/workflows/R-CMD-check.yaml diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml deleted file mode 100644 index 8fab229d4..000000000 --- a/.github/workflows/R-CMD-check.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. -# -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions -on: - push: - branches: - - master - pull_request: - branches: - - master - -name: R-CMD-check - -jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}, ${{ matrix.config.installation_method }}) - - strategy: - fail-fast: false - matrix: - config: - # macOS - - {os: macOS-latest, r: 'release', installation_method: 'brew'} - - {os: macOS-latest, r: 'release', installation_method: 'conda'} - - {os: macOS-latest, r: 'release', installation_method: 'pip'} - # Windows - - {os: windows-latest, r: 'release', installation_method: 'pip'} - - {os: windows-latest, r: 'release', installation_method: 'conda'} - # Linux - - {os: ubuntu-18.04, r: 'release', installation_method: 'pip', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-18.04, r: 'release', installation_method: 'conda', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } -# - {os: ubuntu-16.04, r: 'devel', installation_method: 'conda', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } -# - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} -# - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} -# - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} -# - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - PRECOMMIT_INSTALLATION_METHOD: ${{ matrix.config.installation_method }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@master - with: - r-version: ${{ matrix.config.r }} - http-user-agent: ${{ matrix.config.http-user-agent }} - - - uses: r-lib/actions/setup-pandoc@master - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v1 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - name: Install system dependencies (Linux) - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') - - - name: Install system dependencies (brew) - if: matrix.config.installation_method == 'brew' - run: brew install pre-commit - - name: Install system dependencies (pip) - if: matrix.config.installation_method == 'pip' - run: | - pip3 install setuptools --user - pip3 install pre-commit --user - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - # installation methods other than conda don't need reticulate - if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') { - remove.packages('reticulate') - } - shell: Rscript {0} - - name: Install system dependencies (conda) - if: matrix.config.installation_method == 'conda' - run: | - reticulate::install_miniconda() - shell: Rscript {0} - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: | - if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') { - Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "False") - } - remotes::install_local() # circumvent https://github.com/r-lib/rcmdcheck/issues/136 - rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check From b44f299decd4937745f33aec69760ee86907c643 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:01:21 +0100 Subject: [PATCH 13/75] add simple hook test --- .github/workflows/hook-tests.yaml | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/hook-tests.yaml diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml new file mode 100644 index 000000000..0fd8fe6ba --- /dev/null +++ b/.github/workflows/hook-tests.yaml @@ -0,0 +1,87 @@ +on: + push: + branches: + - master + pull_request: + branches: + - master + +name: Hook tests + +jobs: + hook-test: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}, ${{ matrix.config.installation_method }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + env: + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + - name: Install system dependencies (Linux) + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') + - name: Prepare virtual environment + run: | + renv::restore() + # needed to make sure renv is activated in run_test() + writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') + shell: Rscript {0} + - name: Session info + run: | + renv::install('sessioninfo') + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + - name: Test + run: | + renv::install('testthat') + renv::install(getwd()) # circumvent https://github.com/r-lib/rcmdcheck/issues/136 + test_file('tests/testthat/test-hooks.R') + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check From f3a988e013a6bce708775b638286f1783392954d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:04:02 +0100 Subject: [PATCH 14/75] we don't need pandoc --- .github/workflows/hook-tests.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 0fd8fe6ba..f97978e29 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -27,19 +27,14 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@master with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} - - - uses: r-lib/actions/setup-pandoc@master - - name: Query dependencies run: | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") shell: Rscript {0} - - name: Cache R packages if: runner.os != 'Windows' uses: actions/cache@v1 From a0b7de40edf0f79aafb366437c678a747c4a0550 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:15:19 +0100 Subject: [PATCH 15/75] activate renv --- .github/workflows/hook-tests.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index f97978e29..37f33e6bd 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -51,17 +51,18 @@ jobs: done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') - name: Prepare virtual environment run: | + source('renv/activate.R') renv::restore() # needed to make sure renv is activated in run_test() writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') shell: Rscript {0} - name: Session info run: | - renv::install('sessioninfo') + install.packages('sessioninfo') options(width = 100) pkgs <- installed.packages()[, "Package"] sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} + shell: Rscript --vanilla {0} - name: Test run: | renv::install('testthat') From 5146ebf6d626a731661882e4480529e6f98324e9 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:28:08 +0100 Subject: [PATCH 16/75] only run on macOS now, cache as suggested in https://github.com/actions/cache/blob/master/examples.md#r---renv --- .github/workflows/hook-tests.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 37f33e6bd..1b4b6b05e 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -19,8 +19,8 @@ jobs: matrix: config: - {os: macOS-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + #- {os: windows-latest, r: 'release'} + #- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } env: RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -36,10 +36,10 @@ jobs: writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") shell: Rscript {0} - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v1 + if: startsWith(runner.os, 'macOS') + uses: actions/cache@v2 with: - path: ${{ env.R_LIBS_USER }} + path: ~/Library/Application Support/renv key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - name: Install system dependencies (Linux) From b41edf56f527eeaf1a28ada0530a08b120970184 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:29:18 +0100 Subject: [PATCH 17/75] use a mirror --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 1b4b6b05e..90c4be6cc 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -58,7 +58,7 @@ jobs: shell: Rscript {0} - name: Session info run: | - install.packages('sessioninfo') + install.packages('sessioninfo', repos = 'cloud.r-project.org') options(width = 100) pkgs <- installed.packages()[, "Package"] sessioninfo::session_info(pkgs, include_base = TRUE) From 23dbcf60f02a2f375d1b173a12ba8a51f2d33861 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:31:08 +0100 Subject: [PATCH 18/75] install renv globally anyways so we can use install utilities with cache --- .github/workflows/hook-tests.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 90c4be6cc..7899394a4 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -51,6 +51,7 @@ jobs: done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') - name: Prepare virtual environment run: | + if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") source('renv/activate.R') renv::restore() # needed to make sure renv is activated in run_test() @@ -58,7 +59,7 @@ jobs: shell: Rscript {0} - name: Session info run: | - install.packages('sessioninfo', repos = 'cloud.r-project.org') + renv::install('sessioninfo', repos = 'cloud.r-project.org') options(width = 100) pkgs <- installed.packages()[, "Package"] sessioninfo::session_info(pkgs, include_base = TRUE) @@ -68,7 +69,7 @@ jobs: renv::install('testthat') renv::install(getwd()) # circumvent https://github.com/r-lib/rcmdcheck/issues/136 test_file('tests/testthat/test-hooks.R') - shell: Rscript {0} + shell: Rscript --vanilla {0} - name: Show testthat output if: always() From 4b542b26a1fd3429b09e5ae95c072d363959f326 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:43:52 +0100 Subject: [PATCH 19/75] build package in different location than testthat and other testing dependencies reside --- .github/workflows/hook-tests.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 7899394a4..3efea1bd9 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -57,6 +57,10 @@ jobs: # needed to make sure renv is activated in run_test() writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') shell: Rscript {0} + - name: Build package in virtual environment + run: | + renv::install(getwd(), dependencies = FALSE) + shell: Rscript {0} - name: Session info run: | renv::install('sessioninfo', repos = 'cloud.r-project.org') @@ -67,8 +71,7 @@ jobs: - name: Test run: | renv::install('testthat') - renv::install(getwd()) # circumvent https://github.com/r-lib/rcmdcheck/issues/136 - test_file('tests/testthat/test-hooks.R') + testthat::test_file('tests/testthat/test-hooks.R') shell: Rscript --vanilla {0} - name: Show testthat output From 63fad34dd9cb7559c3ffb60c1bb32ec7b74fc91a Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:46:38 +0100 Subject: [PATCH 20/75] make a run that caches stuff --- .github/workflows/hook-tests.yaml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 3efea1bd9..58d9c3513 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -57,28 +57,6 @@ jobs: # needed to make sure renv is activated in run_test() writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') shell: Rscript {0} - - name: Build package in virtual environment - run: | - renv::install(getwd(), dependencies = FALSE) - shell: Rscript {0} - - name: Session info - run: | - renv::install('sessioninfo', repos = 'cloud.r-project.org') - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript --vanilla {0} - - name: Test - run: | - renv::install('testthat') - testthat::test_file('tests/testthat/test-hooks.R') - shell: Rscript --vanilla {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - name: Upload check results if: failure() uses: actions/upload-artifact@main From 8dc8ae90247338fbf1252421d53e7998b69a8c74 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 15:51:12 +0100 Subject: [PATCH 21/75] Revert "make a run that caches stuff" This reverts commit 70bad0128125264b1283d9139d633e5d332275d9. --- .github/workflows/hook-tests.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 58d9c3513..3efea1bd9 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -57,6 +57,28 @@ jobs: # needed to make sure renv is activated in run_test() writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') shell: Rscript {0} + - name: Build package in virtual environment + run: | + renv::install(getwd(), dependencies = FALSE) + shell: Rscript {0} + - name: Session info + run: | + renv::install('sessioninfo', repos = 'cloud.r-project.org') + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript --vanilla {0} + - name: Test + run: | + renv::install('testthat') + testthat::test_file('tests/testthat/test-hooks.R') + shell: Rscript --vanilla {0} + + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + - name: Upload check results if: failure() uses: actions/upload-artifact@main From 4cfda2e89a79972b72423967bb0a7f22ab437b68 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 16:07:07 +0100 Subject: [PATCH 22/75] to run tests, we must have package loaded --- .github/workflows/hook-tests.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 3efea1bd9..abe917273 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -70,7 +70,13 @@ jobs: shell: Rscript --vanilla {0} - name: Test run: | - renv::install('testthat') + # testing dependencies (incl. {precommit}) live in global R library, + # hook dependencies in renv, which is only activated when child R + # process is invoked, e.g. as in run_test() + renv::install(c('testthat', 'devtools')) + # some testing infrastructure we need is in R/testing.R + renv::install(getwd(), dependencies = TRUE) + devtools::load_all() testthat::test_file('tests/testthat/test-hooks.R') shell: Rscript --vanilla {0} From 273204f482b877ce1e905805906c4bdfa0a5eaeb Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Mar 2021 16:23:04 +0100 Subject: [PATCH 23/75] check if styler is available --- .github/workflows/hook-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index abe917273..46f05f133 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -54,6 +54,7 @@ jobs: if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") source('renv/activate.R') renv::restore() + library(styler) # needed to make sure renv is activated in run_test() writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') shell: Rscript {0} From 9734bc5fd0b6646c9edc3d6df626d6f1c071c3bc Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 14:42:40 +0100 Subject: [PATCH 24/75] use WIP to test --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b103df18c..457ba5d3b 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_stages: ["commit"] repos: - repo: https://github.com/lorenzwalthert/precommit - rev: v0.1.3 + rev: fb49127c2535e7037c8c9353206176bc21e0fde3 hooks: - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] From 3f53ea15c819ba79895b130928cf5d0181b1ba74 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 14:50:56 +0100 Subject: [PATCH 25/75] bump ci From 51aa1305c12c273b16057a0ccd4bcf3c90ffbf10 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 14:51:49 +0100 Subject: [PATCH 26/75] bump --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 457ba5d3b..c910368de 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_stages: ["commit"] repos: - repo: https://github.com/lorenzwalthert/precommit - rev: fb49127c2535e7037c8c9353206176bc21e0fde3 + rev: 9709dbf3743aba1ecf51f2821ffd9006c62b5ce3 hooks: - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] From 884512288013dc65abfef6a4bab9130dbd1e1213 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 14:56:25 +0100 Subject: [PATCH 27/75] switch to language R --- .pre-commit-hooks.yaml | 40 +++++++++++++++++++------------------- inst/pre-commit-hooks.yaml | 40 +++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 818390905..01218ddd9 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,51 +1,51 @@ - id: roxygenize name: roxygenize description: run roxygen2::roxygenize() - entry: inst/bin/roxygenize - language: script + entry: Rscript inst/bin/roxygenize + language: r files: '^(R|man)/' - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() - entry: inst/bin/use-tidy-description - language: script + entry: Rscript inst/bin/use-tidy-description + language: r files: '^DESCRIPTION$' - id: style-files name: style-files description: style files with styler - entry: inst/bin/style-files - language: script + entry: Rscript inst/bin/style-files + language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement - entry: inst/bin/no-browser-statement - language: script + entry: Rscript inst/bin/no-browser-statement + language: r files: '\.[rR]$' - id: parsable-R name: parsable-R description: check if a .R file is parsable - entry: inst/bin/parsable-R - language: script + entry: Rscript inst/bin/parsable-R + language: r files: '\.[rR]$' - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md - entry: inst/bin/readme-rmd-rendered - language: script + entry: Rscript inst/bin/readme-rmd-rendered + language: r files: 'README\.[Rr]?md$' - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. - entry: inst/bin/codemeta-description-updated - language: script + entry: Rscript inst/bin/codemeta-description-updated + language: r files: '^DESCRIPTION$' - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() - entry: inst/bin/spell-check - language: script + entry: Rscript inst/bin/spell-check + language: r exclude: > (?x)^( data/.*| @@ -73,14 +73,14 @@ - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. - entry: inst/bin/deps-in-desc - language: script + entry: Rscript inst/bin/deps-in-desc + language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - id: lintr name: lintr description: check if a .R file is lint free (using lintr) - entry: inst/bin/lintr - language: script + entry: Rscript inst/bin/lintr + language: r files: '\.[rR]$' exclude: 'renv/activate\.R' diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index 818390905..01218ddd9 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -1,51 +1,51 @@ - id: roxygenize name: roxygenize description: run roxygen2::roxygenize() - entry: inst/bin/roxygenize - language: script + entry: Rscript inst/bin/roxygenize + language: r files: '^(R|man)/' - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() - entry: inst/bin/use-tidy-description - language: script + entry: Rscript inst/bin/use-tidy-description + language: r files: '^DESCRIPTION$' - id: style-files name: style-files description: style files with styler - entry: inst/bin/style-files - language: script + entry: Rscript inst/bin/style-files + language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement - entry: inst/bin/no-browser-statement - language: script + entry: Rscript inst/bin/no-browser-statement + language: r files: '\.[rR]$' - id: parsable-R name: parsable-R description: check if a .R file is parsable - entry: inst/bin/parsable-R - language: script + entry: Rscript inst/bin/parsable-R + language: r files: '\.[rR]$' - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md - entry: inst/bin/readme-rmd-rendered - language: script + entry: Rscript inst/bin/readme-rmd-rendered + language: r files: 'README\.[Rr]?md$' - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. - entry: inst/bin/codemeta-description-updated - language: script + entry: Rscript inst/bin/codemeta-description-updated + language: r files: '^DESCRIPTION$' - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() - entry: inst/bin/spell-check - language: script + entry: Rscript inst/bin/spell-check + language: r exclude: > (?x)^( data/.*| @@ -73,14 +73,14 @@ - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. - entry: inst/bin/deps-in-desc - language: script + entry: Rscript inst/bin/deps-in-desc + language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - id: lintr name: lintr description: check if a .R file is lint free (using lintr) - entry: inst/bin/lintr - language: script + entry: Rscript inst/bin/lintr + language: r files: '\.[rR]$' exclude: 'renv/activate\.R' From 2482329139add75395a8142e2040da2968382488 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 14:58:29 +0100 Subject: [PATCH 28/75] bump --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c910368de..89ac99375 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_stages: ["commit"] repos: - repo: https://github.com/lorenzwalthert/precommit - rev: 9709dbf3743aba1ecf51f2821ffd9006c62b5ce3 + rev: 9360d26cd440a40eac4d9f3dc8546457b42e52be hooks: - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] From 781e9b25ef79ddfaab416d18767b810d553cfc56 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 15:02:57 +0100 Subject: [PATCH 29/75] use env var for testing --- .github/workflows/hook-tests.yaml | 12 ++++++------ DESCRIPTION | 2 +- R/testing.R | 14 +++++++++++++- man/run_test.Rd | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 46f05f133..e1e5ce316 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -54,13 +54,13 @@ jobs: if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") source('renv/activate.R') renv::restore() - library(styler) - # needed to make sure renv is activated in run_test() - writeLines(paste0("source('", getwd(), "/renv/activate.R')"), '~/.Rprofile') - shell: Rscript {0} - - name: Build package in virtual environment - run: | renv::install(getwd(), dependencies = FALSE) + # needed to make sure renv is activated in run_test() + activate <- c( + "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_TESTING')))", + paste0(" renv::activate('", getwd(), "')") + ) + writeLines(activate, '~/.Rprofile') shell: Rscript {0} - name: Session info run: | diff --git a/DESCRIPTION b/DESCRIPTION index 509f2eadb..f800b7725 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,4 +46,4 @@ Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate", if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else { warning("Please install r-lib/pkgapi to make sure the file API is kept up to date"); NULL} ) ) -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.1.9001 diff --git a/R/testing.R b/R/testing.R index aa7455e4b..625cc048e 100644 --- a/R/testing.R +++ b/R/testing.R @@ -15,7 +15,18 @@ #' executable. To check for failed executable, we set `error_msg` to #' the message we expect. To check changed file content, we set `error_msg` to #' `NA`. -#' +#' @section renv: +#' pre-commit >= 2.11.0 supports R as a language and each hook repo has its own +#' virtual environment with package versions locked. For that reason, we should +#' also test with exactly these versions. To avoid convolution of the testing +#' environment (that contains testthat and other packages) and the hook +#' environment (specified in `renv.lock`), we must only activate the hook +#' environment right when the script is called, but `run_test()` must run in the +#' testing environment. Since `--vanilla` is inherited in the child process +#' initiated from `run_test()`, the +#' only way to do this is to set an env variable when running `run_test()` and +#' check in the user R profile if it is set, and then activate the renv. This is +#' done with `R_PRECOMMIT_HOOK_TESTING`. #' @param hook_name The name of the hook in `bin/`. #' @param file_name The file to test in `tests/in` (without extension). #' @param suffix The suffix of `file_name`. @@ -39,6 +50,7 @@ run_test <- function(hook_name, copy = NULL, file_transformer = function(files) files, env = character()) { + withr::local_envvar(list(R_PRECOMMIT_HOOK_TESTING = "1")) path_executable <- system.file( fs::path("bin", hook_name), package = "precommit" diff --git a/man/run_test.Rd b/man/run_test.Rd index 319500cf7..4a26622a3 100644 --- a/man/run_test.Rd +++ b/man/run_test.Rd @@ -69,4 +69,19 @@ the message we expect. To check changed file content, we set \code{error_msg} to \code{NA}. } } +\section{renv}{ + +pre-commit >= 2.11.0 supports R as a language and each hook repo has its own +virtual environment with package versions locked. For that reason, we should +also test with exactly these versions. To avoid convolution of the testing +environment (that contains testthat and other packages) and the hook +environment (specified in \code{renv.lock}), we must only activate the hook +environment right when the script is called, but \code{run_test()} must run in the +testing environment. Since \code{--vanilla} is inherited in the child process +initiated from \code{run_test()}, the +only way to do this is to set an env variable when running \code{run_test()} and +check in the user R profile if it is set, and then activate the renv. This is +done with \code{R_PRECOMMIT_HOOK_TESTING}. +} + \keyword{internal} From 56795b232d7c5d04ad34938a1a30a813dadbc89a Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 15:33:22 +0100 Subject: [PATCH 30/75] fail on test error --- .github/workflows/hook-tests.yaml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index e1e5ce316..a6ac52cb6 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -49,7 +49,7 @@ jobs: do eval sudo $cmd done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') - - name: Prepare virtual environment + - name: Prepare hook environment run: | if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") source('renv/activate.R') @@ -62,14 +62,7 @@ jobs: ) writeLines(activate, '~/.Rprofile') shell: Rscript {0} - - name: Session info - run: | - renv::install('sessioninfo', repos = 'cloud.r-project.org') - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript --vanilla {0} - - name: Test + - name: Perpare testing environment run: | # testing dependencies (incl. {precommit}) live in global R library, # hook dependencies in renv, which is only activated when child R @@ -77,9 +70,24 @@ jobs: renv::install(c('testthat', 'devtools')) # some testing infrastructure we need is in R/testing.R renv::install(getwd(), dependencies = TRUE) + shell: Rscript {0} + - name: Session info (testing environment) + run: | + renv::install('sessioninfo', repos = 'cloud.r-project.org') + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + - name: Test + run: | devtools::load_all() - testthat::test_file('tests/testthat/test-hooks.R') - shell: Rscript --vanilla {0} + testthat::test_file( + "tests/testthat/test-exec.R", + reporter = testthat::MultiReporter$new(list( + testthat::CheckReporter$new(), testthat::FailReporter$new() + )) + ) + shell: Rscript {0} - name: Show testthat output if: always() From b90148cd650654148171b535e5a8aca0dc1ee22d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 15:40:54 +0100 Subject: [PATCH 31/75] test hooks --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index a6ac52cb6..385d3139e 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -82,7 +82,7 @@ jobs: run: | devtools::load_all() testthat::test_file( - "tests/testthat/test-exec.R", + "tests/testthat/test-hooks.R", reporter = testthat::MultiReporter$new(list( testthat::CheckReporter$new(), testthat::FailReporter$new() )) From 8162c6780222139558e847577d24a1225fd74632 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 15:55:51 +0100 Subject: [PATCH 32/75] use newer renv --- renv.lock | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/renv.lock b/renv.lock index 63c46d406..495b9060d 100644 --- a/renv.lock +++ b/renv.lock @@ -462,10 +462,8 @@ }, "renv": { "Package": "renv", - "Version": "0.12.5", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "5c0cdb37f063c58cdab3c7e9fbb8bd2c" + "Version": "0.13.0", + "Source": "Repository" }, "reticulate": { "Package": "reticulate", From 1f0c088adfab2effdf5025ef052fc86f251aa25d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:02:19 +0100 Subject: [PATCH 33/75] use cran version of desc, GitHub verion of styler (t make tests pass) --- renv.lock | 78 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/renv.lock b/renv.lock index 495b9060d..7321b8200 100644 --- a/renv.lock +++ b/renv.lock @@ -109,10 +109,10 @@ }, "cli": { "Package": "cli", - "Version": "2.3.0", + "Version": "2.3.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "26fb4f0871c8e5b84d77f6dc22f2ee0a" + "Hash": "3e3f28efcadfda442cd18651fbcbbecf" }, "clipr": { "Package": "clipr", @@ -165,15 +165,10 @@ }, "desc": { "Package": "desc", - "Version": "1.2.0.9000", - "Source": "GitHub", - "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "desc", - "RemoteUsername": "r-lib", - "RemoteRef": "HEAD", - "RemoteSha": "b4e84816666dd788be4cc8eb886dc2f44358b41d", - "Hash": "304bb37b58052aa55306466167b84b09" + "Version": "1.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b6963166f7f10b970af1006c462ce6cd" }, "diffobj": { "Package": "diffobj", @@ -194,12 +189,12 @@ "Version": "0.7.1", "Source": "GitHub", "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "docopt.R", "RemoteUsername": "docopt", + "RemoteRepo": "docopt.R", "RemoteRef": "HEAD", - "RemoteSha": "b9f031ee6bf8c0add1548ea64360791d9dcb05c0", - "Hash": "9975c22e69171d62dcd9ce4454b848d4" + "RemoteSha": "ebdeb31d911584eab409799423edce3e48a85a2c", + "RemoteHost": "api.github.com", + "Hash": "29e92f2df5a13ca12520224b00a4f488" }, "ellipsis": { "Package": "ellipsis", @@ -378,10 +373,10 @@ }, "pillar": { "Package": "pillar", - "Version": "1.4.7", + "Version": "1.5.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "3b3dd89b2ee115a8b54e93a34cd546b4" + "Hash": "24622aa4a0d3de3463c34513edca99b2" }, "pkgbuild": { "Package": "pkgbuild", @@ -399,10 +394,10 @@ }, "pkgload": { "Package": "pkgload", - "Version": "1.1.0", + "Version": "1.2.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "b6b150cd4709e0c0c9b5d51ac4376282" + "Hash": "cb57de933545960a86f03513e4bd2911" }, "praise": { "Package": "praise", @@ -427,10 +422,10 @@ }, "ps": { "Package": "ps", - "Version": "1.5.0", + "Version": "1.6.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "ebaed51a03411fd5cfc1e12d9079b353" + "Hash": "32620e2001c1dce1af49c49dccbb9420" }, "purrr": { "Package": "purrr", @@ -463,7 +458,9 @@ "renv": { "Package": "renv", "Version": "0.13.0", - "Source": "Repository" + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9f10d9db5b50400c348920c5c603385e" }, "reticulate": { "Package": "reticulate", @@ -542,10 +539,15 @@ }, "styler": { "Package": "styler", - "Version": "1.3.2", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "60b23effde8d08a56a64ebeb92a32749" + "Version": "1.3.2.9000", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "styler", + "RemoteUsername": "r-lib", + "RemoteRef": "HEAD", + "RemoteSha": "5957df1748de5bf8585705aad0c82534f54e014b", + "Hash": "a945cac2e09910ca7ace9bd21667524c" }, "sys": { "Package": "sys", @@ -563,17 +565,17 @@ }, "tibble": { "Package": "tibble", - "Version": "3.0.6", + "Version": "3.1.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "9c6c10e594f32096ede0c7d373ccbddd" + "Hash": "4d894a114dbd4ecafeda5074e7c538e6" }, "tinytex": { "Package": "tinytex", - "Version": "0.29", + "Version": "0.30", "Source": "Repository", "Repository": "CRAN", - "Hash": "f0b0ba735febac9a8344253ae6fa93f5" + "Hash": "066f49a225dc3215cb1f32bc23535f88" }, "usethis": { "Package": "usethis", @@ -584,10 +586,10 @@ }, "utf8": { "Package": "utf8", - "Version": "1.1.4", + "Version": "1.2.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "4a5081acfb7b81a572e4384a7aaf2af1" + "Hash": "c3ad47dc6da0751f18ed53c4613e3ac7" }, "vctrs": { "Package": "vctrs", @@ -598,10 +600,10 @@ }, "waldo": { "Package": "waldo", - "Version": "0.2.4", + "Version": "0.2.5", "Source": "Repository", "Repository": "CRAN", - "Hash": "29df52c781e572c967f90de9713423c4" + "Hash": "20c45f1d511a3f730b7b469f4d11e104" }, "whisker": { "Package": "whisker", @@ -619,10 +621,10 @@ }, "xfun": { "Package": "xfun", - "Version": "0.21", + "Version": "0.22", "Source": "Repository", "Repository": "CRAN", - "Hash": "f3ddcca198959a42e8cb6b06c30d4f1e" + "Hash": "eab2f8ba53809c321813e72ecbbd19ba" }, "xml2": { "Package": "xml2", @@ -633,10 +635,10 @@ }, "xmlparsedata": { "Package": "xmlparsedata", - "Version": "1.0.4", + "Version": "1.0.5", "Source": "Repository", "Repository": "CRAN", - "Hash": "373bcee7aad3980799936749cfca6f24" + "Hash": "45e4bf3c46476896e821fc0a408fb4fc" }, "yaml": { "Package": "yaml", From 694dc05d806ed790341cea1a8f2f74d85af76cd2 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:03:52 +0100 Subject: [PATCH 34/75] exclude renv from build --- .Rbuildignore | 1 + renv/.gitignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index d2f4a8df6..831696c22 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ +^renv$ ^renv\.lock$ ^README\.Rmd$ ^.*\.Rproj$ diff --git a/renv/.gitignore b/renv/.gitignore index 62e60ad4a..5246cf196 100644 --- a/renv/.gitignore +++ b/renv/.gitignore @@ -1,3 +1,4 @@ +local/ library/ lock/ python/ From 662589f34bdf4797a5ef41c2ccdc40025a039fef Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:04:16 +0100 Subject: [PATCH 35/75] use newer renv in activation script too --- renv/activate.R | 498 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 360 insertions(+), 138 deletions(-) diff --git a/renv/activate.R b/renv/activate.R index 36b5038ca..2cba08a4c 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,15 +2,14 @@ local({ # the requested version of renv - version <- "0.12.5" + version <- "0.13.0" # the project directory project <- getwd() # avoid recursion - if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) { + if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) return(invisible(TRUE)) - } # signal that we're loading renv during R startup Sys.setenv("RENV_R_INITIALIZING" = "true") @@ -29,70 +28,68 @@ local({ # if renv has already been loaded, and it's the requested version of renv, # nothing to do spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") - if (identical(spec[["version"]], version)) { + if (identical(spec[["version"]], version)) return(invisible(TRUE)) - } # otherwise, unload and attempt to load the correct version of renv unloadNamespace("renv") + } - # load bootstrap tools + # load bootstrap tools bootstrap <- function(version, library) { - + # attempt to download renv tarball <- tryCatch(renv_bootstrap_download(version), error = identity) - if (inherits(tarball, "error")) { + if (inherits(tarball, "error")) stop("failed to download renv ", version) - } - + # now attempt to install status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) - if (inherits(status, "error")) { + if (inherits(status, "error")) stop("failed to install renv ", version) - } + } - + renv_bootstrap_tests_running <- function() { getOption("renv.tests.running", default = FALSE) } - + renv_bootstrap_repos <- function() { - + # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) { + if (!is.na(repos)) return(repos) - } - + # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) { + if (renv_bootstrap_tests_running()) return(getOption("renv.tests.repos")) - } - + # retrieve current repos repos <- getOption("repos") - + # ensure @CRAN@ entries are resolved repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" - + # add in renv.bootstrap.repos if set - default <- c(CRAN = "https://cloud.r-project.org") + default <- c(FALLBACK = "https://cloud.r-project.org") extra <- getOption("renv.bootstrap.repos", default = default) repos <- c(repos, extra) - + # remove duplicates that might've snuck in dupes <- duplicated(repos) | duplicated(names(repos)) repos[!dupes] + } - + renv_bootstrap_download <- function(version) { - + # if the renv version number has 4 components, assume it must # be retrieved via github nv <- numeric_version(version) components <- unclass(nv)[[1]] - + methods <- if (length(components) == 4L) { list( renv_bootstrap_download_github @@ -103,65 +100,92 @@ local({ renv_bootstrap_download_cran_archive ) } - + for (method in methods) { path <- tryCatch(method(version), error = identity) - if (is.character(path) && file.exists(path)) { + if (is.character(path) && file.exists(path)) return(path) - } } - + stop("failed to download renv ", version) + } - + renv_bootstrap_download_impl <- function(url, destfile) { + mode <- "wb" - + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 fixup <- Sys.info()[["sysname"]] == "Windows" && - substring(url, 1L, 5L) == "file:" - - if (fixup) { + substring(url, 1L, 5L) == "file:" + + if (fixup) mode <- "w+b" - } - + utils::download.file( - url = url, + url = url, destfile = destfile, - mode = mode, - quiet = TRUE + mode = mode, + quiet = TRUE ) + } - + renv_bootstrap_download_cran_latest <- function(version) { + repos <- renv_bootstrap_download_cran_latest_find(version) - - message("* Downloading renv ", version, " from CRAN ... ", appendLF = FALSE) - - info <- tryCatch( - utils::download.packages( - pkgs = "renv", - repos = repos, - destdir = tempdir(), - quiet = TRUE - ), - condition = identity - ) - + + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + + downloader <- function(type) { + + tryCatch( + utils::download.packages( + pkgs = "renv", + destdir = tempdir(), + repos = repos, + type = type, + quiet = TRUE + ), + condition = identity + ) + + } + + # first, try downloading a binary on Windows + macOS if appropriate + binary <- + !identical(.Platform$pkgType, "source") && + !identical(getOption("pkgType"), "source") && + Sys.info()[["sysname"]] %in% c("Darwin", "Windows") + + if (binary) { + info <- downloader(type = "binary") + if (!inherits(info, "condition")) { + message("OK (downloaded binary)") + return(info[1, 2]) + } + } + + # otherwise, try downloading a source tarball + info <- downloader(type = "source") if (inherits(info, "condition")) { message("FAILED") return(FALSE) } - - message("OK") + + # report success and return + message("OK (downloaded source)") info[1, 2] + } - + renv_bootstrap_download_cran_latest_find <- function(version) { + all <- renv_bootstrap_repos() - + for (repos in all) { + db <- tryCatch( as.data.frame( x = utils::available.packages(repos = repos), @@ -169,53 +193,57 @@ local({ ), error = identity ) - - if (inherits(db, "error")) { + + if (inherits(db, "error")) next - } - + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] - if (nrow(entry) == 0) { + if (nrow(entry) == 0) next - } - + return(repos) + } - + fmt <- "renv %s is not available from your declared package repositories" stop(sprintf(fmt, version)) + } - + renv_bootstrap_download_cran_archive <- function(version) { + name <- sprintf("renv_%s.tar.gz", version) repos <- renv_bootstrap_repos() urls <- file.path(repos, "src/contrib/Archive/renv", name) destfile <- file.path(tempdir(), name) - - message("* Downloading renv ", version, " from CRAN archive ... ", appendLF = FALSE) - + + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + for (url in urls) { + status <- tryCatch( renv_bootstrap_download_impl(url, destfile), condition = identity ) - + if (identical(status, 0L)) { message("OK") return(destfile) } + } - + message("FAILED") return(FALSE) + } - + renv_bootstrap_download_github <- function(version) { + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") - if (!identical(enabled, "TRUE")) { + if (!identical(enabled, "TRUE")) return(FALSE) - } - + # prepare download options pat <- Sys.getenv("GITHUB_PAT") if (nzchar(Sys.which("curl")) && nzchar(pat)) { @@ -231,33 +259,34 @@ local({ options(download.file.method = "wget", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE) } - + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) - + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) name <- sprintf("renv_%s.tar.gz", version) destfile <- file.path(tempdir(), name) - + status <- tryCatch( renv_bootstrap_download_impl(url, destfile), condition = identity ) - + if (!identical(status, 0L)) { message("FAILED") return(FALSE) } - + message("OK") return(destfile) + } - + renv_bootstrap_install <- function(version, tarball, library) { - + # attempt to install it into project library message("* Installing renv ", version, " ... ", appendLF = FALSE) dir.create(library, showWarnings = FALSE, recursive = TRUE) - + # invoke using system2 so we can capture and report output bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" @@ -265,7 +294,7 @@ local({ args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) output <- system2(r, args, stdout = TRUE, stderr = TRUE) message("Done!") - + # check for successful install status <- attr(output, "status") if (is.numeric(status) && !identical(status, 0L)) { @@ -274,132 +303,325 @@ local({ text <- c(header, lines, output) writeLines(text, con = stderr()) } - + status + } - - renv_bootstrap_prefix <- function() { - + + renv_bootstrap_platform_prefix <- function() { + # construct version prefix version <- paste(R.version$major, R.version$minor, sep = ".") prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") - + # include SVN revision for development versions of R # (to avoid sharing platform-specific artefacts with released versions of R) devel <- - identical(R.version[["status"]], "Under development (unstable)") || - identical(R.version[["nickname"]], "Unsuffered Consequences") - - if (devel) { + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") - } - + # build list of path components components <- c(prefix, R.version$platform) - + # include prefix if provided by user - prefix <- Sys.getenv("RENV_PATHS_PREFIX") - if (nzchar(prefix)) { + prefix <- renv_bootstrap_platform_prefix_impl() + if (!is.na(prefix) && nzchar(prefix)) components <- c(prefix, components) - } - + # build prefix paste(components, collapse = "/") + } - + + renv_bootstrap_platform_prefix_impl <- function() { + + # if an explicit prefix has been supplied, use it + prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) + if (!is.na(prefix)) + return(prefix) + + # if the user has requested an automatic prefix, generate it + auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (auto %in% c("TRUE", "True", "true", "1")) + return(renv_bootstrap_platform_prefix_auto()) + + # empty string on failure + "" + + } + + renv_bootstrap_platform_prefix_auto <- function() { + + prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) + if (inherits(prefix, "error") || prefix %in% "unknown") { + + msg <- paste( + "failed to infer current operating system", + "please file a bug report at https://github.com/rstudio/renv/issues", + sep = "; " + ) + + warning(msg) + + } + + prefix + + } + + renv_bootstrap_platform_os <- function() { + + sysinfo <- Sys.info() + sysname <- sysinfo[["sysname"]] + + # handle Windows + macOS up front + if (sysname == "Windows") + return("windows") + else if (sysname == "Darwin") + return("macos") + + # check for os-release files + for (file in c("/etc/os-release", "/usr/lib/os-release")) + if (file.exists(file)) + return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) + + # check for redhat-release files + if (file.exists("/etc/redhat-release")) + return(renv_bootstrap_platform_os_via_redhat_release()) + + "unknown" + + } + + renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { + + # read /etc/os-release + release <- utils::read.table( + file = file, + sep = "=", + quote = c("\"", "'"), + col.names = c("Key", "Value"), + comment.char = "#", + stringsAsFactors = FALSE + ) + + vars <- as.list(release$Value) + names(vars) <- release$Key + + # get os name + os <- tolower(sysinfo[["sysname"]]) + + # read id + id <- "unknown" + for (field in c("ID", "ID_LIKE")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + id <- vars[[field]] + break + } + } + + # read version + version <- "unknown" + for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + version <- vars[[field]] + break + } + } + + # join together + paste(c(os, id, version), collapse = "-") + + } + + renv_bootstrap_platform_os_via_redhat_release <- function() { + + # read /etc/redhat-release + contents <- readLines("/etc/redhat-release", warn = FALSE) + + # infer id + id <- if (grepl("centos", contents, ignore.case = TRUE)) + "centos" + else if (grepl("redhat", contents, ignore.case = TRUE)) + "redhat" + else + "unknown" + + # try to find a version component (very hacky) + version <- "unknown" + + parts <- strsplit(contents, "[[:space:]]")[[1L]] + for (part in parts) { + + nv <- tryCatch(numeric_version(part), error = identity) + if (inherits(nv, "error")) + next + + version <- nv[1, 1] + break + + } + + paste(c("linux", id, version), collapse = "-") + + } + renv_bootstrap_library_root_name <- function(project) { - + # use project name as-is if requested asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") - if (asis) { + if (asis) return(basename(project)) - } - + # otherwise, disambiguate based on project's path id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) paste(basename(project), id, sep = "-") + } - + renv_bootstrap_library_root <- function(project) { + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) - if (!is.na(path)) { + if (!is.na(path)) return(path) - } - + path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) if (!is.na(path)) { name <- renv_bootstrap_library_root_name(project) return(file.path(path, name)) } - - file.path(project, "renv/library") + + prefix <- renv_bootstrap_profile_prefix() + paste(c(project, prefix, "renv/library"), collapse = "/") + } - + renv_bootstrap_validate_version <- function(version) { + loadedversion <- utils::packageDescription("renv", fields = "Version") - if (version == loadedversion) { + if (version == loadedversion) return(TRUE) - } - + # assume four-component versions are from GitHub; three-component # versions are from CRAN components <- strsplit(loadedversion, "[.-]")[[1]] - remote <- if (length(components) == 4L) { + remote <- if (length(components) == 4L) paste("rstudio/renv", loadedversion, sep = "@") - } else { + else paste("renv", loadedversion, sep = "@") - } - + fmt <- paste( "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", sep = "\n" ) - + msg <- sprintf(fmt, loadedversion, version, remote) warning(msg, call. = FALSE) - + FALSE + } - + renv_bootstrap_hash_text <- function(text) { + hashfile <- tempfile("renv-hash-") on.exit(unlink(hashfile), add = TRUE) - + writeLines(text, con = hashfile) tools::md5sum(hashfile) + } - + renv_bootstrap_load <- function(project, libpath, version) { - + # try to load renv from the project library - if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) return(FALSE) - } - + # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) - + # load the project renv::load(project) - + TRUE + + } + + renv_bootstrap_profile_load <- function(project) { + + # if RENV_PROFILE is already set, just use that + profile <- Sys.getenv("RENV_PROFILE", unset = NA) + if (!is.na(profile) && nzchar(profile)) + return(profile) + + # check for a profile file (nothing to do if it doesn't exist) + path <- file.path(project, "renv/local/profile") + if (!file.exists(path)) + return(NULL) + + # read the profile, and set it if it exists + contents <- readLines(path, warn = FALSE) + if (length(contents) == 0L) + return(NULL) + + # set RENV_PROFILE + profile <- contents[[1L]] + if (nzchar(profile)) + Sys.setenv(RENV_PROFILE = profile) + + profile + + } + + renv_bootstrap_profile_prefix <- function() { + profile <- renv_bootstrap_profile_get() + if (!is.null(profile)) + return(file.path("renv/profiles", profile)) } + + renv_bootstrap_profile_get <- function() { + profile <- Sys.getenv("RENV_PROFILE", unset = "") + renv_bootstrap_profile_normalize(profile) + } + + renv_bootstrap_profile_set <- function(profile) { + profile <- renv_bootstrap_profile_normalize(profile) + if (is.null(profile)) + Sys.unsetenv("RENV_PROFILE") + else + Sys.setenv(RENV_PROFILE = profile) + } + + renv_bootstrap_profile_normalize <- function(profile) { + + if (is.null(profile) || profile %in% c("", "default")) + return(NULL) + + profile + + } + + # load the renv profile, if any + renv_bootstrap_profile_load(project) # construct path to library root root <- renv_bootstrap_library_root(project) # construct library prefix for platform - prefix <- renv_bootstrap_prefix() + prefix <- renv_bootstrap_platform_prefix() # construct full libpath libpath <- file.path(root, prefix) # attempt to load - if (renv_bootstrap_load(project, libpath, version)) { + if (renv_bootstrap_load(project, libpath, version)) return(TRUE) - } # load failed; inform user we're about to bootstrap prefix <- paste("# Bootstrapping renv", version) @@ -411,9 +633,8 @@ local({ bootstrap(version, libpath) # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) { + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) return(TRUE) - } # try again to load if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { @@ -428,4 +649,5 @@ local({ ) warning(paste(msg, collapse = "\n"), call. = FALSE) + }) From 6f04f8790fbf0df496934eb24c152d6e1322b93c Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:14:05 +0100 Subject: [PATCH 36/75] rename env variable --- .github/workflows/hook-tests.yaml | 2 +- R/testing.R | 4 ++-- man/run_test.Rd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 385d3139e..ba10d79bc 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -57,7 +57,7 @@ jobs: renv::install(getwd(), dependencies = FALSE) # needed to make sure renv is activated in run_test() activate <- c( - "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_TESTING')))", + "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_ENV')))", paste0(" renv::activate('", getwd(), "')") ) writeLines(activate, '~/.Rprofile') diff --git a/R/testing.R b/R/testing.R index 625cc048e..4fb2ca4b0 100644 --- a/R/testing.R +++ b/R/testing.R @@ -26,7 +26,7 @@ #' initiated from `run_test()`, the #' only way to do this is to set an env variable when running `run_test()` and #' check in the user R profile if it is set, and then activate the renv. This is -#' done with `R_PRECOMMIT_HOOK_TESTING`. +#' done with `R_PRECOMMIT_HOOK_ENV`. #' @param hook_name The name of the hook in `bin/`. #' @param file_name The file to test in `tests/in` (without extension). #' @param suffix The suffix of `file_name`. @@ -50,7 +50,7 @@ run_test <- function(hook_name, copy = NULL, file_transformer = function(files) files, env = character()) { - withr::local_envvar(list(R_PRECOMMIT_HOOK_TESTING = "1")) + withr::local_envvar(list(R_PRECOMMIT_HOOK_ENV = "1")) path_executable <- system.file( fs::path("bin", hook_name), package = "precommit" diff --git a/man/run_test.Rd b/man/run_test.Rd index 4a26622a3..01db6ba75 100644 --- a/man/run_test.Rd +++ b/man/run_test.Rd @@ -81,7 +81,7 @@ testing environment. Since \code{--vanilla} is inherited in the child process initiated from \code{run_test()}, the only way to do this is to set an env variable when running \code{run_test()} and check in the user R profile if it is set, and then activate the renv. This is -done with \code{R_PRECOMMIT_HOOK_TESTING}. +done with \code{R_PRECOMMIT_HOOK_ENV}. } \keyword{internal} From 566b0c43da50aa8f5c1844b137eaa90c913a1b3e Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:17:37 +0100 Subject: [PATCH 37/75] avoid warning about renv versions by boostraping only for hook env and install renv in global library for testing env --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index ba10d79bc..0a711ae8d 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -51,7 +51,6 @@ jobs: done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') - name: Prepare hook environment run: | - if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") source('renv/activate.R') renv::restore() renv::install(getwd(), dependencies = FALSE) @@ -67,6 +66,7 @@ jobs: # testing dependencies (incl. {precommit}) live in global R library, # hook dependencies in renv, which is only activated when child R # process is invoked, e.g. as in run_test() + if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") renv::install(c('testthat', 'devtools')) # some testing infrastructure we need is in R/testing.R renv::install(getwd(), dependencies = TRUE) From 1066cc133cc43fd43f281bd4916a587579df1fa8 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:22:03 +0100 Subject: [PATCH 38/75] enable cross platform testing --- .github/workflows/hook-tests.yaml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 0a711ae8d..181aca016 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -19,8 +19,8 @@ jobs: matrix: config: - {os: macOS-latest, r: 'release'} - #- {os: windows-latest, r: 'release'} - #- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: windows-latest, r: 'release'} + - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } env: RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -42,6 +42,21 @@ jobs: path: ~/Library/Application Support/renv key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + - name: Cache R packages + if: startsWith(runner.os, 'Linux') + uses: actions/cache@v2 + with: + path: ~/.local/share/renv + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + - name: Cache R packages + if: startsWith(runner.os, 'Windows') + uses: actions/cache@v2 + with: + path: ~\AppData\Local\renv + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + - name: Install system dependencies (Linux) if: runner.os == 'Linux' run: | From fe4da84845b88913276fe5234aeff8d0f093569d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:25:30 +0100 Subject: [PATCH 39/75] select mirror --- .github/workflows/hook-tests.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 181aca016..855795514 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -81,7 +81,9 @@ jobs: # testing dependencies (incl. {precommit}) live in global R library, # hook dependencies in renv, which is only activated when child R # process is invoked, e.g. as in run_test() - if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") + if (!requireNamespace("renv", quietly = TRUE)) { + install.packages("renv", repos = "cloud.r-project.org") + } renv::install(c('testthat', 'devtools')) # some testing infrastructure we need is in R/testing.R renv::install(getwd(), dependencies = TRUE) From 529b85642e552680325dab0d93bf506fee606059 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:27:01 +0100 Subject: [PATCH 40/75] nicer display name --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 855795514..975948fca 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -12,7 +12,7 @@ jobs: hook-test: runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}, ${{ matrix.config.installation_method }}) + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) strategy: fail-fast: false From bc9a59c8fb697b4fb78367646ccb677749cafb18 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:37:05 +0100 Subject: [PATCH 41/75] install remotes for sys req check --- .github/workflows/hook-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 975948fca..e4a114da9 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -33,6 +33,7 @@ jobs: http-user-agent: ${{ matrix.config.http-user-agent }} - name: Query dependencies run: | + install.packages('remotes') # needed for sys reqs writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") shell: Rscript {0} - name: Cache R packages From 648600d3dcd3a15e029b92eb7fe7c6b4d143cc3f Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:43:11 +0100 Subject: [PATCH 42/75] only install remotes on Linux --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index e4a114da9..9d357259d 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -33,7 +33,6 @@ jobs: http-user-agent: ${{ matrix.config.http-user-agent }} - name: Query dependencies run: | - install.packages('remotes') # needed for sys reqs writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") shell: Rscript {0} - name: Cache R packages @@ -61,6 +60,7 @@ jobs: - name: Install system dependencies (Linux) if: runner.os == 'Linux' run: | + Rscript -e "install.packages('remotes', repos = Sys.getenv('RSPM'))" while read -r cmd do eval sudo $cmd From 80c1f752fc4186f4cd21fe185b60f5442544ffb8 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:44:32 +0100 Subject: [PATCH 43/75] try cran with repos for windows --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 9d357259d..b17c31000 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -83,7 +83,7 @@ jobs: # hook dependencies in renv, which is only activated when child R # process is invoked, e.g. as in run_test() if (!requireNamespace("renv", quietly = TRUE)) { - install.packages("renv", repos = "cloud.r-project.org") + install.packages("renv", repos = c(CRAN = "cloud.r-project.org")) } renv::install(c('testthat', 'devtools')) # some testing infrastructure we need is in R/testing.R From 1d04d36f0e81ef48840cd5db7aff8a048a9d9728 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:46:07 +0100 Subject: [PATCH 44/75] ensure cached package library for experimenting --- .github/workflows/hook-tests.yaml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index b17c31000..7f5e9a9c6 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -89,32 +89,3 @@ jobs: # some testing infrastructure we need is in R/testing.R renv::install(getwd(), dependencies = TRUE) shell: Rscript {0} - - name: Session info (testing environment) - run: | - renv::install('sessioninfo', repos = 'cloud.r-project.org') - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - name: Test - run: | - devtools::load_all() - testthat::test_file( - "tests/testthat/test-hooks.R", - reporter = testthat::MultiReporter$new(list( - testthat::CheckReporter$new(), testthat::FailReporter$new() - )) - ) - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check From e11eec24c0ed3035a61e61ea93c4d67a743ebd57 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 16:48:49 +0100 Subject: [PATCH 45/75] try https --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 7f5e9a9c6..c665f3286 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -83,7 +83,7 @@ jobs: # hook dependencies in renv, which is only activated when child R # process is invoked, e.g. as in run_test() if (!requireNamespace("renv", quietly = TRUE)) { - install.packages("renv", repos = c(CRAN = "cloud.r-project.org")) + install.packages("renv", repos = c(CRAN = "https://cloud.r-project.org")) } renv::install(c('testthat', 'devtools')) # some testing infrastructure we need is in R/testing.R From 2c3e69c4bf68ca5ff764dc9c986b766214e9d06d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 17:11:38 +0100 Subject: [PATCH 46/75] remove hook env to fail faster --- .github/workflows/hook-tests.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index c665f3286..c31167948 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -65,18 +65,6 @@ jobs: do eval sudo $cmd done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') - - name: Prepare hook environment - run: | - source('renv/activate.R') - renv::restore() - renv::install(getwd(), dependencies = FALSE) - # needed to make sure renv is activated in run_test() - activate <- c( - "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_ENV')))", - paste0(" renv::activate('", getwd(), "')") - ) - writeLines(activate, '~/.Rprofile') - shell: Rscript {0} - name: Perpare testing environment run: | # testing dependencies (incl. {precommit}) live in global R library, From e3e29c4803f1c8762135f58b5442d7c10c03cade Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 17:17:53 +0100 Subject: [PATCH 47/75] Revert "remove hook env to fail faster" This reverts commit 1b402e3220d8f8807d0ffd5a95b27cbdfa318472. --- .github/workflows/hook-tests.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index c31167948..c665f3286 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -65,6 +65,18 @@ jobs: do eval sudo $cmd done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') + - name: Prepare hook environment + run: | + source('renv/activate.R') + renv::restore() + renv::install(getwd(), dependencies = FALSE) + # needed to make sure renv is activated in run_test() + activate <- c( + "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_ENV')))", + paste0(" renv::activate('", getwd(), "')") + ) + writeLines(activate, '~/.Rprofile') + shell: Rscript {0} - name: Perpare testing environment run: | # testing dependencies (incl. {precommit}) live in global R library, From dea2fa645ee8496b122f4b00462a3c643749f6ba Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 17:33:41 +0100 Subject: [PATCH 48/75] Revert "ensure cached package library for experimenting" This reverts commit f57f74daff3e04ab01447ca4db3d84e4d1072f89. --- .github/workflows/hook-tests.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index c665f3286..160b8439d 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -89,3 +89,32 @@ jobs: # some testing infrastructure we need is in R/testing.R renv::install(getwd(), dependencies = TRUE) shell: Rscript {0} + - name: Session info (testing environment) + run: | + renv::install('sessioninfo', repos = 'cloud.r-project.org') + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + - name: Test + run: | + devtools::load_all() + testthat::test_file( + "tests/testthat/test-hooks.R", + reporter = testthat::MultiReporter$new(list( + testthat::CheckReporter$new(), testthat::FailReporter$new() + )) + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check From 929043f263f236d47219691dd34863f0e2374d00 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 17:51:33 +0100 Subject: [PATCH 49/75] remove empty test --- tests/testthat/setup-git2r.R | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/testthat/setup-git2r.R diff --git a/tests/testthat/setup-git2r.R b/tests/testthat/setup-git2r.R deleted file mode 100644 index e69de29bb..000000000 From 5be7e1b54be1a1e84f78fffce0b4a3c655dae04d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:30:57 +0100 Subject: [PATCH 50/75] test leaking from test into hook env --- .github/workflows/hook-tests.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 160b8439d..7451d3723 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -96,6 +96,14 @@ jobs: pkgs <- installed.packages()[, "Package"] sessioninfo::session_info(pkgs, include_base = TRUE) shell: Rscript {0} + - name: Assert random package is not available in hook env (1/2) + run: | + Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" + - name: Assert random package is not available in hook env (2/2) + run: | + Rscript -e "if ('someP' %in% rownames(installed.packages())) stop('environment isolation not working: You installed a package into the testing environment and it is available in the hook environment')" + env: + R_PRECOMMIT_HOOK_ENV: "1" - name: Test run: | devtools::load_all() @@ -106,7 +114,6 @@ jobs: )) ) shell: Rscript {0} - - name: Show testthat output if: always() run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true From c642a15c760de1b0b2b1e0f30782c4f465760463 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:33:28 +0100 Subject: [PATCH 51/75] rename --- .github/workflows/hook-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 7451d3723..bea1311d6 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -96,10 +96,10 @@ jobs: pkgs <- installed.packages()[, "Package"] sessioninfo::session_info(pkgs, include_base = TRUE) shell: Rscript {0} - - name: Assert random package is not available in hook env (1/2) + - name: Assert no leakage from testing to hook env (1/2) run: | Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" - - name: Assert random package is not available in hook env (2/2) + - name: Assert no leakage from testing to hook env (1/2) run: | Rscript -e "if ('someP' %in% rownames(installed.packages())) stop('environment isolation not working: You installed a package into the testing environment and it is available in the hook environment')" env: From b88827c3bd8d9d88d19ce013849ed882d55ae0e4 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:35:05 +0100 Subject: [PATCH 52/75] better titles --- .github/workflows/hook-tests.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index bea1311d6..a0e7b5c2a 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -35,21 +35,21 @@ jobs: run: | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") shell: Rscript {0} - - name: Cache R packages + - name: Cache R packages (macOs) if: startsWith(runner.os, 'macOS') uses: actions/cache@v2 with: path: ~/Library/Application Support/renv key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - name: Cache R packages + - name: Cache R packages (Linux) if: startsWith(runner.os, 'Linux') uses: actions/cache@v2 with: path: ~/.local/share/renv key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - name: Cache R packages + - name: Cache R packages (Windows) if: startsWith(runner.os, 'Windows') uses: actions/cache@v2 with: From 1131dad80313dab9ee6cb17e656364e7b7de7c24 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:39:36 +0100 Subject: [PATCH 53/75] reorder --- .github/workflows/hook-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index a0e7b5c2a..a211bc84b 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -100,10 +100,10 @@ jobs: run: | Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" - name: Assert no leakage from testing to hook env (1/2) - run: | - Rscript -e "if ('someP' %in% rownames(installed.packages())) stop('environment isolation not working: You installed a package into the testing environment and it is available in the hook environment')" env: R_PRECOMMIT_HOOK_ENV: "1" + run: | + Rscript -e "if ('someP' %in% rownames(installed.packages())) stop('environment isolation not working: You installed a package into the testing environment and it is available in the hook environment')" - name: Test run: | devtools::load_all() From 4897aea95bc8b626bc011a6996da0b7bebabdd45 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:46:14 +0100 Subject: [PATCH 54/75] don't assert anymore --- .github/workflows/hook-tests.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index a211bc84b..423657d08 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -96,14 +96,6 @@ jobs: pkgs <- installed.packages()[, "Package"] sessioninfo::session_info(pkgs, include_base = TRUE) shell: Rscript {0} - - name: Assert no leakage from testing to hook env (1/2) - run: | - Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" - - name: Assert no leakage from testing to hook env (1/2) - env: - R_PRECOMMIT_HOOK_ENV: "1" - run: | - Rscript -e "if ('someP' %in% rownames(installed.packages())) stop('environment isolation not working: You installed a package into the testing environment and it is available in the hook environment')" - name: Test run: | devtools::load_all() From dcf59837b80b3b8972fb75560ca1e064dd495e76 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:47:19 +0100 Subject: [PATCH 55/75] assert after the fact --- .github/workflows/hook-tests.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 423657d08..f03d5e9a8 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -110,7 +110,14 @@ jobs: if: always() run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true shell: bash - + - name: Assert no leakage from testing to hook env (1/2) + run: | + Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" + - name: Assert no leakage from testing to hook env (1/2) + env: + R_PRECOMMIT_HOOK_ENV: "1" + run: | + Rscript -e "if ('someP' %in% rownames(installed.packages())) stop('environment isolation not working: You installed a package into the testing environment and it is available in the hook environment')" - name: Upload check results if: failure() uses: actions/upload-artifact@main From 583c1b472ae507aca0a16418b26d9ba158eb943c Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:57:04 +0100 Subject: [PATCH 56/75] try deactivating renv, as it could mistakenly write infra --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index f03d5e9a8..11f973fc8 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -112,7 +112,7 @@ jobs: shell: bash - name: Assert no leakage from testing to hook env (1/2) run: | - Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" + Rscript -e "renv::deactivate(); renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" - name: Assert no leakage from testing to hook env (1/2) env: R_PRECOMMIT_HOOK_ENV: "1" From af6af5574a14d36ae39d43cb90fbacb475f48a47 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 18:59:18 +0100 Subject: [PATCH 57/75] fix title --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 11f973fc8..798bb5850 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -113,7 +113,7 @@ jobs: - name: Assert no leakage from testing to hook env (1/2) run: | Rscript -e "renv::deactivate(); renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" - - name: Assert no leakage from testing to hook env (1/2) + - name: Assert no leakage from testing to hook env (2/2) env: R_PRECOMMIT_HOOK_ENV: "1" run: | From e5baaee8f7357c2f4170a9ad0cd1f359d89b5117 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 19:02:11 +0100 Subject: [PATCH 58/75] use load, not activate, to prevent infrastructure writing --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 798bb5850..73b2625da 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -73,7 +73,7 @@ jobs: # needed to make sure renv is activated in run_test() activate <- c( "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_ENV')))", - paste0(" renv::activate('", getwd(), "')") + paste0(" renv::load('", getwd(), "')") ) writeLines(activate, '~/.Rprofile') shell: Rscript {0} From 5c3982bd6fa1a14a0e1db4e825f56b6953e3da6e Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 19:04:42 +0100 Subject: [PATCH 59/75] no need to deactivate when load was used --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 73b2625da..5ac20f9f2 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -112,7 +112,7 @@ jobs: shell: bash - name: Assert no leakage from testing to hook env (1/2) run: | - Rscript -e "renv::deactivate(); renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" + Rscript -e "renv::install('usethis'); path_pkg <- file.path(tempdir(), 'someP'); usethis::create_package(path_pkg); renv::install(path_pkg)" - name: Assert no leakage from testing to hook env (2/2) env: R_PRECOMMIT_HOOK_ENV: "1" From 5b446161aecd292e84b559cf3d1dfc42d8811e13 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 22:29:35 +0100 Subject: [PATCH 60/75] drop random space --- .github/workflows/hook-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hook-tests.yaml b/.github/workflows/hook-tests.yaml index 5ac20f9f2..bbd729110 100644 --- a/.github/workflows/hook-tests.yaml +++ b/.github/workflows/hook-tests.yaml @@ -73,7 +73,7 @@ jobs: # needed to make sure renv is activated in run_test() activate <- c( "if (nzchar(Sys.getenv('R_PRECOMMIT_HOOK_ENV')))", - paste0(" renv::load('", getwd(), "')") + paste0("renv::load('", getwd(), "')") ) writeLines(activate, '~/.Rprofile') shell: Rscript {0} From 60e93dd60dffad1c7aea867b9383640f1778fbf8 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 22:33:08 +0100 Subject: [PATCH 61/75] fix news --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 6375a8235..843036831 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,7 +17,8 @@ - {precommit} now uses [`language: r`](https://pre-commit.com/#r) instead of `language: script` from the [pre-commit framework](https://pre-commit.com). This requires `pre-commit >= 2.11.1`. All hooks and dependencies are now - contained in a virtual environment with [`{renv}`](https://rstudio.github.io/renv/). + contained in a virtual environment with [`{renv}`](https://rstudio.github.io/renv/) + (#233). **Minor changes** From 1881cc1a8f595f939c23ea3246c5feee0bf70058 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 22:33:36 +0100 Subject: [PATCH 62/75] move details out to testing vignette --- R/testing.R | 15 ++------------- vignettes/testing.Rmd | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 vignettes/testing.Rmd diff --git a/R/testing.R b/R/testing.R index 4fb2ca4b0..de0990f6d 100644 --- a/R/testing.R +++ b/R/testing.R @@ -1,7 +1,8 @@ #' Run a test #' #' Tests for the executables used as pre-commit hooks via `entrypoint` in -#' `.pre-commit-config.yaml`. +#' `.pre-commit-config.yaml`. Set's the env variable `R_PRECOMMIT_HOOK_ENV` to +#' when running. #' @details #' Two potential outcomes of a hooks are pass or fail. This is reflected on the #' level of the executable: Fail means the executable fails or the file is @@ -15,18 +16,6 @@ #' executable. To check for failed executable, we set `error_msg` to #' the message we expect. To check changed file content, we set `error_msg` to #' `NA`. -#' @section renv: -#' pre-commit >= 2.11.0 supports R as a language and each hook repo has its own -#' virtual environment with package versions locked. For that reason, we should -#' also test with exactly these versions. To avoid convolution of the testing -#' environment (that contains testthat and other packages) and the hook -#' environment (specified in `renv.lock`), we must only activate the hook -#' environment right when the script is called, but `run_test()` must run in the -#' testing environment. Since `--vanilla` is inherited in the child process -#' initiated from `run_test()`, the -#' only way to do this is to set an env variable when running `run_test()` and -#' check in the user R profile if it is set, and then activate the renv. This is -#' done with `R_PRECOMMIT_HOOK_ENV`. #' @param hook_name The name of the hook in `bin/`. #' @param file_name The file to test in `tests/in` (without extension). #' @param suffix The suffix of `file_name`. diff --git a/vignettes/testing.Rmd b/vignettes/testing.Rmd new file mode 100644 index 000000000..a161fb34d --- /dev/null +++ b/vignettes/testing.Rmd @@ -0,0 +1,38 @@ +--- +title: "testing" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{testing} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +pre-commit >= 2.11.0 supports R as a language and each hook repo has its own +virtual environment with package versions locked. For that reason, we should +also test with exactly these versions. + +This package has three testing worfklows: + +* hook testing. Tests the hooks (as well as hook script helpers?) in the renv in + which they'll be shipped. No R CMD Check or pre-commit executable needed. + All platforms. To avoid convolution of the testing environment + (that contains testthat and other packages) and the hook environment + (specified in `renv.lock`), we must only activate the hook environment right + when the script is called, but `run_test()` must run in the testing + environment. Since `--vanilla` is inherited in the child process initiated + from `run_test()`, the only way to do this is to set an env variable when + running `run_test()` and check in the user R profile if it is set, and then + activate the renv. This is done with `R_PRECOMMIT_HOOK_ENV`. + +* complete testing: Tests hooks as well as usethis like access functionality + with latest CRAN packges, on all platforms, with all installation methods. + +* CRAN testing. On CRAN, complete testing is ran, tests that check pre-commit + executable access are disabled. From 1e0197f1793c52d37e8799a95d51f2f355474b29 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Thu, 18 Mar 2021 22:34:09 +0100 Subject: [PATCH 63/75] Revert "temporarily disable R cmd check" This reverts commit 636d41fcdfa40c01cac873608af85f7d193ae013. --- .github/workflows/R-CMD-check.yaml | 131 +++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 .github/workflows/R-CMD-check.yaml diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 000000000..8fab229d4 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,131 @@ +# NOTE: This workflow is overkill for most R packages +# check-standard.yaml is likely a better choice +# usethis::use_github_action("check-standard") will install it. +# +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - master + pull_request: + branches: + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}, ${{ matrix.config.installation_method }}) + + strategy: + fail-fast: false + matrix: + config: + # macOS + - {os: macOS-latest, r: 'release', installation_method: 'brew'} + - {os: macOS-latest, r: 'release', installation_method: 'conda'} + - {os: macOS-latest, r: 'release', installation_method: 'pip'} + # Windows + - {os: windows-latest, r: 'release', installation_method: 'pip'} + - {os: windows-latest, r: 'release', installation_method: 'conda'} + # Linux + - {os: ubuntu-18.04, r: 'release', installation_method: 'pip', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: ubuntu-18.04, r: 'release', installation_method: 'conda', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } +# - {os: ubuntu-16.04, r: 'devel', installation_method: 'conda', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } +# - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} +# - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} +# - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} +# - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + PRECOMMIT_INSTALLATION_METHOD: ${{ matrix.config.installation_method }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + - name: Install system dependencies (Linux) + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') + + - name: Install system dependencies (brew) + if: matrix.config.installation_method == 'brew' + run: brew install pre-commit + - name: Install system dependencies (pip) + if: matrix.config.installation_method == 'pip' + run: | + pip3 install setuptools --user + pip3 install pre-commit --user + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + # installation methods other than conda don't need reticulate + if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') { + remove.packages('reticulate') + } + shell: Rscript {0} + - name: Install system dependencies (conda) + if: matrix.config.installation_method == 'conda' + run: | + reticulate::install_miniconda() + shell: Rscript {0} + - name: Session info + run: | + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_: false + run: | + if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') { + Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "False") + } + remotes::install_local() # circumvent https://github.com/r-lib/rcmdcheck/issues/136 + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check From 8bcac087a95755c8b7ec00199376cd882194ea97 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 6 Apr 2021 22:38:37 +0200 Subject: [PATCH 64/75] trigger new run --- .pre-commit-hooks.yaml | 1 + R/testing.R | 6 +++--- inst/pre-commit-hooks.yaml | 1 + man/run_test.Rd | 18 ++---------------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 01218ddd9..e216e2d97 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -4,6 +4,7 @@ entry: Rscript inst/bin/roxygenize language: r files: '^(R|man)/' + require_serial: true - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() diff --git a/R/testing.R b/R/testing.R index de0990f6d..d814995e6 100644 --- a/R/testing.R +++ b/R/testing.R @@ -1,8 +1,8 @@ #' Run a test #' #' Tests for the executables used as pre-commit hooks via `entrypoint` in -#' `.pre-commit-config.yaml`. Set's the env variable `R_PRECOMMIT_HOOK_ENV` to -#' when running. +#' `.pre-commit-config.yaml`. Set's the env variable `R_PRECOMMIT_HOOK_ENV` to +#' when running. #' @details #' Two potential outcomes of a hooks are pass or fail. This is reflected on the #' level of the executable: Fail means the executable fails or the file is @@ -88,7 +88,7 @@ run_test_impl <- function(path_executable, tempdir <- fs::dir_create(fs::file_temp()) if (!is.null(copy)) { if (is.null(names(copy))) { - # no names, take basename + # no names, take dirname new_dirs <- fs::path(tempdir, fs::path_dir(copy)) fs::dir_create(new_dirs) paths_copy <- fs::path(new_dirs, fs::path_file(copy)) diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index 01218ddd9..e216e2d97 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -4,6 +4,7 @@ entry: Rscript inst/bin/roxygenize language: r files: '^(R|man)/' + require_serial: true - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() diff --git a/man/run_test.Rd b/man/run_test.Rd index 01db6ba75..f8da6b20e 100644 --- a/man/run_test.Rd +++ b/man/run_test.Rd @@ -53,7 +53,8 @@ made.} } \description{ Tests for the executables used as pre-commit hooks via \code{entrypoint} in -\code{.pre-commit-config.yaml}. +\code{.pre-commit-config.yaml}. Set's the env variable \code{R_PRECOMMIT_HOOK_ENV} to +when running. } \details{ Two potential outcomes of a hooks are pass or fail. This is reflected on the @@ -69,19 +70,4 @@ the message we expect. To check changed file content, we set \code{error_msg} to \code{NA}. } } -\section{renv}{ - -pre-commit >= 2.11.0 supports R as a language and each hook repo has its own -virtual environment with package versions locked. For that reason, we should -also test with exactly these versions. To avoid convolution of the testing -environment (that contains testthat and other packages) and the hook -environment (specified in \code{renv.lock}), we must only activate the hook -environment right when the script is called, but \code{run_test()} must run in the -testing environment. Since \code{--vanilla} is inherited in the child process -initiated from \code{run_test()}, the -only way to do this is to set an env variable when running \code{run_test()} and -check in the user R profile if it is set, and then activate the renv. This is -done with \code{R_PRECOMMIT_HOOK_ENV}. -} - \keyword{internal} From f2318c8248beb4e48696cf34a3881280f966c2ea Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 6 Apr 2021 23:15:38 +0200 Subject: [PATCH 65/75] downgrade to see if warning occurs --- renv.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renv.lock b/renv.lock index 7321b8200..b080eebd8 100644 --- a/renv.lock +++ b/renv.lock @@ -1,6 +1,6 @@ { "R": { - "Version": "4.0.3", + "Version": "3.6.1", "Repositories": [ { "Name": "CRAN", From 829bbefb0d1b80421d2488a597482b5b860e464e Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 7 Apr 2021 08:08:50 +0200 Subject: [PATCH 66/75] run test --- .pre-commit-config.yaml | 2 +- R/testing.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89ac99375..74820e0b0 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_stages: ["commit"] repos: - repo: https://github.com/lorenzwalthert/precommit - rev: 9360d26cd440a40eac4d9f3dc8546457b42e52be + rev: 3fd792391a4997ee75d2df464621dc7511c97829 hooks: - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] diff --git a/R/testing.R b/R/testing.R index d814995e6..351213ceb 100644 --- a/R/testing.R +++ b/R/testing.R @@ -88,7 +88,7 @@ run_test_impl <- function(path_executable, tempdir <- fs::dir_create(fs::file_temp()) if (!is.null(copy)) { if (is.null(names(copy))) { - # no names, take dirname + # not namesm take directory name new_dirs <- fs::path(tempdir, fs::path_dir(copy)) fs::dir_create(new_dirs) paths_copy <- fs::path(new_dirs, fs::path_file(copy)) From 89e31b5f7e025645315ac161112f4fc6d0534573 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 9 Apr 2021 22:00:42 +0200 Subject: [PATCH 67/75] more doc notes --- vignettes/available-hooks.Rmd | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/vignettes/available-hooks.Rmd b/vignettes/available-hooks.Rmd index 8b602cbac..900421443 100644 --- a/vignettes/available-hooks.Rmd +++ b/vignettes/available-hooks.Rmd @@ -165,10 +165,21 @@ exists, the hook emits a warning which you can silence with args: [--no-warn-cache] ``` -Because the hook will write the version of `{roxygen2}` to `DESCRIPTON`, you -should either make sure the version you use when you call `{roxygen2}` -interactively matches the one +Because the hook will write the version of {roxygen2} to `DESCRIPTON`, you +should either make sure the version you use when you call {roxygen2} +interactively matches the one from in {precommit} or simply not run {roxygen2} +manually. +If you specify additional roclets through the `Roxygen:` field in `DESCRIPTION`, +e.g. from [{pkgapi}](https://github.com/r-lib/pkgapi) you must specify the +dependencies explicitly such that `renv::install()` understands it, e.g. + +``` + id: roxygenize + additional_dependencies: + - r-lib/pkgapi + +``` This hook does not modify input files, but writes to `.Rd` files in `man/`, `NAMESPACE` and potentially others depending on which roxygen roclets you @@ -212,8 +223,7 @@ should set this with the field `verbose: true`. When configured this way, lintr prints lint errors as they appear. Other arguments are not supported. Instead, `lintr` config should be specified in a `.lintr` config file in Debian Control Field Format as specified in the -[`.lintr` -documentation](https://github.com/jimhester/lintr#project-configuration). +[`.lintr` documentation](https://github.com/jimhester/lintr#project-configuration). This hook does not modify any file. From d3651e689cdf5692dd9770c99e6c9c95c7d238cf Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 9 Apr 2021 22:13:40 +0200 Subject: [PATCH 68/75] drop assumption test, hope people use latest version of desc --- tests/testthat/test-assumptions.R | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/testthat/test-assumptions.R b/tests/testthat/test-assumptions.R index cfe912634..e69de29bb 100644 --- a/tests/testthat/test-assumptions.R +++ b/tests/testthat/test-assumptions.R @@ -1,6 +0,0 @@ -test_that("documentation regarding desc is still accurate", { - skip_on_cran() - if (packageVersion("desc") >= 1.3 && Sys.Date() > as.Date("2021-04-01")) { - rlang::abort("newer version of desc on CRAN. Adapt the warning and maybe add minimal version requirement?") - } -}) From f3359fbf7dc788e2c130fd8765af19fc0427b64e Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 9 Apr 2021 22:43:11 +0200 Subject: [PATCH 69/75] when using R as language, we need minimal pre-commit version --- .pre-commit-hooks.yaml | 10 ++++++++++ inst/pre-commit-hooks.yaml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index e216e2d97..2abb31f86 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -5,12 +5,14 @@ language: r files: '^(R|man)/' require_serial: true + minimum_pre_commit_version: 2.11.1 - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() entry: Rscript inst/bin/use-tidy-description language: r files: '^DESCRIPTION$' + minimum_pre_commit_version: 2.11.1 - id: style-files name: style-files description: style files with styler @@ -18,30 +20,35 @@ language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' + minimum_pre_commit_version: 2.11.1 - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement entry: Rscript inst/bin/no-browser-statement language: r files: '\.[rR]$' + minimum_pre_commit_version: 2.11.1 - id: parsable-R name: parsable-R description: check if a .R file is parsable entry: Rscript inst/bin/parsable-R language: r files: '\.[rR]$' + minimum_pre_commit_version: 2.11.1 - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md entry: Rscript inst/bin/readme-rmd-rendered language: r files: 'README\.[Rr]?md$' + minimum_pre_commit_version: 2.11.1 - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. entry: Rscript inst/bin/codemeta-description-updated language: r files: '^DESCRIPTION$' + minimum_pre_commit_version: 2.11.1 - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() @@ -71,6 +78,7 @@ .*\.RData )$ require_serial: true + minimum_pre_commit_version: 2.11.1 - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. @@ -78,6 +86,7 @@ language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' + minimum_pre_commit_version: 2.11.1 - id: lintr name: lintr description: check if a .R file is lint free (using lintr) @@ -85,3 +94,4 @@ language: r files: '\.[rR]$' exclude: 'renv/activate\.R' + minimum_pre_commit_version: 2.11.1 \ No newline at end of file diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index e216e2d97..2abb31f86 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -5,12 +5,14 @@ language: r files: '^(R|man)/' require_serial: true + minimum_pre_commit_version: 2.11.1 - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() entry: Rscript inst/bin/use-tidy-description language: r files: '^DESCRIPTION$' + minimum_pre_commit_version: 2.11.1 - id: style-files name: style-files description: style files with styler @@ -18,30 +20,35 @@ language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' + minimum_pre_commit_version: 2.11.1 - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement entry: Rscript inst/bin/no-browser-statement language: r files: '\.[rR]$' + minimum_pre_commit_version: 2.11.1 - id: parsable-R name: parsable-R description: check if a .R file is parsable entry: Rscript inst/bin/parsable-R language: r files: '\.[rR]$' + minimum_pre_commit_version: 2.11.1 - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md entry: Rscript inst/bin/readme-rmd-rendered language: r files: 'README\.[Rr]?md$' + minimum_pre_commit_version: 2.11.1 - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. entry: Rscript inst/bin/codemeta-description-updated language: r files: '^DESCRIPTION$' + minimum_pre_commit_version: 2.11.1 - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() @@ -71,6 +78,7 @@ .*\.RData )$ require_serial: true + minimum_pre_commit_version: 2.11.1 - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. @@ -78,6 +86,7 @@ language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' + minimum_pre_commit_version: 2.11.1 - id: lintr name: lintr description: check if a .R file is lint free (using lintr) @@ -85,3 +94,4 @@ language: r files: '\.[rR]$' exclude: 'renv/activate\.R' + minimum_pre_commit_version: 2.11.1 \ No newline at end of file From 843a72cc36ddd5242feeb54a638132a4260738eb Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 10 Apr 2021 10:43:00 +0200 Subject: [PATCH 70/75] stricter min reqs --- .pre-commit-hooks.yaml | 20 ++++++++++---------- inst/pre-commit-hooks.yaml | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 2abb31f86..917b326d4 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -5,14 +5,14 @@ language: r files: '^(R|man)/' require_serial: true - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() entry: Rscript inst/bin/use-tidy-description language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: style-files name: style-files description: style files with styler @@ -20,35 +20,35 @@ language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement entry: Rscript inst/bin/no-browser-statement language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: parsable-R name: parsable-R description: check if a .R file is parsable entry: Rscript inst/bin/parsable-R language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md entry: Rscript inst/bin/readme-rmd-rendered language: r files: 'README\.[Rr]?md$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. entry: Rscript inst/bin/codemeta-description-updated language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() @@ -78,7 +78,7 @@ .*\.RData )$ require_serial: true - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. @@ -86,7 +86,7 @@ language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: lintr name: lintr description: check if a .R file is lint free (using lintr) @@ -94,4 +94,4 @@ language: r files: '\.[rR]$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.11.1 \ No newline at end of file + minimum_pre_commit_version: 2.12 diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index 2abb31f86..917b326d4 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -5,14 +5,14 @@ language: r files: '^(R|man)/' require_serial: true - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() entry: Rscript inst/bin/use-tidy-description language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: style-files name: style-files description: style files with styler @@ -20,35 +20,35 @@ language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement entry: Rscript inst/bin/no-browser-statement language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: parsable-R name: parsable-R description: check if a .R file is parsable entry: Rscript inst/bin/parsable-R language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md entry: Rscript inst/bin/readme-rmd-rendered language: r files: 'README\.[Rr]?md$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. entry: Rscript inst/bin/codemeta-description-updated language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() @@ -78,7 +78,7 @@ .*\.RData )$ require_serial: true - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. @@ -86,7 +86,7 @@ language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.11.1 + minimum_pre_commit_version: 2.12 - id: lintr name: lintr description: check if a .R file is lint free (using lintr) @@ -94,4 +94,4 @@ language: r files: '\.[rR]$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.11.1 \ No newline at end of file + minimum_pre_commit_version: 2.12 From 5260dffc98648200d59abe37f9fce6586f754820 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 10 Apr 2021 10:44:44 +0200 Subject: [PATCH 71/75] stricter min reqs --- .pre-commit-hooks.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 917b326d4..cdbddca21 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -5,14 +5,14 @@ language: r files: '^(R|man)/' require_serial: true - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() entry: Rscript inst/bin/use-tidy-description language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: style-files name: style-files description: style files with styler @@ -20,35 +20,35 @@ language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement entry: Rscript inst/bin/no-browser-statement language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: parsable-R name: parsable-R description: check if a .R file is parsable entry: Rscript inst/bin/parsable-R language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md entry: Rscript inst/bin/readme-rmd-rendered language: r files: 'README\.[Rr]?md$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. entry: Rscript inst/bin/codemeta-description-updated language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() @@ -78,7 +78,7 @@ .*\.RData )$ require_serial: true - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. @@ -86,7 +86,7 @@ language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: lintr name: lintr description: check if a .R file is lint free (using lintr) @@ -94,4 +94,4 @@ language: r files: '\.[rR]$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" From 5cdc3e7073380c81398dfee81002bd49c480fbd2 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 17 Apr 2021 11:09:26 +0200 Subject: [PATCH 72/75] the readme hook remains a scripted one --- .pre-commit-hooks.yaml | 4 ++-- inst/pre-commit-hooks.yaml | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index cdbddca21..6e69987bb 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -38,8 +38,8 @@ - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md - entry: Rscript inst/bin/readme-rmd-rendered - language: r + entry: inst/bin/readme-rmd-rendered + language: script files: 'README\.[Rr]?md$' minimum_pre_commit_version: "2.12" - id: codemeta-description-updated diff --git a/inst/pre-commit-hooks.yaml b/inst/pre-commit-hooks.yaml index 917b326d4..6e69987bb 100644 --- a/inst/pre-commit-hooks.yaml +++ b/inst/pre-commit-hooks.yaml @@ -5,14 +5,14 @@ language: r files: '^(R|man)/' require_serial: true - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: use-tidy-description name: use-tidy-description description: run usethis::use_tidy_description() entry: Rscript inst/bin/use-tidy-description language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: style-files name: style-files description: style files with styler @@ -20,35 +20,35 @@ language: r files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: no-browser-statement name: no-browser-statement description: check if a .R file contains a `browser()` statement entry: Rscript inst/bin/no-browser-statement language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: parsable-R name: parsable-R description: check if a .R file is parsable entry: Rscript inst/bin/parsable-R language: r files: '\.[rR]$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: readme-rmd-rendered name: readme-rmd-rendered description: make sure README.Rmd hasn't been edited more recently than README.md - entry: Rscript inst/bin/readme-rmd-rendered - language: r + entry: inst/bin/readme-rmd-rendered + language: script files: 'README\.[Rr]?md$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: codemeta-description-updated name: codemeta-description-updated description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description. entry: Rscript inst/bin/codemeta-description-updated language: r files: '^DESCRIPTION$' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: spell-check name: spell-check description: perform a spell check with spelling::spell_check_files() @@ -78,7 +78,7 @@ .*\.RData )$ require_serial: true - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: deps-in-desc name: deps-in-desc description: Check if dependencies that can be parsed from code are in DESCRIPTION. @@ -86,7 +86,7 @@ language: r files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" - id: lintr name: lintr description: check if a .R file is lint free (using lintr) @@ -94,4 +94,4 @@ language: r files: '\.[rR]$' exclude: 'renv/activate\.R' - minimum_pre_commit_version: 2.12 + minimum_pre_commit_version: "2.12" From fd9d2b01e8c561bedbfe12c59f77cf70270cdd27 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 23 Apr 2021 19:00:19 +0200 Subject: [PATCH 73/75] newer R, styler --- renv.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/renv.lock b/renv.lock index b080eebd8..90d4c4eae 100644 --- a/renv.lock +++ b/renv.lock @@ -1,6 +1,6 @@ { "R": { - "Version": "3.6.1", + "Version": "4.0.3", "Repositories": [ { "Name": "CRAN", @@ -539,15 +539,10 @@ }, "styler": { "Package": "styler", - "Version": "1.3.2.9000", - "Source": "GitHub", - "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "styler", - "RemoteUsername": "r-lib", - "RemoteRef": "HEAD", - "RemoteSha": "5957df1748de5bf8585705aad0c82534f54e014b", - "Hash": "a945cac2e09910ca7ace9bd21667524c" + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2ec6308547ffe73208cef3ef3766fc33" }, "sys": { "Package": "sys", From 3a3475a057a63846731bb69411c32099140892d2 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 27 Apr 2021 17:33:50 +0200 Subject: [PATCH 74/75] update packages --- .pre-commit-config.yaml | 8 ++- renv.lock | 128 ++++++++++++++++++++-------------------- renv/activate.R | 99 ++++++++++++++++--------------- 3 files changed, 119 insertions(+), 116 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74820e0b0..bb4035eed 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,11 +3,15 @@ default_stages: ["commit"] repos: - repo: https://github.com/lorenzwalthert/precommit - rev: 3fd792391a4997ee75d2df464621dc7511c97829 + rev: acc8657498d5bfb9e9891098ba00b36e82c7ebd6 hooks: - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] - exclude: '^tests/testthat/in/.*\.R' + exclude: > + (?x)^( + tests/testthat/in/.*\.R| + renv/.* + )$ - id: roxygenize # codemeta must be above use-tidy-description when both are used # - id: codemeta-description-updated diff --git a/renv.lock b/renv.lock index 90d4c4eae..2fb36fdb8 100644 --- a/renv.lock +++ b/renv.lock @@ -65,13 +65,6 @@ "Repository": "CRAN", "Hash": "e8a22846fff485f0be3770c2da758713" }, - "assertthat": { - "Package": "assertthat", - "Version": "0.2.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "50c838a310445e954bc13f26f26a6ecf" - }, "backports": { "Package": "backports", "Version": "1.2.1", @@ -95,24 +88,24 @@ }, "brio": { "Package": "brio", - "Version": "1.1.1", + "Version": "1.1.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "36758510e65a457efeefa50e1e7f0576" + "Hash": "2f01e16ff9571fe70381c7b9ae560dc4" }, "callr": { "Package": "callr", - "Version": "3.5.1", + "Version": "3.7.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "b7d7f1e926dfcd57c74ce93f5c048e80" + "Hash": "461aa75a11ce2400245190ef5d3995df" }, "cli": { "Package": "cli", - "Version": "2.3.1", + "Version": "2.5.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "3e3f28efcadfda442cd18651fbcbbecf" + "Hash": "a94ba44cee3ea571e813721e64184172" }, "clipr": { "Package": "clipr", @@ -135,6 +128,13 @@ "Repository": "CRAN", "Hash": "0f22be39ec1d141fd03683c06f3a6e67" }, + "cpp11": { + "Package": "cpp11", + "Version": "0.2.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "730eebcc741a5c36761f7d4d0f5e37b8" + }, "crayon": { "Package": "crayon", "Version": "1.4.1", @@ -172,10 +172,10 @@ }, "diffobj": { "Package": "diffobj", - "Version": "0.3.3", + "Version": "0.3.4", "Source": "Repository", "Repository": "CRAN", - "Hash": "55fae7ec1418d2a47bd552571673d1af" + "Hash": "feb5b7455eba422a2c110bb89852e6a3" }, "digest": { "Package": "digest", @@ -226,17 +226,17 @@ }, "gert": { "Package": "gert", - "Version": "1.2.0", + "Version": "1.3.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "dcbfac00cf60125f43791a135ef68285" + "Hash": "56f398846cd40937be6b435a66bd3f37" }, "gh": { "Package": "gh", - "Version": "1.2.0", + "Version": "1.2.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "05129b4387282404780d2f8593636388" + "Hash": "346cc58165d33da095c7e67487ec6bca" }, "git2r": { "Package": "git2r", @@ -268,10 +268,10 @@ }, "highr": { "Package": "highr", - "Version": "0.8", + "Version": "0.9", "Source": "Repository", "Repository": "CRAN", - "Hash": "4dc5bb88961e347a0f4d8aad597cbfac" + "Hash": "8eb36c8125038e648e5d111c0d7b2ed4" }, "htmltools": { "Package": "htmltools", @@ -310,10 +310,10 @@ }, "knitr": { "Package": "knitr", - "Version": "1.31", + "Version": "1.33", "Source": "Repository", "Repository": "CRAN", - "Hash": "c3994c036d19fc22c5e2a209c8298bfb" + "Hash": "0bc1b5da1b0eb07cd4b727e95e9ff0b8" }, "lattice": { "Package": "lattice", @@ -373,17 +373,10 @@ }, "pillar": { "Package": "pillar", - "Version": "1.5.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "24622aa4a0d3de3463c34513edca99b2" - }, - "pkgbuild": { - "Package": "pkgbuild", - "Version": "1.2.0", + "Version": "1.6.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "725fcc30222d4d11ec68efb8ff11a9af" + "Hash": "a8c755912ae31910ba6a5d42f5526b6b" }, "pkgconfig": { "Package": "pkgconfig", @@ -394,10 +387,17 @@ }, "pkgload": { "Package": "pkgload", - "Version": "1.2.0", + "Version": "1.2.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "cb57de933545960a86f03513e4bd2911" + "Hash": "463642747f81879e6752485aefb831cf" + }, + "png": { + "Package": "png", + "Version": "0.1-7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "03b7076c234cb3331288919983326c55" }, "praise": { "Package": "praise", @@ -406,19 +406,12 @@ "Repository": "CRAN", "Hash": "a555924add98c99d2f411e37e7d25e9f" }, - "prettyunits": { - "Package": "prettyunits", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" - }, "processx": { "Package": "processx", - "Version": "3.4.5", + "Version": "3.5.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "22aab6098cb14edd0a5973a8438b569b" + "Hash": "5ee87b05936a4aa9d8d026eb1a51314b" }, "ps": { "Package": "ps", @@ -450,24 +443,24 @@ }, "remotes": { "Package": "remotes", - "Version": "2.2.0", + "Version": "2.3.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "430a0908aee75b1fcba0e62857cab0ce" + "Hash": "92ea77818b3bb83c699008451af32b86" }, "renv": { "Package": "renv", - "Version": "0.13.0", + "Version": "0.13.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "9f10d9db5b50400c348920c5c603385e" + "Hash": "079cb1f03ff972b30401ed05623cbe92" }, "reticulate": { "Package": "reticulate", - "Version": "1.18", + "Version": "1.19", "Source": "Repository", "Repository": "CRAN", - "Hash": "fbd35cac6ae7554d0e4f440bca1adf3a" + "Hash": "a793719f1b17126b503feef01ce63410" }, "rex": { "Package": "rex", @@ -495,12 +488,12 @@ "Version": "7.1.1.9001", "Source": "GitHub", "RemoteType": "github", - "RemoteHost": "api.github.com", - "RemoteRepo": "roxygen2", "RemoteUsername": "r-lib", + "RemoteRepo": "roxygen2", "RemoteRef": "HEAD", - "RemoteSha": "6c1e42f061e9435a14bd3a0e01c7f08fc7aa9160", - "Hash": "ab1efef67b07177d14c8100ce43c75d6" + "RemoteSha": "23261728c184743ec2ab4322f5c6cb6f42bd4865", + "RemoteHost": "api.github.com", + "Hash": "796272644c17da61395c0977c0840cf6" }, "rprojroot": { "Package": "rprojroot", @@ -539,10 +532,15 @@ }, "styler": { "Package": "styler", - "Version": "1.4.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "2ec6308547ffe73208cef3ef3766fc33" + "Version": "1.4.1.9001", + "Source": "GitHub", + "RemoteType": "github", + "RemoteUsername": "r-lib", + "RemoteRepo": "styler", + "RemoteRef": "HEAD", + "RemoteSha": "4250d57bd638e745dd7a09aee8cf49064d672a40", + "RemoteHost": "api.github.com", + "Hash": "c19fb6d7c036e4b733594db58061420c" }, "sys": { "Package": "sys", @@ -560,17 +558,17 @@ }, "tibble": { "Package": "tibble", - "Version": "3.1.0", + "Version": "3.1.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "4d894a114dbd4ecafeda5074e7c538e6" + "Hash": "fbbca141541ee9242233ba50b0fcb843" }, "tinytex": { "Package": "tinytex", - "Version": "0.30", + "Version": "0.31", "Source": "Repository", "Repository": "CRAN", - "Hash": "066f49a225dc3215cb1f32bc23535f88" + "Hash": "25b572f764f3c19fef9aac33b5724f3d" }, "usethis": { "Package": "usethis", @@ -588,10 +586,10 @@ }, "vctrs": { "Package": "vctrs", - "Version": "0.3.6", + "Version": "0.3.7", "Source": "Repository", "Repository": "CRAN", - "Hash": "5cf1957f93076c19fdc81d01409d240b" + "Hash": "5540dc30a203a43a1ce5dc6a89532b3b" }, "waldo": { "Package": "waldo", @@ -609,10 +607,10 @@ }, "withr": { "Package": "withr", - "Version": "2.4.1", + "Version": "2.4.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "caf4781c674ffa549a4676d2d77b13cc" + "Hash": "ad03909b44677f930fa156d47d7a3aeb" }, "xfun": { "Package": "xfun", diff --git a/renv/activate.R b/renv/activate.R index 2cba08a4c..b852628d0 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,7 +2,7 @@ local({ # the requested version of renv - version <- "0.13.0" + version <- "0.13.2" # the project directory project <- getwd() @@ -70,7 +70,10 @@ local({ repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" + repos[repos == "@CRAN@"] <- getOption( + "renv.repos.cran", + "https://cloud.r-project.org" + ) # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -134,77 +137,75 @@ local({ renv_bootstrap_download_cran_latest <- function(version) { - repos <- renv_bootstrap_download_cran_latest_find(version) + spec <- renv_bootstrap_download_cran_latest_find(version) message("* Downloading renv ", version, " ... ", appendLF = FALSE) - downloader <- function(type) { - - tryCatch( - utils::download.packages( - pkgs = "renv", - destdir = tempdir(), - repos = repos, - type = type, - quiet = TRUE - ), - condition = identity - ) - - } - - # first, try downloading a binary on Windows + macOS if appropriate - binary <- - !identical(.Platform$pkgType, "source") && - !identical(getOption("pkgType"), "source") && - Sys.info()[["sysname"]] %in% c("Darwin", "Windows") - - if (binary) { - info <- downloader(type = "binary") - if (!inherits(info, "condition")) { - message("OK (downloaded binary)") - return(info[1, 2]) - } - } + type <- spec$type + repos <- spec$repos + + info <- tryCatch( + utils::download.packages( + pkgs = "renv", + destdir = tempdir(), + repos = repos, + type = type, + quiet = TRUE + ), + condition = identity + ) - # otherwise, try downloading a source tarball - info <- downloader(type = "source") if (inherits(info, "condition")) { message("FAILED") return(FALSE) } # report success and return - message("OK (downloaded source)") + message("OK (downloaded ", type, ")") info[1, 2] } renv_bootstrap_download_cran_latest_find <- function(version) { - all <- renv_bootstrap_repos() + # check whether binaries are supported on this system + binary <- + getOption("renv.bootstrap.binary", default = TRUE) && + !identical(.Platform$pkgType, "source") && + !identical(getOption("pkgType"), "source") && + Sys.info()[["sysname"]] %in% c("Darwin", "Windows") - for (repos in all) { + types <- c(if (binary) "binary", "source") - db <- tryCatch( - as.data.frame( - x = utils::available.packages(repos = repos), - stringsAsFactors = FALSE - ), - error = identity - ) + # iterate over types + repositories + for (type in types) { + for (repos in renv_bootstrap_repos()) { - if (inherits(db, "error")) - next + # retrieve package database + db <- tryCatch( + as.data.frame( + utils::available.packages(type = type, repos = repos), + stringsAsFactors = FALSE + ), + error = identity + ) - entry <- db[db$Package %in% "renv" & db$Version %in% version, ] - if (nrow(entry) == 0) - next + if (inherits(db, "error")) + next - return(repos) + # check for compatible entry + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) + next + + # found it; return spec to caller + spec <- list(entry = entry, type = type, repos = repos) + return(spec) + } } + # if we got here, we failed to find renv fmt <- "renv %s is not available from your declared package repositories" stop(sprintf(fmt, version)) From eae3959ff64f9a1ddc8b3bf8257ad3224bc30d34 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 4 May 2021 14:59:30 +0200 Subject: [PATCH 75/75] remove Type as we can rely on new definition criterion --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f800b7725..3b43f61db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,3 @@ -Type: Package Package: precommit Title: Pre-Commit Hooks Version: 0.1.3.9000