From c2c16a5d99f55c56bd1860aa94fe7b6ae71b9d57 Mon Sep 17 00:00:00 2001 From: Keith Wiles Date: Fri, 27 Feb 2026 08:20:21 -0600 Subject: [PATCH 1/4] Update clang-format.yml Update clang-format Signed-off-by: Keith Wiles --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index fe37e2cb..21db4d66 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -9,6 +9,6 @@ jobs: - name: Run clang-format style check for C/C++/Protobuf programs. uses: jidicula/clang-format-action@v4.16.0 with: - clang-format-version: '21' + clang-format-version: '22.1' #check-path: 'src' #fallback-style: 'Mozilla' # optional From b8a10129e71a1b5cfdd5c8eaf5c3f92e9f02361e Mon Sep 17 00:00:00 2001 From: Keith Wiles Date: Fri, 27 Feb 2026 08:40:31 -0600 Subject: [PATCH 2/4] Update clang-format.yml Signed-off-by: Keith Wiles --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 21db4d66..2830f9c1 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -9,6 +9,6 @@ jobs: - name: Run clang-format style check for C/C++/Protobuf programs. uses: jidicula/clang-format-action@v4.16.0 with: - clang-format-version: '22.1' + clang-format-version: '22' #check-path: 'src' #fallback-style: 'Mozilla' # optional From f668ac4e1a7621a51d571c9959927208d5490abd Mon Sep 17 00:00:00 2001 From: Keith Wiles Date: Fri, 27 Feb 2026 08:44:24 -0600 Subject: [PATCH 3/4] revert to version 21 Signed-off-by: Keith Wiles --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 2830f9c1..fe37e2cb 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -9,6 +9,6 @@ jobs: - name: Run clang-format style check for C/C++/Protobuf programs. uses: jidicula/clang-format-action@v4.16.0 with: - clang-format-version: '22' + clang-format-version: '21' #check-path: 'src' #fallback-style: 'Mozilla' # optional From dd2da296615c97e7cb05239123028447483141b3 Mon Sep 17 00:00:00 2001 From: Keith Wiles Date: Fri, 27 Feb 2026 08:49:05 -0600 Subject: [PATCH 4/4] Enhance clang-format workflow with detailed steps and improved file handling Signed-off-by: Keith Wiles --- .github/workflows/clang-format.yml | 62 ++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index fe37e2cb..9fad6e6c 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,14 +1,60 @@ name: clang-format Check -on: [push, pull_request] +on: + push: + branches: [main] + pull_request: + jobs: formatting-check: name: Formatting Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Run clang-format style check for C/C++/Protobuf programs. - uses: jidicula/clang-format-action@v4.16.0 - with: - clang-format-version: '21' - #check-path: 'src' - #fallback-style: 'Mozilla' # optional + - uses: actions/checkout@v4 + with: + # Fetch enough history to diff against the base branch on PRs, + # or against the previous commit on direct pushes. + fetch-depth: 0 + + - name: Install clang-format-21 + run: | + wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 21 + sudo apt-get install -y clang-format-21 + sudo update-alternatives --install /usr/bin/clang-format clang-format \ + /usr/bin/clang-format-21 100 + clang-format --version + + - name: Resolve changed C/C++ files + id: changed + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + BASE="${{ github.event.pull_request.base.sha }}" + else + BASE="${{ github.event.before }}" + fi + + # Gracefully handle the first push to a branch (no previous commit). + if git cat-file -t "$BASE" 2>/dev/null | grep -q commit; then + FILES=$(git diff --name-only --diff-filter=ACMR "$BASE" HEAD \ + | grep -E '\.(c|h|cpp|hpp|cc|hh)$' || true) + else + FILES=$(git ls-files '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh') + fi + + echo "files<> "$GITHUB_OUTPUT" + echo "$FILES" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + if [ -z "$FILES" ]; then + echo "No C/C++ files changed – skipping format check." + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "Checking $(echo "$FILES" | wc -l) file(s):" + echo "$FILES" + echo "skip=false" >> "$GITHUB_OUTPUT" + fi + + - name: Check formatting + if: steps.changed.outputs.skip == 'false' + run: | + echo "${{ steps.changed.outputs.files }}" \ + | xargs -r clang-format --dry-run --Werror