From dac3a33dd6bd2429f16807a4ee076ad76fc5fbde Mon Sep 17 00:00:00 2001 From: Stanislav Gonorovskii Date: Wed, 3 Dec 2025 14:29:31 +0400 Subject: [PATCH 1/6] Minimal pre-commit implementation --- .github/workflows/lint.yml | 87 ++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 20 +++++++++ 2 files changed, 107 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..a05bdd35e8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,87 @@ +name: Lint + +on: + pull_request: + branches: + - master + push: + branches: + - master + +env: + OV_BRANCH: master + +jobs: + openvino_download: + name: Download OpenVINO + runs-on: aks-linux-medium + timeout-minutes: 10 + defaults: + run: + shell: bash + container: + image: "openvinogithubactions.azurecr.io/openvino_provider:0.1.0" + volumes: + - /mount:/mount + - ${{ github.workspace }}:${{ github.workspace }} + outputs: + ov_artifact_name: ${{ steps.openvino_download.outputs.ov_artifact_name }} + steps: + - uses: openvinotoolkit/openvino/.github/actions/openvino_provider@master + id: openvino_download + with: + platform: ubuntu22 + commit_packages_to_provide: developer_package.tar.gz + revision: latest_available_commit + + lint: + name: Lint Changed Files + needs: [openvino_download] + runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + shell: bash + env: + OV_INSTALL_DIR: ${{ github.workspace }}/ov + + steps: + - name: Checkout code + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 0 + submodules: recursive + + - name: Download OpenVINO package + uses: akashchi/download-artifact@d59a9c15fec3fdb7c9adf09464124d00f9c11415 + with: + name: ${{ needs.openvino_download.outputs.ov_artifact_name }} + path: ${{ env.OV_INSTALL_DIR }} + merge-multiple: true + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y clang-format clang-tidy cmake ninja-build + + - name: Configure CMake to generate compile_commands.json + run: | + source ${{ env.OV_INSTALL_DIR }}/setupvars.sh + cmake -B build -G Ninja \ + -DOpenVINODeveloperPackage_DIR=${{ env.OV_INSTALL_DIR }}/developer_package/cmake \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + + - name: Run pre-commit on changed files + uses: pre-commit/action@v3.0.1 + with: + extra_args: --from-ref origin/${{ github.base_ref || 'master' }} --to-ref HEAD diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..9914ff388e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: + - repo: meta + hooks: + - id: identity + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-merge-conflict + - id: check-case-conflict + - id: check-symlinks + - id: detect-private-key + - id: mixed-line-ending + args: ["--fix=lf"] + - id: check-ast + - id: check-yaml + - id: check-toml + - id: check-added-large-files + args: ["--maxkb=1000"] From 8bca45f97d24f0a8a888cd297431f14d7524f7c5 Mon Sep 17 00:00:00 2001 From: Stanislav Gonorovskii Date: Wed, 3 Dec 2025 14:29:31 +0400 Subject: [PATCH 2/6] Removed unnececarry CI steps --- .github/workflows/lint.yml | 49 -------------------------------------- 1 file changed, 49 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a05bdd35e8..077dccda8e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,38 +12,13 @@ env: OV_BRANCH: master jobs: - openvino_download: - name: Download OpenVINO - runs-on: aks-linux-medium - timeout-minutes: 10 - defaults: - run: - shell: bash - container: - image: "openvinogithubactions.azurecr.io/openvino_provider:0.1.0" - volumes: - - /mount:/mount - - ${{ github.workspace }}:${{ github.workspace }} - outputs: - ov_artifact_name: ${{ steps.openvino_download.outputs.ov_artifact_name }} - steps: - - uses: openvinotoolkit/openvino/.github/actions/openvino_provider@master - id: openvino_download - with: - platform: ubuntu22 - commit_packages_to_provide: developer_package.tar.gz - revision: latest_available_commit - lint: name: Lint Changed Files - needs: [openvino_download] runs-on: ubuntu-latest timeout-minutes: 30 defaults: run: shell: bash - env: - OV_INSTALL_DIR: ${{ github.workspace }}/ov steps: - name: Checkout code @@ -52,35 +27,11 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Download OpenVINO package - uses: akashchi/download-artifact@d59a9c15fec3fdb7c9adf09464124d00f9c11415 - with: - name: ${{ needs.openvino_download.outputs.ov_artifact_name }} - path: ${{ env.OV_INSTALL_DIR }} - merge-multiple: true - - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.10" - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y clang-format clang-tidy cmake ninja-build - - - name: Configure CMake to generate compile_commands.json - run: | - source ${{ env.OV_INSTALL_DIR }}/setupvars.sh - cmake -B build -G Ninja \ - -DOpenVINODeveloperPackage_DIR=${{ env.OV_INSTALL_DIR }}/developer_package/cmake \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - - name: Run pre-commit on changed files uses: pre-commit/action@v3.0.1 with: From 725ede515751bc5f6f9bebfb2fcb640c40f50646 Mon Sep 17 00:00:00 2001 From: Stanislav Gonorovskii Date: Wed, 3 Dec 2025 14:29:32 +0400 Subject: [PATCH 3/6] Adding Darker for Python code formatting --- .pre-commit-config.yaml | 7 +++++++ pyproject.toml | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9914ff388e..9dc4d38259 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,3 +18,10 @@ repos: - id: check-toml - id: check-added-large-files args: ["--maxkb=1000"] + - repo: https://github.com/akaihola/darker + rev: v3.0.0 + hooks: + - id: darker + args: ["--formatter=ruff"] + additional_dependencies: + - ruff==0.14.4 diff --git a/pyproject.toml b/pyproject.toml index d962982d24..026a81ed42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,3 +59,16 @@ requires = [ "cmake~=3.24.0; platform_system == 'Darwin' and platform_machine == 'arm64'", ] build-backend = "py_build_cmake.build" + +[tool.ruff] +line-length = 100 +indent-width = 4 +target-version = "py310" + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" +docstring-code-format = false +docstring-code-line-length = "dynamic" From 30330bd0660b6f7029a338b1b5afa6aebb4291aa Mon Sep 17 00:00:00 2001 From: Stanislav Gonorovskii Date: Wed, 3 Dec 2025 14:29:32 +0400 Subject: [PATCH 4/6] Exclude python files fromtrailing-whitespace check --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9dc4d38259..d67b5f5de9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,7 @@ repos: rev: v6.0.0 hooks: - id: trailing-whitespace + exclude: '\.py$' - id: end-of-file-fixer - id: check-merge-conflict - id: check-case-conflict From 71c003c08753bd66d963e9e3563145620d9e2c62 Mon Sep 17 00:00:00 2001 From: Stanislav Gonorovskii Date: Wed, 3 Dec 2025 14:29:32 +0400 Subject: [PATCH 5/6] Sync python line length with OV --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 026a81ed42..6ecc719606 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ requires = [ build-backend = "py_build_cmake.build" [tool.ruff] -line-length = 100 +line-length = 120 indent-width = 4 target-version = "py310" From c44cb7b668a461029e673015a687d3fb787f5b0d Mon Sep 17 00:00:00 2001 From: Stanislav Gonorovskii Date: Wed, 3 Dec 2025 14:29:32 +0400 Subject: [PATCH 6/6] Adding cpp files to whitespace ignore --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d67b5f5de9..e836d576dc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: rev: v6.0.0 hooks: - id: trailing-whitespace - exclude: '\.py$' + exclude: '\.(py|c|cpp|h|hpp)$' - id: end-of-file-fixer - id: check-merge-conflict - id: check-case-conflict