Closed bdice closed 3 years ago
pre-commit (and by extension) pre-commit.ci works best when it manages your tools. language: system
is the escape hatch for manual management and is not supported for pre-commit.ci at the current time.
installing global tools inside the container goes against the intent that a user should not need to set up anything to run the tools. ideally there'd be a first-class supported way to run clang-format
via one of the currently supported languages (an example for a workaround (pre-commit doesn't directly support haskell at the moment) is https://github.com/shellcheck-py/shellcheck-py -- this wraps the shellcheck
binary in a tiny python package which downloads a prebuilt binary.
There's also some work that's being done to make download a language
that might interest you: https://github.com/pre-commit/pre-commit/issues/1453
additionally there's planned paid-tier extensions that would allow something like this: https://github.com/pre-commit-ci/issues/issues/13 (it would likely be a fixed set of system tools that could be added on to the running image)
(moving this issue since I noticed it's in the wrong place)
the other thing you can do today if you don't want to split up your configuration files is to utilize ci: skip
for now
I appreciate the info and links! We'll probably keep the separate configs for now, since we want local pre-commit hooks to skip clang-format as well (only want to run it manually through the second config on developer systems with clang-format, or on our CI image with clang-format installed). I'll close this issue since my questions have been answered, and thank you for your time. 👍
Hi! I'm interested in adding clang-format to the container used for pre-commit. However, it's possible that there is a better solution to my problem, so I want to give a little more info about the challenge I'm facing in hopes of finding a simpler approach. If there isn't a better way, then I would like to make a PR to add clang-format to this container.
I work on a couple Python/C++ projects. We use pre-commit for all the Python hooks, but our C++ hooks are harder to install (e.g. clang-format). While there are several hooks for clang-format, all of those hooks require clang-format to be installed on the system (they're
local
hooks and there's not a way to install clang-format in a virtual environment that I've seen). For now, we've been splitting our hooks into two files that run on our CI:I'd like to be able to use pre-commit.ci to automatically apply clang-format. If pre-commit.ci had clang-format available in the container, I could combine the two config files and just let it run on CI (without worrying about whether users have clang-format installed locally, since their PRs can be auto-fixed). Ideally there would be a way that users could execute the Python/general hooks locally and skip the C++ hooks if they don't have the right tools installed. Any advice would be welcome! Thanks for your amazing work on pre-commit and the CI service. Hoping to tune into a live stream sometime soon. 😄