| # Copyright 2026 The IREE Authors |
| # |
| # Licensed 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 |
| |
| # This workflow uses the newest clang-tidy binary built from source after the |
| # latest integrate. This way we get the newest checks (incl., llvm-specific |
| # ones). |
| |
| name: Clang Tidy |
| |
| on: |
| pull_request: |
| paths: |
| - '**.h' |
| - '**.c' |
| - '**.cpp' |
| - '.clang-tidy' |
| - '.github/workflows/clang_tidy.yml' |
| |
| permissions: |
| contents: write |
| pull-requests: write |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
| cancel-in-progress: true |
| |
| jobs: |
| clang-tidy: |
| runs-on: ubuntu-24.04 |
| container: |
| image: ghcr.io/iree-org/cpubuilder_ubuntu_jammy@sha256:78a558b999b230f7e1da376639e14b44f095f30f1777d6a272ba48c0bbdd4ccb |
| defaults: |
| run: |
| shell: bash |
| env: |
| BUILD_DIR: build |
| steps: |
| - name: Check out repository |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| submodules: false |
| fetch-depth: 0 |
| |
| - name: Initialize submodules |
| run: | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| git submodule update --init --depth=1 |
| |
| - name: Download iree-clang-tidy artifact |
| uses: dawidd6/action-download-artifact@5c98f0b039f36ef966fdb7dfa9779262785ecb05 # v14 |
| with: |
| workflow: build_clang_tidy.yml |
| name: iree-clang-tidy-linux-x86_64 |
| path: .iree-clang-tidy |
| |
| - name: Setup iree-clang-tidy |
| run: | |
| # Make executable (artifact download doesn't preserve permissions). |
| chmod +x .iree-clang-tidy/clang-tidy |
| echo "Using clang-tidy from llvm-project revision:" |
| cat .iree-clang-tidy/llvm-project-revision.txt |
| .iree-clang-tidy/clang-tidy --version |
| |
| - name: Install Python requirements |
| run: | |
| # Use uv instead of plain pip since cpp-linter uses it anyway. |
| curl -LsSf https://astral.sh/uv/install.sh | sh |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| export PATH="$HOME/.local/bin:$PATH" |
| uv pip install --system -r ./runtime/bindings/python/iree/runtime/build_requirements.txt |
| uv pip install --system -r ./build_tools/github_actions/ci_requirements.txt |
| |
| - name: Generate compilation database (compile_commands.json) |
| run: | |
| IREE_CONFIGURE_ONLY=1 ./build_tools/cmake/build_all.sh "${BUILD_DIR}" |
| |
| - name: Run clang-tidy |
| uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v1.11.4 |
| id: linter |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| with: |
| version: .iree-clang-tidy |
| style: '' # Disable clang-format (already handled by pre-commit). |
| tidy-checks: '' # Use .clang-tidy config files. |
| database: ${{ env.BUILD_DIR }} |
| files-changed-only: true |
| lines-changed-only: diff |
| ignore: 'third_party' |
| thread-comments: false |
| step-summary: true |