feat(ci): add Clang-tidy to Sheldon
Description
This MR will add Clang-tidy as a new hook for Sheldon, as well as providing the hooks to be run on the command line thanks to a new option.
As opposed to what was written in the design, we can't generate the compilation database in a temporary build directory, this is because the resulting compilation database will then contain references to the deleted directory, which will then make Clang-tidy unhappy (this is mostly because of files generated by CMake: eg cppunit_main.cpp, config.hpp, etc...).
Closes #63 (closed)
How to test it?
Run the hook, Clang-tidy should run and report warnings in the format(s) specified in clang-tidy-hook.report-modes
. If sheldon is run in fix mode, the fix are correctly applied when available.
As for the compilation database auto-generation:
- If
clang-tidy-hook.build-path
isn't set and there is nocompile_commands.json
at the repository root, the hook always fails. - If
clang-tidy-hook.build-path
is set andclang-tidy-hook.generate-compilation-db
is set towhen_absent
, the generation happens only ifcompile_commands.json
is absent from provided directory, and it generates without failure. - If
clang-tidy-hook.build-path
is set andclang-tidy-hook.generate-compilation-db
is set toalways
, the generation happens whethercompile_commands.json
is present or not, and it generates without failure. - If
clang-tidy-hook.build-path
is set andclang-tidy-hook.generate-compilation-db
is set tonever
, the hooks fails if the provided directory doesn't containcompile_commands.json
. - If
clang-tidy-hook.generate-compilation-db
contains anything else thanalways
,when_absent
ornever
, the hook fails.
Additional tests/tasks to run
Adapt the CI so as to run sheldon instead of Clang-tidy directly (see https://git.ircad.fr/sight/sight-gitlab/-/merge_requests/26).