[GLUTEN-11027][VL][CI] Add clang-tidy to check cpp code#11120
[GLUTEN-11027][VL][CI] Add clang-tidy to check cpp code#11120PHILO-HE merged 2 commits intoapache:mainfrom
Conversation
ccac8e8 to
2d5f9ff
Compare
fde7a6a to
84e345b
Compare
|
@xinghuayu007 @PHILO-HE based on the issue description, the target here is to check the CPP code format? We already have a format checker with |
@zhouyuan , there are different. 'clang-format' focuses solely on code appearance and layout, like automatically adjusts indentation, line breaks, spacing, brace positioning, alignment, etc. 'clang-tidy' focuses on code quality, logic, and potential errors, like checks for potential bugs, suggests using more modern C++ features. |
PHILO-HE
left a comment
There was a problem hiding this comment.
Sorry for delayed response. Some comments. Please confirm if they make sense. Thanks.
.github/workflows/cpp_clang_tidy.yml
Outdated
| cd /work | ||
| export CCACHE_DIR=/work/.ccache | ||
| mkdir -p /work/.ccache | ||
| bash dev/ci-velox-buildstatic-centos-7.sh |
There was a problem hiding this comment.
It seems redundant to run the build for native code. Maybe, we can use the following action to reuse the binary produced in the main workflow. Please verify it.
- name: Download artifact from in-progress workflow
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: velox_backend_x86.yml
name: velox-native-lib-centos-7-${{ github.sha }}
commit: ${{ github.sha }}
workflow_conclusion: ""
check_artifacts: true
search_artifacts: true
if_no_artifact_found: warn
There was a problem hiding this comment.
If dawidd6/action-download-artifact requires that the base workflow must complete, I think it is acceptable, since our goal is to apply the clang tidy check and the time by clang tidy may not be too much if only the files changed by PR are checked.
Also note an existing workflow is using this action.
https://github.com/apache/incubator-gluten/blob/4feac9bba366e032c7ad50fccc603d6fe3c29f8f/.github/workflows/test_report.yml#L34
There was a problem hiding this comment.
It is possible to run 'clang tidy check' workflow after the completion of the whole 'Velox Backend (x86)' workflow to reuse the cache of 'build-native-lib-centos-7'. But I face another problem, that there can not exist two trigger on the workflow 'clang tidy check' like the follow:
`name: Clang Tidy Check
on:
pull_request:
paths:
- '.github/workflows/cpp_clang_tidy.yml'
- 'cpp//*.cc'
- 'cpp//*.h'
workflow_run:
workflows: ["Velox Backend (x86)"]
types:
- completed`
There was a problem hiding this comment.
Then, we may have to add a check step to determine if this clang-tidy workflow needs to be skipped. Please confirm it. Thanks.
- name: Check for specific path changes
id: filter
uses: tj-actions/changed-files@v45
with:
files: |
cpp/**/*.cc
cpp/**/*.h
- name: Download artifact
# Only run this step if the files we care about were changed
if: steps.filter.outputs.any_changed == 'true'
uses: dawidd6/action-download-artifact@v3
xxxx
See the link for tj-actions/changed-files: https://github.com/tj-actions/changed-files
There was a problem hiding this comment.
I found another problem: https://github.com/apache/incubator-gluten/actions/runs/20520437287
The action tj-actions/changed-files@v45 is not allowed in apache/incubator-gluten because all actions must be from a repository owned by your enterprise
I will use another method to implement this action.
There was a problem hiding this comment.
@xinghuayu007, you can choose another version verified by GitHub Marketplace, e.g., v46.
There was a problem hiding this comment.
Maybe, we have to switch to use dorny/paths-filter, which is allowed by Apache infrastructure.
| dnf install clang-tools-extra -y | ||
| clang-tidy --version | ||
| ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5 | ||
| sed -i "s|/work|$(pwd)|g" cpp/build/compile_commands.json |
There was a problem hiding this comment.
if cpp/build/compile_commands.json is required could we add this to some existing job?
There was a problem hiding this comment.
You mean all jobs in CI/CD generates 'cpp/build/compile_commands.json'?
b5e8843 to
842fc01
Compare
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Velox Backend (x86)"] |
There was a problem hiding this comment.
With workflow_run, it seems this new workflow will be triggered after merged to main branch.
|
@xinghuayu007, is this PR ready? I assume we can merge this first version, then create a follow-up PR to see if it works, and fix possible issues there. |
It is ready. Please merge it. |
|
This PR did not run Spark 41 unit tests and is now breaking the CI. I will fix it in #11380 |
What changes are proposed in this pull request?
How was this patch tested?
Related issue: #11027