File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 runs-on : ubuntu-latest
1313 steps :
1414 - uses : actions/checkout@v4
15- - uses : DoozyX/clang-format-lint-action@v0.15
1615 with :
17- source : ' ./app ./include ./src ./test'
16+ fetch-depth : 0
17+ - name : Install clang-format
18+ run : sudo apt-get update && sudo apt-get install -y clang-format-18
19+ - name : Run clang-format
20+ env :
21+ BASE_SHA : ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
22+ HEAD_SHA : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
23+ run : ./scripts/ci/clang-format-check.sh "${BASE_SHA}" "${HEAD_SHA}"
1824 build-linux :
1925 strategy :
2026 matrix :
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ base_ref=" ${1:- } "
5+ head_ref=" ${2:- HEAD} "
6+
7+ if [[ -z " ${base_ref} " || " ${base_ref} " =~ ^0+$ ]]; then
8+ base_ref=" $( git rev-parse " ${head_ref} ^" ) "
9+ fi
10+
11+ mapfile -t files < <(
12+ git diff --name-only --diff-filter=ACMR " ${base_ref} " " ${head_ref} " -- app include src test \
13+ | grep -E ' \.(c|h|C|H|cpp|hpp|cc|hh|c\+\+|h\+\+|cxx|hxx)$' \
14+ || true
15+ )
16+
17+ if [[ " ${# files[@]} " -eq 0 ]]; then
18+ echo " No source files changed."
19+ exit 0
20+ fi
21+
22+ clang_format_bin=" ${CLANG_FORMAT_BIN:- clang-format-18} "
23+
24+ " ${clang_format_bin} " --dry-run -Werror " ${files[@]} "
You can’t perform that action at this time.
0 commit comments