Skip to content

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

[GHA] Switch code style checks to use Docker environment (#32342)

Gracjan Koscinskidfdfc162473c
diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag
index ca68e94ff89..2fbbf3a952f 100644
--- a/.github/dockerfiles/docker_tag
+++ b/.github/dockerfiles/docker_tag
@@ -1 +1 @@
-pr-31878
+pr-32342
\ No newline at end of file
diff --git a/.github/dockerfiles/ov_test/ubuntu_22_04_x64_code_style/Dockerfile b/.github/dockerfiles/ov_test/ubuntu_22_04_x64_code_style/Dockerfile
new file mode 100644
index 00000000000..e094015b418
--- /dev/null
+++ b/.github/dockerfiles/ov_test/ubuntu_22_04_x64_code_style/Dockerfile
@@ -0,0 +1,35 @@
+ARG REGISTRY="docker.io"
+FROM ${REGISTRY}/library/ubuntu:22.04
+
+USER root
+
+# APT configuration
+RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf && \
+ echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf && \
+ echo 'APT::Get::Fix-Broken "true";' >> /etc/apt/apt.conf && \
+ echo 'APT::Get::no-install-recommends "true";' >> /etc/apt/apt.conf
+
+ENV DEBIAN_FRONTEND="noninteractive" \
+ TZ="Europe/London"
+
+RUN apt-get update && \
+ apt-get install software-properties-common && \
+ add-apt-repository --yes --no-update ppa:git-core/ppa && \
+ apt-get update && \
+ apt-get install \
+ curl \
+ git \
+ ca-certificates \
+ cmake \
+ wget \
+ build-essential \
+ shellcheck \
+ clang-14 \
+ libclang-14-dev \
+ && \
+ rm -rf /var/lib/apt/lists/*
+
+ENV PIP_VERSION="24.0"
+RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
+ python3 get-pip.py --no-cache-dir pip==${PIP_VERSION} && \
+ rm -f get-pip.py
diff --git a/.github/dockerfiles/ov_test/ubuntu_24_04_x64_code_style/Dockerfile b/.github/dockerfiles/ov_test/ubuntu_24_04_x64_code_style/Dockerfile
new file mode 100644
index 00000000000..65fbc30e098
--- /dev/null
+++ b/.github/dockerfiles/ov_test/ubuntu_24_04_x64_code_style/Dockerfile
@@ -0,0 +1,38 @@
+ARG REGISTRY="docker.io"
+FROM ${REGISTRY}/library/ubuntu:24.04
+
+USER root
+
+# APT configuration
+RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf && \
+ echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf && \
+ echo 'APT::Get::Fix-Broken "true";' >> /etc/apt/apt.conf && \
+ echo 'APT::Get::no-install-recommends "true";' >> /etc/apt/apt.conf
+
+ENV DEBIAN_FRONTEND="noninteractive" \
+ TZ="Europe/London"
+
+RUN apt-get update && \
+ apt-get install software-properties-common && \
+ add-apt-repository --yes --no-update ppa:git-core/ppa && \
+ apt-get update && \
+ apt-get install \
+ curl \
+ git \
+ ca-certificates \
+ wget \
+ cmake \
+ lsb-release \
+ gnupg \
+ build-essential \
+ clang-format-18 \
+ shellcheck \
+ python3-dev \
+ python3-setuptools \
+ python3-pip \
+ && \
+ wget https://apt.llvm.org/llvm.sh && \
+ chmod +x llvm.sh && \
+ ./llvm.sh 18 && \
+ apt-get --assume-yes install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu scons gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu && \
+ rm -rf /var/lib/apt/lists/*
diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml
index 327a63d68e5..ba0992c509a 100644
--- a/.github/workflows/code_style.yml
+++ b/.github/workflows/code_style.yml
@@ -8,23 +8,75 @@ concurrency:
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'
+
+ - 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: Checkout
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
+
+ - uses: ./.github/actions/handle_docker
+ id: handle_docker
+ with:
+ images: |
+ ov_test/ubuntu_24_04_x64_code_style
+ ov_test/ubuntu_22_04_x64_code_style
+ registry: 'openvinogithubactions.azurecr.io'
+ dockerfiles_root_dir: '.github/dockerfiles'
+ changed_components: ${{ needs.smart_ci.outputs.changed_components }}
+
clang-format:
- runs-on: ubuntu-24.04
- if: ${{ github.repository_owner == 'openvinotoolkit' }}
- permissions:
- pull-requests: write
+ needs: Docker
+ runs-on: aks-linux-4-cores-16gb
+ container:
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64_code_style }}
+ volumes:
+ - /mount:/mount
+ options: --user 1001 # We use standard github-actions user inside container to avoid permission issues after checkout
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
timeout-minutes: 15
with:
submodules: 'true'
- - name: Install clang-format-18
- run: |
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 18
-
# Run cmake with extra options to cover as much source code as possible:
# - -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT to enable codestyle check for ITT collector
# - -DENABLE_SNIPPETS_LIBXSMM_TPP to cover snippets TPP adaptation
@@ -44,23 +96,19 @@ jobs:
filter_mode: nofilter
clang-format-aarch64:
- runs-on: ubuntu-24.04
- if: ${{ github.repository_owner == 'openvinotoolkit' }}
- permissions:
- pull-requests: write
+ needs: Docker
+ runs-on: aks-linux-4-cores-16gb
+ container:
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64_code_style }}
+ volumes:
+ - /mount:/mount
+ options: --user 1001 # We use standard github-actions user inside container to avoid permission issues after checkout
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
with:
submodules: 'true'
- - name: Install clang-format-18 and cross-compilation dependencies
- run: |
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 18
- sudo apt update
- sudo apt --assume-yes install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu scons
-
# Run cmake with extra options to cover as much source code as possible:
# - -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT to enable codestyle check for ITT collector
# - -DENABLE_SNIPPETS_LIBXSMM_TPP to cover snippets TPP adaptation
@@ -80,25 +128,19 @@ jobs:
filter_mode: nofilter
clang-format-riscv64:
- runs-on: ubuntu-24.04
- if: ${{ github.repository_owner == 'openvinotoolkit' }}
- permissions:
- pull-requests: write
+ needs: Docker
+ runs-on: aks-linux-4-cores-16gb
+ container:
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64_code_style }}
+ volumes:
+ - /mount:/mount
+ options: --user 1001 # We use standard github-actions user inside container to avoid permission issues after checkout
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ timeout-minutes: 15
with:
submodules: 'true'
- - name: Install clang-format-18 and cross-compilation dependencies
- run: |
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 18
- sudo apt update
- sudo apt --assume-yes install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu
-
- # Run cmake with extra options to cover as much source code as possible:
- # - -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT to enable codestyle check for ITT collector
- name: CMake configure
run: cmake -DENABLE_CLANG_FORMAT=ON -DENABLE_TESTS=ON -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/riscv64.linux.toolchain.cmake -B build_riscv64
@@ -115,21 +157,19 @@ jobs:
filter_mode: nofilter
ShellCheck:
- runs-on: ubuntu-22.04
- if: ${{ github.repository_owner == 'openvinotoolkit' }}
- permissions:
- pull-requests: write
+ needs: Docker
+ runs-on: aks-linux-4-cores-16gb
+ container:
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_22_04_x64_code_style }}
+ volumes:
+ - /mount:/mount
+ options: --user 1001 # We use standard github-actions user inside container to avoid permission issues after checkout
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
timeout-minutes: 15
with:
submodules: 'true'
- - name: Install ShellCheck
- run: |
- sudo apt update
- sudo apt --assume-yes install shellcheck
-
- name: CMake configure
run: cmake -B build
@@ -150,20 +190,19 @@ jobs:
"./temp/*"
NamingConventionCheck:
- runs-on: ubuntu-22.04
- if: ${{ github.repository_owner == 'openvinotoolkit' }}
+ needs: Docker
+ runs-on: aks-linux-4-cores-16gb
+ container:
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_22_04_x64_code_style }}
+ volumes:
+ - /mount:/mount
+ options: --user 1001 # We use standard github-actions user inside container to avoid permission issues after checkout
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
timeout-minutes: 15
with:
submodules: 'true'
- - name: Install Clang dependency
- run: |
- sudo apt update
- sudo apt --assume-yes remove clang-7 clang-8 clang-9 clang-10 clang-11 clang-12 clang-13 clang-15
- sudo apt --assume-yes install clang-14 libclang-14-dev
-
- name: Install Python-based dependencies
run: python3 -m pip install -r cmake/developer_package/ncc_naming_style/requirements_dev.txt
@@ -171,4 +210,4 @@ jobs:
run: cmake -B build
- name: Naming convention check
- run: cmake --build build --target ncc_all -j8
+ run: cmake --build build --target ncc_all -j8
\ No newline at end of file