-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GitHub cpp-linter-action #20
Conversation
wgtmac
commented
Dec 27, 2024
•
edited
Loading
edited
Oops, my bad. I just copied pre-commit.yml and edited the wrong file. Now it is fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, and I think it is worth a try 🙌
Hmm, in that screenshot, 'memory not found' seems like a spurious error? Will this be noisy? |
I have also noticed that. I need to learn more about its configuration and improve it gradually. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add it and see if it's helpful. If we find too many spurious errors we can try to fine tune it or remove it if not helpful.
Maybe we want to add extra-args: '-std=c++20 -Wall'
?
https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#extra-args
Co-authored-by: Raúl Cumplido <[email protected]>
https://github.com/apache/iceberg-cpp/actions/runs/12544655200 cpp-linter/[email protected] is not allowed to be used in apache/iceberg-cpp. |
Thanks for trying! |
api/iceberg/table.h
Outdated
@@ -20,15 +20,24 @@ | |||
#pragma once | |||
|
|||
#include <memory> | |||
#include <string_view> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raulcd It seems that this issue still exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been able to reproduce the memory error locally:
$ clang-tidy-18 -p ../iceberg-cpp -checks=file --format-style file ../iceberg-cpp/api/iceberg/table.h --extra-arg=-std=c++17 --enable-module-headers-parsing
Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "../iceberg-cpp"
No compilation database found in /home/raulcd/code/arrow/../iceberg-cpp or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
/home/raulcd/code/arrow/.clang-tidy:30:1: error: unknown key 'AnalyzeTemporaryDtors'
AnalyzeTemporaryDtors: true
^~~~~~~~~~~~~~~~~~~~~
Error parsing /home/raulcd/code/arrow/.clang-tidy: Invalid argument
/home/raulcd/code/arrow/.clang-tidy:30:1: error: unknown key 'AnalyzeTemporaryDtors'
AnalyzeTemporaryDtors: true
^~~~~~~~~~~~~~~~~~~~~
Error parsing /home/raulcd/code/arrow/.clang-tidy: Invalid argument
/home/raulcd/code/arrow/.clang-tidy:30:1: error: unknown key 'AnalyzeTemporaryDtors'
AnalyzeTemporaryDtors: true
^~~~~~~~~~~~~~~~~~~~~
Error parsing /home/raulcd/code/arrow/.clang-tidy: Invalid argument
/home/raulcd/code/arrow/.clang-tidy:30:1: error: unknown key 'AnalyzeTemporaryDtors'
AnalyzeTemporaryDtors: true
^~~~~~~~~~~~~~~~~~~~~
Error parsing /home/raulcd/code/arrow/.clang-tidy: Invalid argument
2 errors generated.
Error while processing /home/raulcd/code/arrow/../iceberg-cpp/api/iceberg/table.h.
error: invalid argument '-std=c++17' not allowed with 'C' [clang-diagnostic-error]
/home/raulcd/code/arrow/../iceberg-cpp/api/iceberg/table.h:22:10: error: 'memory' file not found [clang-diagnostic-error]
22 | #include <memory>
| ^~~~~~~~
Found compiler error(s).
We might need to generate a compilation database first and use the database attribute: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#database. It seems like it is detecting as if it's a C project by default without it.
If I build and use the build folder with -p
it is successful:
$ clang-tidy-18 -p /home/raulcd/code/iceberg-cpp/build -checks=file --format-style file ../api/iceberg/table.h --extra-arg=-std=c++17 --enable-module-headers-parsing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have inserted a build step before the cpp-linter to create the compile_commands.json. Now it seems working.
It appears either the token doesn't have comment permissions or the token isn't being passed into the action |
I have added permission for
|
The token still says only read permissions https://github.com/apache/iceberg-cpp/actions/runs/12554533849/job/35003344629?pr=20#step:1:17 |
It seems since the PR comes from a fork, Github will never let you get anything but read access. https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token I think you'd either have to somehow make this work with |
Note that pull_request_target (1) only runs from the base branch, not the PR and (2) doesn't check out the PR HEAD (it gets the base branch) so it's not suitable for this by default. (You can manually check out the PR HEAD but it gets easy to have accidental vulnerabilities this way) |
Thanks @lidavidm for providing the detail! After reading relevant documentation, I agree that it is really tricky to workaround the token permission. Without comments on PR, the cpp-linter action seems not that useful because we already have the pre-commit check to do similar things. Is it possible to elevate permission on a specific token? @Fokko |
I think it's a security issue: the pre-commit only runs clang-format, not clang-tidy - I think it'd still be useful even without the PR comment? |
That makes sense! Let me enable it for now. We can improve or discard it after we have experience with more PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @wgtmac for this. This changes look nice to me, I will merge it to unblock the future developement.