Skip to content

[GLUTEN-11027][VL][CI] Add clang-tidy to check cpp code#11120

Merged
PHILO-HE merged 2 commits intoapache:mainfrom
xinghuayu007:my/clang_tidy
Jan 13, 2026
Merged

[GLUTEN-11027][VL][CI] Add clang-tidy to check cpp code#11120
PHILO-HE merged 2 commits intoapache:mainfrom
xinghuayu007:my/clang_tidy

Conversation

@xinghuayu007
Copy link
Contributor

@xinghuayu007 xinghuayu007 commented Nov 19, 2025

What changes are proposed in this pull request?

How was this patch tested?

Related issue: #11027

@xinghuayu007 xinghuayu007 changed the title Add clang-tidy to check cpp code [GLUTEN-11027]Add clang-tidy to check cpp code Nov 19, 2025
@xinghuayu007 xinghuayu007 force-pushed the my/clang_tidy branch 3 times, most recently from ccac8e8 to 2d5f9ff Compare November 19, 2025 06:28
@PHILO-HE PHILO-HE changed the title [GLUTEN-11027]Add clang-tidy to check cpp code [GLUTEN-11027] Add clang-tidy to check cpp code Nov 19, 2025
@xinghuayu007 xinghuayu007 force-pushed the my/clang_tidy branch 22 times, most recently from fde7a6a to 84e345b Compare November 24, 2025 06:49
@zhouyuan
Copy link
Member

@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 clang-format here, is there a gap in this existing tool?
https://github.com/apache/incubator-gluten/blob/main/.github/workflows/code_format.yml

@xinghuayu007
Copy link
Contributor Author

@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 clang-format here, is there a gap in this existing tool? https://github.com/apache/incubator-gluten/blob/main/.github/workflows/code_format.yml

@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.

Copy link
Member

@PHILO-HE PHILO-HE left a comment

Choose a reason for hiding this comment

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

Sorry for delayed response. Some comments. Please confirm if they make sense. Thanks.

cd /work
export CCACHE_DIR=/work/.ccache
mkdir -p /work/.ccache
bash dev/ci-velox-buildstatic-centos-7.sh
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good ideal.

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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`

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

@xinghuayu007 xinghuayu007 Dec 26, 2025

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

@xinghuayu007, you can choose another version verified by GitHub Marketplace, e.g., v46.

https://github.com/marketplace/actions/changed-files

Copy link
Member

Choose a reason for hiding this comment

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

Maybe, we have to switch to use dorny/paths-filter, which is allowed by Apache infrastructure.

https://github.com/apache/infrastructure-actions/blob/b18408d79fe0ee2d3aedef6032b59aaf68ec87ca/actions.yml#L304

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@PHILO-HE PHILO-HE changed the title [GLUTEN-11027] Add clang-tidy to check cpp code [GLUTEN-11027][CI] Add clang-tidy to check cpp code Dec 24, 2025
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
Copy link
Member

Choose a reason for hiding this comment

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

if cpp/build/compile_commands.json is required could we add this to some existing job?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean all jobs in CI/CD generates 'cpp/build/compile_commands.json'?

@xinghuayu007 xinghuayu007 force-pushed the my/clang_tidy branch 17 times, most recently from b5e8843 to 842fc01 Compare December 26, 2025 10:27
Copy link
Member

@PHILO-HE PHILO-HE left a comment

Choose a reason for hiding this comment

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

Some comments. Thanks.


on:
workflow_run:
workflows: ["Velox Backend (x86)"]
Copy link
Member

Choose a reason for hiding this comment

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

With workflow_run, it seems this new workflow will be triggered after merged to main branch.

@PHILO-HE
Copy link
Member

@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.

@xinghuayu007
Copy link
Contributor Author

@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.

Copy link
Member

@PHILO-HE PHILO-HE left a comment

Choose a reason for hiding this comment

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

Looks good. cc @zhouyuan

@baibaichen
Copy link
Contributor

This PR did not run Spark 41 unit tests and is now breaking the CI. I will fix it in #11380

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.

4 participants