Skip to content

Commit

Permalink
Fix clang-tidy.sh to correctly handle paths without a starting slash …
Browse files Browse the repository at this point in the history
…and empty subsets (CleverRaven#65354)
  • Loading branch information
Qrox authored Apr 29, 2023
1 parent 5dec493 commit c02676a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
- '**.hpp'
- '**/CMakeLists.txt'
- '**/Makefile'
- 'build-scripts/clang-tidy.sh'
- 'build-scripts/clang-tidy-wrapper.sh'
- 'build-scripts/get_affected_files.py'
- '.github/workflows/clang-tidy.yml'

# We only care about the latest revision of a PR, so cancel all previous instances.
Expand All @@ -34,7 +37,7 @@ jobs:
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
paths: '[ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", ".github/workflows/clang-tidy.yml" ]'
paths: '[ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/clang-tidy.sh", "build-scripts/clang-tidy-wrapper.sh", "build-scripts/get_affected_files.py", ".github/workflows/clang-tidy.yml" ]'
build:
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}
Expand Down Expand Up @@ -91,5 +94,10 @@ jobs:
run: bash ./build-scripts/clang-tidy.sh
- name: show most time consuming checks
if: always()
run: |
jq -n 'reduce(inputs.profile | to_entries[]) as {$key,$value} ({}; .[$key] += $value) | with_entries(select(.key|contains(".wall"))) | to_entries | sort_by(.value) | reverse | .[0:10] | from_entries' clang-tidy-trace/*.json
run: | # the folder may not exist if there is no file to analyze
if [ -d clang-tidy-trace ]
then
jq -n 'reduce(inputs.profile | to_entries[]) as {$key,$value} ({}; .[$key] += $value) | with_entries(select(.key|contains(".wall"))) | to_entries | sort_by(.value) | reverse | .[0:10] | from_entries' clang-tidy-trace/*.json
else
echo "clang-tidy-trace folder not found."
fi
9 changes: 6 additions & 3 deletions build-scripts/clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ fi
printf "Subset to analyze: '%s'\n" "$CATA_CLANG_TIDY_SUBSET"

# We might need to analyze only a subset of the files if they have been split
# into multiple jobs for efficiency
# into multiple jobs for efficiency. The paths from `compile_commands.json` can
# be absolute but the paths from `get_affected_files.py` are relative, so both
# formats are matched. Exit code 1 from grep (meaning no match) is ignored in
# case one subset contains no file to analyze.
case "$CATA_CLANG_TIDY_SUBSET" in
( src )
tidyable_cpp_files=$(printf '%s\n' "$tidyable_cpp_files" | grep '/src/')
tidyable_cpp_files=$(printf '%s\n' "$tidyable_cpp_files" | grep -E '(^|/)src/' || [[ $? == 1 ]])
;;
( other )
tidyable_cpp_files=$(printf '%s\n' "$tidyable_cpp_files" | grep -v '/src/')
tidyable_cpp_files=$(printf '%s\n' "$tidyable_cpp_files" | grep -Ev '(^|/)src/' || [[ $? == 1 ]])
;;
esac

Expand Down

0 comments on commit c02676a

Please sign in to comment.