When initializing pre-commit in your repo with
precommit::use_precommit(), you can specify the Continuous
integration provider with
ci = "native" if you want to use
ci = "gha" if you want to use GitHub Actions. For existing
Pre-commit will run the hooks on all files, so instead of pushing, waiting and fixing issues locally, we recommend that you fix all problems before pushing by invoking pre-commit (roughly) the same way as it happens in the CI, which is described in the next section.
In the CI run, a command roughly equivalent to the following will be ran from the command line:
pre-commit run --all-files
If you get an error and
pre-commit is not on your
$PATH (e.g. because you installed with
precommit::install_precommit()), you can locate the
executable from R with
::path_pre_commit_exec() precommit#> "/usr/local/bin/pre-commit"
And run the command in your bash terminal like this:
/usr/local/bin/pre-commit run --all-files
Then fix the problems, stage the files and re-try until the command succeeds without more errors.
Next, we quickly introduce the two options. We recommend pre-commit.ci, but you might have to skip the roxygenize hook in the ci run under certain circumstances as explained below.
You need to authenticate the pre-commit.ci App in GitHub.
Limitations for the roxygenize hook:
id: roxygenize. You can generate the required code with
precommit::snippet_generate('additional-deps-roxygenize'). This is also required to run the hook locally.
To overcome the above limitations, you can:
ci: skip: [roxygenize]
Please see the documentation of pre-commit.ci on whether or not to auto-fix problems as well as other configuration options.