From 2612a19f3cc5fb007a4943eeffb7d56e7d2de633 Mon Sep 17 00:00:00 2001 From: light7734 Date: Thu, 16 Oct 2025 14:04:26 +0330 Subject: [PATCH] ci: add cmake_format check --- .drone.yml | 14 ++++++++++---- tools/ci/static_analysis/cmake_format.sh | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100755 tools/ci/static_analysis/cmake_format.sh diff --git a/.drone.yml b/.drone.yml index 9abc962..dd34f73 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,7 +31,7 @@ steps: - ./tools/ci/amd64/gcc/unit_tests.sh - name: valgrind - image: ci:latest + image: ci:latest pull: if-not-exists commands: - ./tools/ci/amd64/gcc/valgrind.sh @@ -55,7 +55,7 @@ steps: - ./tools/ci/amd64/clang/coverage.sh - name: leak sanitizer - image: ci:latest + image: ci:latest pull: if-not-exists commands: - ./tools/ci/amd64/clang/lsan.sh @@ -76,18 +76,24 @@ trigger: steps: - name: clang tidy - image: ci:latest + image: ci:latest pull: if-not-exists privileged: true commands: - ./tools/ci/static_analysis/clang_tidy.sh - name: clang format - image: ci:latest + image: ci:latest pull: if-not-exists commands: - ./tools/ci/static_analysis/clang_format.sh +- name: cmake format + image: ci:latest + pull: if-not-exists + commands: + - ./tools/ci/static_analysis/cmake_format.sh + --- kind: pipeline type: docker diff --git a/tools/ci/static_analysis/cmake_format.sh b/tools/ci/static_analysis/cmake_format.sh new file mode 100755 index 0000000..33826ee --- /dev/null +++ b/tools/ci/static_analysis/cmake_format.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -euo pipefail +cd "$(git rev-parse --show-toplevel)/" + +has_formatting_issues=0 +while IFS= read -r -d '' file; do + echo "Checking format for $file" + + if ! cmake-format --check "$file"; then + echo "❌ Formatting issue detected in $file" + has_formatting_issues=1 + fi +done < <(find ./modules ./tools/cmake -type f \( -name 'CMakeLists.txt' -o -name '*.cmake' \) -print0) + +if [ "$has_formatting_issues" -ne 0 ]; then + echo "✅ All files are properly formatted! Well done! ^~^" +fi + +exit ${has_formatting_issues}