[clang-tools-extra] [llvm] [TEST][WIP] Run clang-format inside ci-container (PR #160193)

Baranov Victor via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 15:06:19 PDT 2025


https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/160193

>From 7fd440924682ed2e88580563e1128b93f182a379 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Thu, 9 Oct 2025 01:01:33 +0300
Subject: [PATCH 1/2] add codestyle violation

---
 clang-tools-extra/clang-tidy/ClangTidy.cpp | 3 +--
 llvm/utils/git/code-lint-helper.py         | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 7e18f3806a143..385c7adc6e0c2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -270,8 +270,7 @@ class ErrorReporter {
                  const llvm::StringMap<Replacements> &Fix) {
     for (const auto &FileAndReplacements : Fix) {
       for (const auto &Repl : FileAndReplacements.second) {
-        if (!Repl.isApplicable())
-          continue;
+        if (!Repl.isApplicable()) continue;
         FileByteRange FBR;
         FBR.FilePath = Repl.getFilePath().str();
         FBR.FileOffset = Repl.getOffset();
diff --git a/llvm/utils/git/code-lint-helper.py b/llvm/utils/git/code-lint-helper.py
index 1232f3ab0d370..ccd4ecd29c61e 100755
--- a/llvm/utils/git/code-lint-helper.py
+++ b/llvm/utils/git/code-lint-helper.py
@@ -206,10 +206,8 @@ def run_clang_tidy(changed_files: List[str], args: LintArgs) -> Optional[str]:
     proc = subprocess.run(
         tidy_diff_cmd,
         input=diff_content,
-        stdout=subprocess.PIPE,
-        stderr=subprocess.PIPE,
-        text=True,
-        check=False,
+                stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+        text=True, check=False,
     )
 
     return clean_clang_tidy_output(proc.stdout.strip())

>From f5900e2f7ca5f71eed19c57f8ae14aea26c8dfcf Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Thu, 9 Oct 2025 01:06:05 +0300
Subject: [PATCH 2/2] add formatting job

---
 .github/workflows/pr-code-format.yml | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 1e0dc7045c1cc..c446aba9dda9f 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -12,6 +12,8 @@ on:
 jobs:
   code_formatter:
     runs-on: ubuntu-24.04
+    container:
+      image: 'ghcr.io/llvm/ci-ubuntu-24.04-format:latest'
     timeout-minutes: 30
     concurrency:
       group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
@@ -39,24 +41,6 @@ jobs:
           echo "Formatting files:"
           echo "$CHANGED_FILES"
 
-      # The clang format version should always be upgraded to the first version
-      # of a release cycle (x.1.0) or the last version of a release cycle, or
-      # if there have been relevant clang-format backports.
-      - name: Install clang-format
-        uses: aminya/setup-cpp at a276e6e3d1db9160db5edc458e99a30d3b109949 # v1.7.1
-        with:
-          clangformat: 21.1.0
-
-      - name: Setup Python env
-        uses: actions/setup-python at a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
-        with:
-          python-version: '3.13'
-          cache: 'pip'
-          cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
-
-      - name: Install python dependencies
-        run: pip install -r llvm/utils/git/requirements_formatting.txt
-
       - name: Run code formatter
         env:
           GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}



More information about the llvm-commits mailing list