Skip to content

Introduce helpers for static analysis Gitlab CI jobs

Daniel Vrátil requested to merge dvratil/ci-tooling:static-analyzer into master

This change adds a new GitLab CI job template called ".static-analysis", that will build the project and will run clazy and clang-tidy on it. When the job is ran on a merge request, the static analyzers are only executed on C++ files that have changed compared to the merge request target branch (which speeds things up considerably). When executed on arbitrary commit, it will perform check on all files in the repo.

The way it works is that

  1. The entire project is compiled as usual (using clang)
  2. The branch base commit (where the branch has diverged from the target branch) is identified
  3. Files that have changed between the base commit and HEAD of the source branch are identified
  4. Clazy and clang-tidy are executed on all changed files (parallelism is supported)
  5. A codequality report is generated, so the failed checks are shown as failed test in the merge request on GitLab

See this .gitlab-ci.yml file for reference how easily the static analysis job can then be added to an arbitrary project, and see this job to see how the failed checks are reported.

Edited by Daniel Vrátil

Merge request reports