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

Baranov Victor via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 13:01:10 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
----------------
vbvictor wrote:

I encountered this issue https://github.com/actions/setup-python/issues/719 ([failed job](https://github.com/llvm/llvm-project/actions/runs/17219088852/job/48849878270?pr=154223)) when setting-up cache and had to make an additional step to clear cache as suggested in https://github.com/actions/setup-python/issues/719#issuecomment-2416175995.
Though I'm not sure if it is faster now with this "cache" because it seems to not hit it:

```console
/github/home/.cache/pip
Warning: Cache not found for keys: setup-python-Linux-x64-24.04-Ubuntu-python-3.12.11-pip-b84011bb1b4c3dda5db6077e3ae4801fe89a59fba019274c0e9482276b9306f3, setup-python-Linux-x64-24.04-Ubuntu-python-3.12.11-pip
pip cache is not found
```

I'd remove this part, WDYT? Maybe there is some misconfiguration that I did, but I copied it from `formatting-job`

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


More information about the llvm-commits mailing list