You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2026/01/07 05:17:49 UTC
[PR] ci: add clang-tidy to pre-commit and CI lint job [tvm-ffi]
guan404ming opened a new pull request, #389:
URL: https://github.com/apache/tvm-ffi/pull/389
## Why
PR CI passed but main CI failed after merge because clang-tidy only ran on main branch (in ci_mainline_only.yml), not on PRs.
## How
- Add `clang-tidy` hook to `pre-commit` config using existing clang_tidy_precommit.py script
- Add uv setup to CI lint job so the hook can run in CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3722570320
Seems like a good idea!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3721891121
Thanks for the context. Just to add some context from my side: I think main CI is slow mainly because it runs clang-tidy on all files, while here we only check the modified ones. Curious to hear your thoughts on whether this trade-off would be acceptable. Thanks!
<img width="1522" height="309" alt="image" src="https://github.com/user-attachments/assets/fbb965fb-97a9-4ebd-aa96-e07bbd98f21f" />
(run for 1 file modified)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to pre-commit and CI lint job [tvm-ffi]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3717355282
## Summary of Changes
Hello @guan404ming, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request aims to enhance the continuous integration pipeline by proactively catching `clang-tidy` issues during the pull request phase rather than after merging to the main branch. By integrating `clang-tidy` into the `pre-commit` configuration and updating the CI lint job to support its execution, the change ensures that C/C++ code adheres to quality standards earlier in the development cycle, thereby preventing unexpected CI failures and maintaining a stable main branch.
### Highlights
* **Pre-commit Hook Integration**: Integrated `clang-tidy` as a `pre-commit` hook, ensuring C/C++ code is linted before commits are finalized.
* **CI Lint Job Enhancement**: Configured the CI lint job to utilize `uv` for running the `clang-tidy` pre-commit script, ensuring consistent linting across PRs and the main branch.
* **Preventing CI Failures**: Addressed the issue where `clang-tidy` failures were only caught on the main branch, leading to post-merge CI breaks, by shifting checks to PRs.
🧠**New Feature in Public Preview:** You can now enable **Memory** to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
<details>
<summary><b>Ignored Files</b></summary>
* **Ignored by pattern:** `.github/workflows/**` (1)
* .github/workflows/ci_test.yml
</details>
<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>
The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
<b>Invoking Gemini</b>
You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help | `/gemini help` | Displays a list of available commands.
<b>Customization</b>
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
<b>Limitations & Feedback</b>
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
<b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>
</details>
[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao merged PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3721799902
Thanks for bringing up this PR! We used to consider clang-tidy in PRs, but turns out it runs too long, and thus moved it to mainline only. Therefore, we may not want to do so unfortunately
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#discussion_r2671494442
##########
.github/workflows/ci_test.yml:
##########
@@ -45,6 +47,13 @@ jobs:
github_event_name: ${{ github.event_name }}
pr_base_ref: ${{ github.event.pull_request.base.ref || '' }}
pr_head_sha: ${{ github.event.pull_request.head.sha || '' }}
+ - name: Get changed C++ files
+ id: cpp_files
+ run: |
+ FILES=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}...HEAD -- \
+ '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hpp' '*.hxx' | tr '\n' ' ')
Review Comment:
Sure, I've removed it. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to pre-commit and CI lint job [tvm-ffi]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#discussion_r2667101402
##########
.pre-commit-config.yaml:
##########
@@ -85,6 +85,14 @@ repos:
rev: "v21.1.7"
hooks:
- id: clang-format
+ - repo: local
+ hooks:
+ - id: clang-tidy
+ name: clang-tidy
+ entry: uv run --no-project --with "clang-tidy==21.1.1" python tests/lint/clang_tidy_precommit.py --build-dir=build-pre-commit
Review Comment:

I've noticed a couple of potential improvements for the `entry` command:
1. **Invalid package version**: The version `21.1.1` for the `clang-tidy` PyPI package appears to be incorrect, as this version is not available on PyPI. This will cause the hook installation to fail. I've suggested using a recent valid version, `18.1.8`, but you should confirm which version is most appropriate for your project, ideally aligning it with the `clang-format` version.
2. **Redundant argument**: The `--build-dir=build-pre-commit` argument is redundant. The `tests/lint/clang_tidy_precommit.py` script already uses `build-pre-commit` as the default value for this argument. Removing it makes the configuration cleaner.
```yaml
entry: uv run --no-project --with "clang-tidy==18.1.8" python tests/lint/clang_tidy_precommit.py
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3718139358
I tested this by making random modifications to a C++ file and confirmed that it works.
Reference: https://github.com/apache/tvm-ffi/actions/runs/20777613039/job/59667160177
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3721408447
we deliberately deferred it for now to reduce immediate feedback overhead, while we need some posthoc fixes, it works ok for our cases so far
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#issuecomment-3727261018
> I don't fully understand some of the logics but it seems right. Very happy to get it in and worry about it later if we got into problems :D
Thanks. Let's see what happen lol, I could handle it in the future if needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] ci: add clang-tidy to ci_test [tvm-ffi]
Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #389:
URL: https://github.com/apache/tvm-ffi/pull/389#discussion_r2671307916
##########
.github/workflows/ci_test.yml:
##########
@@ -45,6 +47,13 @@ jobs:
github_event_name: ${{ github.event_name }}
pr_base_ref: ${{ github.event.pull_request.base.ref || '' }}
pr_head_sha: ${{ github.event.pull_request.head.sha || '' }}
+ - name: Get changed C++ files
+ id: cpp_files
+ run: |
+ FILES=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}...HEAD -- \
+ '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hpp' '*.hxx' | tr '\n' ' ')
Review Comment:
We should probably skip header files, because there’s no compilation database generated for headers
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org