Skip to content

fix: clang-tidy lint step fails when no csrc files change - #6049

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/lint-clang-tidy-lint-step-fails-when-no
Open

fix: clang-tidy lint step fails when no csrc files change#6049
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/lint-clang-tidy-lint-step-fails-when-no

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in .github/workflows/lint.yml: clang-tidy lint step fails when no csrc files change.

Changes

  • .github/workflows/lint.yml: clang-tidy lint step fails when no csrc files change.

Details

--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -1,1 +1,4 @@
-          git --no-pager diff --diff-filter=d --name-only $head_commit | grep -e "csrc/.*\.cpp" -e "csrc/.*\.h" | xargs lintrunner --take CLANGTIDY --force-color
+          files=$(git --no-pager diff --diff-filter=d --name-only $head_commit | grep -e "csrc/.*\.cpp" -e "csrc/.*\.h" || true)
+          if [ -n "$files" ]; then
+            echo "$files" | xargs -r lintrunner --take CLANGTIDY --force-color
+          fi

Tests

  • tests/test_repo_config.py
diff --git a/tests/test_repo_config.py b/tests/test_repo_config.py
new file mode 100644
--- /dev/null
+++ b/tests/test_repo_config.py
@@ -0,0 +1,39 @@
+import unittest
+from pathlib import Path
+
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+
+
+class TestGitignore(unittest.TestCase):
+    def test_nvfuser_common_lib_ignored(self):
+        gitignore = (REPO_ROOT / ".gitignore").read_text()
+        self.assertIn("nvfuser_common/lib", gitignore)
+        self.assertNotIn("nvfuser_comon/lib", gitignore)
+
+
+class TestLintWorkflow(unittest.TestCase):
+    def test_clang_tidy_step_handles_empty_file_list(self):
+        workflow = (REPO_ROOT / ".github" / "workflows" / "lint.yml").read_text()
+        self.assertIn('if [ -n "$files" ]', workflow)
+        self.assertIn("xargs -r", workflow)
+        self.assertNotIn(
+            'git --no-pager diff --diff-filter=d --name-only $head_commit | grep -e "csrc/.*\.cpp" -e "csrc/.*\.h" | xargs lintrunner --take CLANGTIDY --force-color',
+            workflow,
+        )
+
+
+if __name__ == "__main__":
+    unittest.main()

Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR prevents the clang-tidy workflow from invoking lintrunner when no matching C/C++ files changed.

  • Captures matching paths before invoking lintrunner.
  • Skips invocation for an empty file list.
  • Adds GNU xargs' no-run-if-empty option as an additional safeguard.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking concern that file-discovery errors can now be silently treated as an empty diff.

The empty-input failure is fixed, but the broad error suppression can allow clang-tidy to be skipped when changed-file discovery itself fails.

Files Needing Attention: .github/workflows/lint.yml

Important Files Changed

Filename Overview
.github/workflows/lint.yml Correctly avoids an empty lintrunner invocation, but broadly suppresses failures from the changed-file discovery pipeline.

Reviews (1): Last reviewed commit: "fix: clang-tidy lint step fails when no ..." | Re-trigger Greptile

# diff-filter for lower case letter:
# https://github.com/git/git/commit/7f2ea5f0f2fb056314092cce23202096ca70f076
git --no-pager diff --diff-filter=d --name-only $head_commit | grep -e "csrc/.*\.cpp" -e "csrc/.*\.h" | xargs lintrunner --take CLANGTIDY --force-color
files=$(git --no-pager diff --diff-filter=d --name-only $head_commit | grep -e "csrc/.*\.cpp" -e "csrc/.*\.h" || true)

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.

P2 Broad pipeline error suppression

The trailing || true treats every file-discovery failure as an empty result, so an unavailable revision or repository read error skips clang-tidy and lets the step succeed instead of exposing the underlying failure.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant