Takishima / cmake-pre-commit-hooks

List of hooks for pre-commit to use with projects built using CMake. The hooks will automatically make a configure step using CMake in order to generate the compilation database if required.
Apache License 2.0
24 stars 1 forks source link

cppcheck and iwyu not installed #41

Closed flagarde closed 1 year ago

flagarde commented 2 years ago

Very nice hooks, It save a lot of work and configuration.

It seems the hooks cppcheck and iwyu cannot be run in pre-commit.ci because the corresponding programs are missing.

I seems possible to install micromamba,conda https://pypi.org/project/ensureconda/ using pip and then use micromamba to download this programs.

I tried to work on this but my knowledge and pre-commit hooks and even python is quite limited :(

Takishima commented 2 years ago

Happy that you find these few hooks useful 😁

I am not particularly a fan of installing a local conda environment and then installing cppcheck or iwyu within it... I could see this potentially creating issues with different conda environment clashing if the users are already using conda somewhere else or in the same project (though I am not a conda user myself, so I might be wrong here).

But if you manage to convince me that such issues (like PATH modifications, adding local conda environment etc.)` are ok, then I wouldn't mind helping you implement this.

LecrisUT commented 1 year ago

Note that some distros do not have iwyu, e.g. Fedora.

Takishima commented 1 year ago

In those cases, you can skip the hooks when running pre-commit by specifying the SKIP environment variable.

For example:

SKIP=include-what-you-use pre-commit run --all-files
LecrisUT commented 1 year ago

I was giving a situation where it would be helpful to bundle iwyu. Ideally though, these should be handled in the upstream distros.

flagarde commented 1 year ago

@Takishima It seems you can use different environments without clashing. My first idea was to be able to run those on github action so it would be less crashy than on personal computer.

LecrisUT commented 1 year ago

As a workaround, the action could be run on ubuntu or debian (seems only those package iwyu according to pkgs.org) and install it manually. But I agree with @flagarde, that would be a cleaner approach.

flagarde commented 1 year ago

@LecrisUT is what I will do but this make running twice pre-commit. One on precommit.ci (with iwyu and cppcheck desactivated) and then one in a dedicated github action