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 five testing workflows:
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 packages, on all platforms, with all installation methods.
CRAN testing. On CRAN, complete testing is ran, tests that check pre-commit executable access are disabled.
end-2-end testing: This simulates closely what happens when you run
git commit
with pre-commit activated: We update the
.pre-commit-config.yaml
to the pushed SHA and run
pre-commit run
, covering all hooks, to ensure in particular file
linking, file permissions etc. in .pre-commit-hooks.yaml
are
correct for exported hooks.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.