From a7838b022cfc907c9777dbab1a90a7325d532bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Sun, 1 Nov 2026 12:22:22 +0100 Subject: [PATCH] ci: install clang-format via pip The clang-format-15 package is not available anymore in the latest Ubuntu runner image. Installing clang-format from PyPI makes the style check independent of the runner image and allows to use the same version locally: pip install clang-format==23.1.* The style check script prefers the clang-format-diff.py installed by pip and prints the clang-format version. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/zephyr.yml | 3 ++- scripts/check-style.sh | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/zephyr.yml b/.github/workflows/zephyr.yml index 14f2adf..59d995e 100644 --- a/.github/workflows/zephyr.yml +++ b/.github/workflows/zephyr.yml @@ -35,7 +35,8 @@ jobs: - name: Coding style check run: | sudo apt-get update - sudo apt-get install -y clang-format-15 colordiff + sudo apt-get install -y colordiff + pip install clang-format==23.1.* git status bash scripts/check-style.sh diff --git a/scripts/check-style.sh b/scripts/check-style.sh index 2438bda..302ce1d 100755 --- a/scripts/check-style.sh +++ b/scripts/check-style.sh @@ -5,10 +5,12 @@ DEFAULT_BRANCH="origin/main" -if [ -x "$(command -v clang-format-diff)" ]; then +# clang-format-diff.py installed via pip (pip install clang-format) is preferred, as the same +# version as in CI can be used locally +if [ -x "$(command -v clang-format-diff.py)" ]; then +CLANG_FORMAT_DIFF="clang-format-diff.py" +elif [ -x "$(command -v clang-format-diff)" ]; then CLANG_FORMAT_DIFF="clang-format-diff" -elif [ -x "$(command -v clang-format-diff-15)" ]; then -CLANG_FORMAT_DIFF="clang-format-diff-15" elif [ -x "$(command -v /usr/share/clang/clang-format-diff.py)" ]; then CLANG_FORMAT_DIFF="/usr/share/clang/clang-format-diff.py -v" fi @@ -26,6 +28,7 @@ else fi echo "Checking coding style with clang-format" +clang-format --version # clang-format-diff returns 0 even for style differences, so we have to check the length of the # response