From 04145abea8338f140c8f94bc9fc5837ab64dd0ce Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 18 Sep 2025 18:54:38 +0200 Subject: [PATCH 1/2] tools/ci: Remove uncrustify functions. Signed-off-by: iabdalkader --- tools/ci.sh | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/tools/ci.sh b/tools/ci.sh index c6ef04988..02555bdad 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -75,45 +75,6 @@ ci_package_firmware_development() { (cd firmware && for i in *; do zip -r -j "firmware_${i%/}.zip" "$i"; done) } -######################################################################################## -# Install code formatter deps -CODEFORMAT_PATH=${HOME}/cache/deps/ -UNCRUSTIFY_PATH=${CODEFORMAT_PATH}/uncrustify -UNCRUSTIFY_URL="https://github.com/uncrustify/uncrustify/archive/uncrustify-0.75.0.tar.gz" - -ci_install_code_format_deps() { - sudo apt-get install wget cmake build-essential colordiff - - mkdir -p ${UNCRUSTIFY_PATH} - wget --no-check-certificate -O - ${UNCRUSTIFY_URL} | tar xvz --strip-components=1 -C ${UNCRUSTIFY_PATH} - (cd ${UNCRUSTIFY_PATH} && mkdir build && cd build && cmake .. && cmake --build .) - - # Copy binaries to cache - mkdir -p ${CODEFORMAT_PATH}/bin - cp ${UNCRUSTIFY_PATH}/build/uncrustify ${CODEFORMAT_PATH}/bin/ - cp `which colordiff` ${CODEFORMAT_PATH}/bin/ - chmod +x ${CODEFORMAT_PATH}/bin/uncrustify -} - -######################################################################################## -# Run code formatter -ci_run_code_format_check() { - export PATH=${CODEFORMAT_PATH}/bin:${PATH} - UNCRUSTIFY_CONFIG=tools/uncrustify.cfg - - exit_code=0 - for file in "$@"; do - file_fmt="${file}.tmp" - uncrustify -q -c ${UNCRUSTIFY_CONFIG} -f ${file} -o ${file_fmt} || true - - diff -q -u ${file} ${file_fmt} >> /dev/null 2>&1 || { - colordiff -u ${file} ${file_fmt} || true - exit_code=1 - } - done - exit $exit_code -} - ######################################################################################## # Install STEdgeAI tools STEDGEAI_URL="https://upload.openmv.io/stedgeai/STEdgeAI-2.1.0.tar.gz" From 75c7a4fb8218cbf81262184d1712ae3792a064e4 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 18 Sep 2025 18:55:07 +0200 Subject: [PATCH 2/2] github/codeformat: Switch to uncrustify-action. Signed-off-by: iabdalkader --- .github/workflows/codeformat.yml | 55 +++++++++++--------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/.github/workflows/codeformat.yml b/.github/workflows/codeformat.yml index b672537af..b4b4605f3 100644 --- a/.github/workflows/codeformat.yml +++ b/.github/workflows/codeformat.yml @@ -15,6 +15,7 @@ on: - synchronize branches: - 'master' + - 'update_code_formatter' paths: - '**/*.{c,cc,h}' @@ -28,41 +29,21 @@ jobs: submodules: false persist-credentials: false - - name: '♻ Caching dependencies' - uses: actions/cache@v4.2.0 - id: cache - with: - path: ~/cache/deps/bin - key: 'uncrustify' - - - name: '🛠 Install dependencies' - if: steps.cache.outputs.cache-hit != 'true' - run: source tools/ci.sh && ci_install_code_format_deps - - - name: '📜 Get list of changed files' - id: changed-files - uses: tj-actions/changed-files@v46 - with: - files: | - **/*.{c,cc,h} - !cubeai/** - !docker/** - !docs/** - !drivers/** - drivers/sensors/*.{c,cc,h} - !lib/** - lib/imlib/*.{c,cc,h} - lib/tflm/*.{c,cc,h} - !scripts/** - !tools/** - - - name: '📜 Show list of changed files' - run: | - echo "${{ toJSON(steps.changed-files.outputs) }}" - shell: - bash - - name: '🔎 Check code formatting' - if: steps.changed-files.outputs.any_changed == 'true' - run: | - source tools/ci.sh && ci_run_code_format_check ${{ steps.changed-files.outputs.all_changed_files }} + uses: openmv/uncrustify-action@v1 + with: + config-path: 'tools/uncrustify.cfg' + extensions: 'c,cc,h' + exclude-patterns: | + cubeai/** + docker/** + docs/** + drivers/** + !drivers/sensors/** + lib/** + !lib/imlib/** + !lib/tflm/** + scripts/** + tools/** + uncrustify-version: '0.75.0' + fail-on-error: 'true'