Skip to content

feat(ci): add Clang-tidy to Sheldon

Lucas SCHMIDT requested to merge 63-feat-ci-add-clang-tidy-to-sheldon into dev

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 no compile_commands.json at the repository root, the hook always fails.
  • If clang-tidy-hook.build-path is set and clang-tidy-hook.generate-compilation-db is set to when_absent, the generation happens only if compile_commands.json is absent from provided directory, and it generates without failure.
  • If clang-tidy-hook.build-path is set and clang-tidy-hook.generate-compilation-db is set to always, the generation happens whether compile_commands.json is present or not, and it generates without failure.
  • If clang-tidy-hook.build-path is set and clang-tidy-hook.generate-compilation-db is set to never, the hooks fails if the provided directory doesn't contain compile_commands.json.
  • If clang-tidy-hook.generate-compilation-db contains anything else than always, when_absent or never, 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).

Edited by Lucas SCHMIDT

Merge request reports