Skip to content

CI: Add clangd-tidy hook for pre-commit#118162

Draft
Repiteo wants to merge 1 commit intogodotengine:masterfrom
Repiteo:ci/pre-commit-clangd-tidy
Draft

CI: Add clangd-tidy hook for pre-commit#118162
Repiteo wants to merge 1 commit intogodotengine:masterfrom
Repiteo:ci/pre-commit-clangd-tidy

Conversation

@Repiteo
Copy link
Copy Markdown
Contributor

@Repiteo Repiteo commented Apr 3, 2026

Implements clangd-tidy as a proper pre-commit hook, making the tool more readily accessible for all users. This required reworking the pre-commit action into our own implementation, which is arguably for the best as that action has been unsupported for years now & is the main source of false-positive warnings in CI output

However: despite being fully-functional, I'm hesitant to implement this as-is. As there's no way to enforce compile_commands.json, nor is there a reliable way to exclude platform-specific files, the hook stage is still "manual". To make this into a readily-accessible hook, I believe that we'd have to either make upstream changes to clangd-tidy or produce our own wrapper script to achieve our desired results. Having said that, I'm setting this up as-is in order to verify that the pre-commit action functions as expected, which will get a dedicated PR if so

Copy link
Copy Markdown
Contributor

@StarryWorm StarryWorm left a comment

Choose a reason for hiding this comment

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

I personally like this approach of implementing our own customizable pre-commit action.

Regarding the clangd-tidy changes required to make this work, what are you thinking of?
I could put a fork together that has what we want (including --fix)
Ownership would be passed to Godot once ready

Comment thread .pre-commit-config.yaml
@@ -79,6 +79,18 @@ repos:

- repo: local
hooks:
# Not automatically triggered (because it requires compile_commands.json to be up-to-date).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be possible for our now hand-made pre-commit action to run scons compiledb_gen_only to update the compiledb forcefully, thus enabling this stage as automatic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like where your head's at, but it's unfortunately unsuitable for a pre-commit hook because of how long that takes even in isolation. What we might be able to do is a wrapper script which either skips or fails the hook if that file isn't present... Will play around with that today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants