[llvm] [GitHub][CI] Add clang-tidy premerge workflow (PR #154829)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 23 12:16:32 PDT 2025


================
@@ -0,0 +1,126 @@
+name: "Code lint"
+
+permissions:
+  contents: read
+
+on:
+  pull_request:
+    branches:
+      - main
+      - 'users/**'
+    paths:
+      - 'clang-tools-extra/clang-tidy/**'
+
+jobs:
+  code_linter:
+    if: github.repository_owner == 'llvm'
+    runs-on: ubuntu-24.04
+    defaults:
+      run:
+        shell: bash
+    container:
+      image: 'ghcr.io/llvm/ci-ubuntu-24.04:latest'
+    timeout-minutes: 60
+    concurrency:
+      group: ${{ github.workflow }}-${{ github.ref }}
+      cancel-in-progress: true
+    steps:
+      - name: Fetch LLVM sources
+        uses: actions/checkout at b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+        with:
+          fetch-depth: 2
+      
+      - name: Get changed files
+        id: changed-files
+        uses: step-security/changed-files at 3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
+        with:
+          separator: ","
+          skip_initial_fetch: true
+          base_sha: 'HEAD~1'
+          sha: 'HEAD'
+      
+      - name: Listed files
+        env:
+          CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
+        run: |
+          echo "Changed files:"
+          echo "$CHANGED_FILES"
+      
+      - name: Fetch code linting utils
+        uses: actions/checkout at 08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
+        with:
+          repository: ${{ github.repository }}
+          ref: ${{ github.base_ref }}
+          sparse-checkout: |
+            llvm/utils/git/code-lint-helper.py
+            llvm/utils/git/requirements_linting.txt
+            clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+          sparse-checkout-cone-mode: false
+          path: code-lint-tools
+      
+      - uses: actions/setup-python at v5
+        id: setup_python
+        with:
+          python-version: '3.12'
+      
+      - name: Install dependencies
+        run: |
+          python3 -m venv .venv
+          source .venv/bin/activate
+          python3 -m pip install -r code-lint-tools/llvm/utils/git/requirements_linting.txt
+      
+      - name: Install clang-tidy
+        uses: aminya/setup-cpp at 17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
+        with:
+          clang-tidy: 20.1.8
+      
+      # FIXME: create special mapping for 'gen' targets, for now build predefined set
+      - name: Configure and CodeGen
+        run: |
+          git config --global --add safe.directory '*'
+
+          source <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)
----------------
boomanaiden154 wrote:

I'm not sure `compute_projects.py` is the right thing to use here. It also adds projects that depend on the code touched which is not what I think you want here. It's probably fine for now though given it will just result in some extra CMake configuration time.

The proper fix I think would involve refactoring `compute_projects.py` into a library and adding another entrypoint that only adds a project and its direct dependencies. That can be left for a future PR.

https://github.com/llvm/llvm-project/pull/154829


More information about the llvm-commits mailing list