|
6 | 6 | required: false |
7 | 7 | default: 'build' |
8 | 8 | exclude: |
9 | | - description: 'Directories to exclude from analysis' |
| 9 | + description: 'Directories to exclude from analysis (space-separated)' |
10 | 10 | required: false |
11 | 11 | default: '3rdparty' |
12 | 12 | clang_tidy_version: |
|
31 | 31 | run: | |
32 | 32 | git config --global --add safe.directory $GITHUB_WORKSPACE |
33 | 33 | git fetch origin ${{ github.event.pull_request.base.ref }} |
34 | | - CHANGED_FILES=$(git diff --name-only \ |
| 34 | +
|
| 35 | + # Check if .clang-tidy files were changed |
| 36 | + CLANG_TIDY_CHANGED=$(git diff --name-only \ |
35 | 37 | origin/${{ github.event.pull_request.base.ref }}...HEAD \ |
36 | | - -- '*.cpp' '*.hpp' '*.c' '*.h' | grep -v '^${{ inputs.exclude }}/' || true) |
| 38 | + -- '**/.clang-tidy' || true) |
| 39 | +
|
| 40 | + if [ -n "$CLANG_TIDY_CHANGED" ]; then |
| 41 | + echo "::notice::.clang-tidy configuration changed, analyzing all source files" |
| 42 | + # Find all source files in the repository (excluding specified directories) |
| 43 | + CHANGED_FILES=$(find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h") |
| 44 | + # Filter out excluded directories |
| 45 | + for exclude_dir in ${{ inputs.exclude }}; do |
| 46 | + CHANGED_FILES=$(echo "$CHANGED_FILES" | grep -v "^./${exclude_dir}/" || true) |
| 47 | + done |
| 48 | + else |
| 49 | + # Only analyze changed source files |
| 50 | + CHANGED_FILES=$(git diff --name-only \ |
| 51 | + origin/${{ github.event.pull_request.base.ref }}...HEAD \ |
| 52 | + -- '*.cpp' '*.hpp' '*.c' '*.h') |
| 53 | + # Filter out excluded directories |
| 54 | + for exclude_dir in ${{ inputs.exclude }}; do |
| 55 | + CHANGED_FILES=$(echo "$CHANGED_FILES" | grep -v "^${exclude_dir}/" || true) |
| 56 | + done |
| 57 | + fi |
| 58 | +
|
37 | 59 | echo "changed_files<<EOF" >> $GITHUB_OUTPUT |
38 | 60 | echo "$CHANGED_FILES" >> $GITHUB_OUTPUT |
39 | 61 | echo "EOF" >> $GITHUB_OUTPUT |
|
0 commit comments