[llvm] [GitHub][CI] Add clang-tidy premerge workflow (PR #154829)
Baranov Victor via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 23 13:24:54 PDT 2025
================
@@ -0,0 +1,345 @@
+#!/usr/bin/env python3
+#
+# ====- clang-tidy-helper, runs clang-tidy from the ci --*- python -*-------==#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+# ==-------------------------------------------------------------------------==#
+
+import argparse
+import os
+import subprocess
+import sys
+from typing import List, Optional
+
+"""
+This script is run by GitHub actions to ensure that the code in PR's conform to
+the coding style of LLVM. The canonical source of this script is in the LLVM
+source tree under llvm/utils/git.
+
+You can learn more about the LLVM coding style on llvm.org:
+https://llvm.org/docs/CodingStandards.html
+"""
+
+
+class LintArgs:
+ start_rev: str = None
+ end_rev: str = None
+ repo: str = None
+ changed_files: List[str] = []
+ token: str = None
+ verbose: bool = True
+ issue_number: int = 0
+ build_path: str = "build"
+ clang_tidy_binary: str = "clang-tidy"
+
+ def __init__(self, args: argparse.Namespace = None) -> None:
+ if not args is None:
+ self.start_rev = args.start_rev
+ self.end_rev = args.end_rev
+ self.repo = args.repo
+ self.token = args.token
+ self.changed_files = args.changed_files
+ self.issue_number = args.issue_number
+ self.verbose = args.verbose
+ self.build_path = args.build_path
+ self.clang_tidy_binary = args.clang_tidy_binary
+
+
+COMMENT_TAG = "<!--LLVM CODE LINT COMMENT: clang-tidy-->"
+
+
+def get_instructions(cpp_files: List[str]) -> str:
+ files_str = " ".join(cpp_files)
+ return f"""
+git diff -U0 origin/main..HEAD -- {files_str} |
----------------
vbvictor wrote:
I don't quite get when two-dot will lead to errors and three won't ([docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-comparing-branches-in-pull-requests#three-dot-and-two-dot-git-diff-comparisons)) speaking it terms of LLVM PR's.
Since GitHub shows 3-dot diff, I'd better use too.
https://github.com/llvm/llvm-project/pull/154829
More information about the llvm-commits
mailing list