Skip to content

Add clang-tidy reviews to CI #1407

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 12, 2023
Merged

Add clang-tidy reviews to CI #1407

merged 1 commit into from
May 12, 2023

Conversation

slaren
Copy link
Member

@slaren slaren commented May 11, 2023

Adds clang-tidy static analyzer and linter checks to pull requests.

The failed checks are reported in the PR in a comment, see these for some examples:
slaren#11
slaren#12 (here it finds a bug in the command line parsing of benchmark-matmult.cpp)

I tried to remove some of the most pedantic checks, but there are still a lot of failed checks in the current code that should be addressed over time. However, the workflow action will only report the checks failed in the lines modified by the PR, so the current issues will not be blamed on new PRs (unless they happen to be in the lines modified by the PR).

To test the settings in .clang-tidy locally:

  • Configure cmake with -DCMAKE_EXPORT_COMPILE_COMMANDS=on
  • Run clang-tidy with the cmake build path in -p and the source file, for example:
    clang-tidy -p build llama.cpp

Note that since this adds comments to the PRs, it requires adding write permissions to the workflows in the project settings.

Copy link
Member

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should already have the write permission:

image

@Green-Sky
Copy link
Collaborator

I wanted to ask if it uses clang-tidy-diff, but the change suggestions look fine too.

@slaren
Copy link
Member Author

slaren commented May 11, 2023

It doesn't use clang-tidy-diff, but essentially it does the same, it checks what lines were modified and passes a -line-filter argument to clang-tidy. This is the action that I am using: https://github.com/marketplace/actions/clang-tidy-review

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants