From deb342e683d20310b380464797bd2b2d112efa64 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Sun, 26 Oct 2025 18:56:41 -0300 Subject: [PATCH] Add clang-format checks --- .github/workflows/main.yml | 19 +++++++++++++++++++ .github/workflows/pull-request.yml | 18 ++++++++++++++++++ check-format.sh | 11 +++++++++++ 3 files changed, 48 insertions(+) create mode 100755 check-format.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3454bbd..77da28e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,24 @@ concurrency: group: main jobs: + clang-format-check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Install clang-format + run: | + sudo apt-get update + sudo apt-get install -y clang-format + + - name: Check clang-format + run: | + ./check-format.sh + build-linux: runs-on: ubuntu-latest steps: @@ -195,6 +213,7 @@ jobs: deploy-docs: runs-on: ubuntu-latest needs: + - clang-format-check - build-linux - build-windows - build-macos diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a553120..9c5d41c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,6 +6,24 @@ on: - main jobs: + clang-format-check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Install clang-format + run: | + sudo apt-get update + sudo apt-get install -y clang-format + + - name: Check clang-format + run: | + ./check-format.sh + build-linux: runs-on: ubuntu-latest steps: diff --git a/check-format.sh b/check-format.sh new file mode 100755 index 0000000..9a3c25d --- /dev/null +++ b/check-format.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +failed_files=$( \ + find src -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "src/lib/fb-api/*" \ + -exec sh -c 'for f; do [ "$(clang-format "$f")" != "$(cat "$f")" ] && echo "$f"; done' _ {} +) + +if [ -n "$failed_files" ]; then + echo "The following files are not properly formatted:" + echo "$failed_files" + exit 1 +fi