Hello fellow pulp developers,
I wanna propose that the Pulp Project start using the pre-commit tool by default on the plugin_template as the runner for static checks. If you are interested in the topic, please read through and vote and/or comment your thoughts.
My motivations are:
- consistency: same command for CI and dev-env that manages all setup and execution realiably. The config file pins on git revisions.
- extensability: its pretty easy to add new checks, either custom made (scripts, dockerfiles) or available by tools themselves. Here is some custom scripts in Godot engine. It could lower the bar for hardening our checks (e.g, docs, security, …).
- ecosystem: pre-commit supports installing tools from other language ecosystems (again, without developer having to setup those manually). Here is a curated list of hooks
Proposal
- plugin’s CI must use pre-commit (but still can opt-out of specific checks, as of today).
- developer can use pre-commit locally
-
lint_requirement.txtis not kept
I’m proposing (3) to avoid having to support multiple ways of doing the same thing, but it’s doable and I can understand developer workflow is a very personal thing.
After reading through, please vote on what you disagree with:
- None (LGTM)
- 1 - CI must use it
- 2 - Developer can use it
- 3 -
lint_requirements.txtis not kept
0 voters
Workflows
For those who are not familiar, here are some possible workflows from the developer point of view, assuming that its being used in CI.
Installing can be done via dnf, apt, pip, uv or whatever, it’s widely available.
As runner
You don’t have to install the git hooks. Its possible to use it as a runner:
# in the first run, setup hook tooling and cache it, then run the hooks
$ pre-commit run -a # run all hooks on all files
$ pre-commit run lint -a # run only the lint hook
$ pre-commit run format -a # run only the format hook
As git-hooks
Install the git hooks themselves, which triggers the checks uppon commit, push, etc.
I don’t usually use that myself, but I’m considering trying the pre-push.
$ pre-commit install
Proof of Concept
I’ve created an experimental PR on pulpcore that replaces every step of the lint workflow with pre-commit hooks, either from popular tools or just using our internal scripting.
Here is how it looks:
