Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GHA] Move clang-tidy check to a code_style workflow (#30379)

Egor Duplenskii1f00a4714a7c
diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag
index 21335ee9034..5a5e6d64d56 100644
--- a/.github/dockerfiles/docker_tag
+++ b/.github/dockerfiles/docker_tag
@@ -1 +1 @@
-pr-29921
+pr-30379
diff --git a/.github/dockerfiles/ov_build/ubuntu_22_04_x64_cc/Dockerfile b/.github/dockerfiles/ov_build/ubuntu_22_04_x64_cc/Dockerfile
index d53bed4e492..dea3e8c2625 100644
--- a/.github/dockerfiles/ov_build/ubuntu_22_04_x64_cc/Dockerfile
+++ b/.github/dockerfiles/ov_build/ubuntu_22_04_x64_cc/Dockerfile
@@ -13,10 +13,8 @@ ENV DEBIAN_FRONTEND="noninteractive" \
TZ="Europe/London"
RUN apt-get update && \
- apt-get install software-properties-common wget && \
+ apt-get install software-properties-common && \
add-apt-repository --yes --no-update ppa:git-core/ppa && \
- add-apt-repository --yes --no-update "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" && \
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/llvm.asc && \
add-apt-repository --yes --no-update ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install \
@@ -38,11 +36,7 @@ RUN apt-get update && \
# For Java API
default-jdk \
# Compiler \
- clang-18 \
- # Static analyzer
- clang-tidy-18 \
- # clang-tidy uses clang-format as a dependency
- clang-format-18 \
+ clang \
&& \
rm -rf /var/lib/apt/lists/*
@@ -53,8 +47,8 @@ RUN chmod +x /install_build_dependencies.sh && \
rm -rf /var/lib/apt/lists/*
# Set clang as a default compiler
-RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang-18 100 && \
- update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-18 100
+RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
+ update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
# Install sscache
ARG SCCACHE_VERSION="v0.7.5"
@@ -68,10 +62,11 @@ RUN mkdir ${SCCACHE_HOME} && cd ${SCCACHE_HOME} && \
# Setup pip
ENV PIP_VERSION="24.0"
-RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
- python3.8 get-pip.py --no-cache-dir pip==${PIP_VERSION} && \
+RUN curl https://bootstrap.pypa.io/pip/3.8/get-pip.py -o get-pip-3.8.py && \
+ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
+ python3.8 get-pip-3.8.py --no-cache-dir pip==${PIP_VERSION} && \
python3.11 get-pip.py --no-cache-dir pip==${PIP_VERSION} && \
- rm -f get-pip.py
+ rm -f get-pip-3.8.py get-pip.py
# Use Python 3.11 as default instead of Python 3.8
# Using venv here 'cause other methods to switch the default Python on Ubuntu 20 break both system and wheels build
diff --git a/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile b/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile
index 4ee5e2ce68d..30f9b9792bc 100644
--- a/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile
+++ b/.github/dockerfiles/ov_build/ubuntu_24_04_x64/Dockerfile
@@ -44,6 +44,9 @@ RUN apt-get update && \
python3-full \
# For Java API
default-jdk \
+ # For clang-tidy validation
+ clang-format-18 \
+ clang-tidy-18 \
&& \
rm -rf /var/lib/apt/lists/*
diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml
new file mode 100644
index 00000000000..4f3fbc5f05b
--- /dev/null
+++ b/.github/workflows/clang_tidy.yml
@@ -0,0 +1,157 @@
+name: Clang-tidy static analysis (Ubuntu 24.04, Python 3.12, Clang-18, Clang-tidy-18)
+on:
+ workflow_dispatch:
+ pull_request:
+ merge_group:
+ push:
+ branches:
+ - master
+ - 'releases/**'
+
+concurrency:
+ # github.ref is not unique in post-commit
+ group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-clang-tidy
+ cancel-in-progress: true
+
+permissions: read-all
+
+jobs:
+ Smart_CI:
+ runs-on: ubuntu-latest
+ outputs:
+ affected_components: "${{ steps.smart_ci.outputs.affected_components }}"
+ changed_components: "${{ steps.smart_ci.outputs.changed_components }}"
+ skip_workflow: "${{ steps.smart_ci.outputs.skip_workflow }}"
+ steps:
+ - name: checkout action
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
+ with:
+ sparse-checkout: .github/actions/smart-ci
+
+ - name: Get affected components
+ id: smart_ci
+ uses: ./.github/actions/smart-ci
+ with:
+ repository: ${{ github.repository }}
+ pr: ${{ github.event.number }}
+ commit_sha: ${{ github.sha }}
+ ref_name: ${{ github.ref_name }}
+ component_pattern: "category: (.*)"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ skip_when_only_listed_labels_set: 'docs'
+ skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg,*/layer_tests_summary/*,*/conformance/*'
+
+ - name: Show affected components
+ run: |
+ echo "${{ toJSON(steps.smart_ci.outputs.affected_components) }}"
+ shell: bash
+
+ Docker:
+ needs: Smart_CI
+ runs-on: aks-linux-4-cores-16gb-docker-build
+ container:
+ image: openvinogithubactions.azurecr.io/docker_build:0.2
+ volumes:
+ - /mount:/mount
+ outputs:
+ images: "${{ steps.handle_docker.outputs.images }}"
+ steps:
+ - name: Set mock output images if pipeline should be skipped
+ if: ${{ needs.smart_ci.outputs.skip_workflow == 'True' }}
+ id: mock_image
+ run: echo "images={\"ov_build\":{\"ubuntu_24_04_x64\":\"mock\"}}" >> "$GITHUB_OUTPUT"
+
+ - name: Checkout
+ if: ${{ needs.smart_ci.outputs.skip_workflow != 'True' }}
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
+
+ - uses: ./.github/actions/handle_docker
+ id: handle_docker
+ with:
+ images: |
+ ov_build/ubuntu_24_04_x64
+ registry: 'openvinogithubactions.azurecr.io'
+ dockerfiles_root_dir: '.github/dockerfiles'
+ changed_components: ${{ needs.smart_ci.outputs.changed_components }}
+
+ Build:
+ needs: [Docker, Smart_CI]
+ if: "!needs.smart_ci.outputs.skip_workflow"
+ timeout-minutes: 150
+ defaults:
+ run:
+ shell: bash
+ runs-on: aks-linux-16-cores-32gb
+ container:
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_24_04_x64 }}
+ volumes:
+ - /mount:/mount
+ options: -e SCCACHE_AZURE_BLOB_CONTAINER -e SCCACHE_AZURE_CONNECTION_STRING
+ env:
+ DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input
+ CMAKE_BUILD_TYPE: 'Release'
+ CMAKE_GENERATOR: 'Ninja Multi-Config'
+ CMAKE_CXX_COMPILER_LAUNCHER: sccache
+ CMAKE_C_COMPILER_LAUNCHER: sccache
+ CMAKE_COMPILE_WARNING_AS_ERROR: 'ON'
+ SCCACHE_IGNORE_SERVER_IO_ERROR: 1
+ SCCACHE_SERVER_PORT: 35555
+ SCCACHE_ERROR_LOG: /__w/openvino/sccache_log.txt
+ SCCACHE_LOG: warn
+ GITHUB_WORKSPACE: '/__w/openvino/openvino'
+ OPENVINO_REPO: /__w/openvino/openvino/openvino
+ BUILD_DIR: /__w/openvino/openvino/openvino_build
+ SCCACHE_AZURE_KEY_PREFIX: ubuntu24_x86_64_Release_itt_faster_build_clang_tidy
+
+ steps:
+ - name: Clone OpenVINO
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
+ with:
+ path: ${{ env.OPENVINO_REPO }}
+ submodules: 'true'
+
+ - name: CMake configure
+ run: |
+ cmake \
+ -G "${{ env.CMAKE_GENERATOR }}" \
+ -DENABLE_CLANG_TIDY=ON \
+ -DCMAKE_CXX_FLAGS="-O0" \
+ -DENABLE_PROFILING_ITT=ON \
+ -DSELECTIVE_BUILD=COLLECT \
+ -DENABLE_PYTHON=OFF \
+ -DENABLE_TESTS=OFF \
+ -DENABLE_NCC_STYLE=OFF \
+ -DENABLE_CPPLINT=OFF \
+ -DENABLE_FASTER_BUILD=ON \
+ -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CMAKE_C_COMPILER_LAUNCHER }} \
+ -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CMAKE_CXX_COMPILER_LAUNCHER }} \
+ -S ${OPENVINO_REPO} \
+ -B ${BUILD_DIR}
+
+ - name: Cmake build with clang-tidy enabled
+ run: |
+ cmake \
+ --build ${BUILD_DIR} \
+ --parallel $(($(nproc) - 1)) \
+ --config ${{ env.CMAKE_BUILD_TYPE }} \
+ --target openvino_intel_cpu_plugin
+
+ - name: Show sccache stats
+ run: ${SCCACHE_PATH} --show-stats
+
+ Overall_Status:
+ name: ci/gha_overall_status_clang_tidy
+ needs: [Smart_CI, Build]
+ if: ${{ always() }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check status of all jobs
+ if: >-
+ ${{
+ contains(needs.*.result, 'failure') ||
+ contains(needs.*.result, 'cancelled')
+ }}
+ run: exit 1
diff --git a/.github/workflows/linux_conditional_compilation.yml b/.github/workflows/linux_conditional_compilation.yml
index 4d273da9659..9908d54f43b 100644
--- a/.github/workflows/linux_conditional_compilation.yml
+++ b/.github/workflows/linux_conditional_compilation.yml
@@ -90,7 +90,7 @@ jobs:
Build:
needs: [Docker, Smart_CI]
- if: "!needs.smart_ci.outputs.skip_workflow"
+ if: ${{ github.event_name != 'merge_group' && needs.smart_ci.outputs.skip_workflow != 'True' }}
timeout-minutes: 150
defaults:
run:
@@ -163,9 +163,7 @@ jobs:
# Build
#
- - name: CMake configure - CC COLLECT with clang-tidy
- # clang-tidy static analysis check is enabled as part of collection
- # to avoid an additional separate build execution
+ - name: CMake configure
run: |
cmake \
-G "${{ env.CMAKE_GENERATOR }}" \
@@ -173,7 +171,6 @@ jobs:
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_TESTS=ON \
-DENABLE_CPPLINT=OFF \
- -DENABLE_CLANG_TIDY=ON \
-DENABLE_NCC_STYLE=OFF \
-DENABLE_PROFILING_ITT=ON \
-DSELECTIVE_BUILD=COLLECT \
diff --git a/.github/workflows/workflow_rerunner.yml b/.github/workflows/workflow_rerunner.yml
index 4ec04a21b3d..46016c77b3d 100644
--- a/.github/workflows/workflow_rerunner.yml
+++ b/.github/workflows/workflow_rerunner.yml
@@ -18,6 +18,7 @@ on:
- "Windows (VS 2022, Python 3.11, Debug)"
- "Windows Conditional Compilation (VS 2022, Python 3.11)"
- "Manylinux 2014"
+ - "Clang-tidy static analysis (Ubuntu 24.04, Python 3.12, Clang-18, Clang-tidy-18)"
types:
- completed
pull_request: