Skip to content

Commit

Permalink
Afuller/clang tidy ignore not built files (#14856)
Browse files Browse the repository at this point in the history
#0: Do not check files not present in compile_commands.json
  • Loading branch information
afuller-TT authored Nov 7, 2024
1 parent 9d24663 commit 53d6f58
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/all-static-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,33 @@ jobs:
- name: Prepare compile_commands.json
run: |
ARCH_NAME=grayskull cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -DTT_METAL_BUILD_TESTS=ON -DTTNN_BUILD_TESTS=ON -DTT_UMD_BUILD_TESTS=ON -DTT_UNITY_BUILDS=OFF
- name: 'Install jq'
uses: dcarbone/install-jq-action@v2
- name: Create results directory
run: |
mkdir clang-tidy-result
- name: Analyze
shell: bash
run: |
git diff -U0 "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" | clang-tidy-diff-17.py -p1 -path build -export-fixes clang-tidy-result/fixes.yml -j4
set -euo pipefail
# Find all touched files present in compile_commands.json
# This is not as simple as filtering non-code files, as some code (eg: Kernels) are C++ code that
# is not built at this level, and thus clang-tidy will be unable to process them.
PREFIX=$(pwd)
jq --arg prefix "$PREFIX/" -r '.[].file | sub("^" + $prefix; "")' build/compile_commands.json > relative_files_in_build.txt
git diff --name-only "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")..." > changed_files.txt
grep -F -f relative_files_in_build.txt changed_files.txt > common_files.txt || true
# Exit if there are no modified files known to CMake
[[ -s common_files.txt ]] || {
echo "No files to analyze"
exit 0
}
# Analyze the relevant diffs of the relevant files
git diff "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" -- $(cat common_files.txt) > filtered_changes.diff
clang-tidy-diff-17.py -p1 -path build -export-fixes clang-tidy-result/fixes.yml -j$(nproc) < filtered_changes.diff
timeout-minutes: 5
continue-on-error: true
- name: Run clang-tidy-pr-comments action
Expand Down

0 comments on commit 53d6f58

Please sign in to comment.