@@ -31,15 +31,15 @@ jobs:
3131 if : github.event_name != 'push' || contains(github.event.head_commit.message, 'clang-tidy auto fixes')
3232 runs-on : heavy
3333 container :
34- image : ghcr.io/xrplf/clio-ci:77387d8f9f13aea8f23831d221ac3e7683bb69b7
34+ image : ghcr.io/xrplf/clio-ci:067449c3f8ae6755ea84752ea2962b589fe56c8f
3535
3636 permissions :
3737 contents : write
3838 issues : write
3939 pull-requests : write
4040
4141 steps :
42- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 .0.0
42+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 .0.1
4343 with :
4444 fetch-depth : 0
4545
@@ -62,27 +62,30 @@ jobs:
6262 uses : XRPLF/actions/.github/actions/get-nproc@046b1620f6bfd6cd0985dc82c3df02786801fe0a
6363 id : nproc
6464
65- - name : Run clang-tidy
65+ - name : Run clang-tidy (several times)
6666 continue-on-error : true
67- id : run_clang_tidy
67+ id : clang_tidy
6868 run : |
69- run-clang-tidy-${{ env.LLVM_TOOLS_VERSION }} -p build -j "${{ steps.nproc.outputs.nproc }}" -fix -quiet 1>output.txt
69+ # We run clang-tidy several times, because some fixes may enable new fixes in subsequent runs.
70+ CLANG_TIDY_COMMAND="run-clang-tidy-${{ env.LLVM_TOOLS_VERSION }} -p build -j ${{ steps.nproc.outputs.nproc }} -fix -quiet"
71+ ${CLANG_TIDY_COMMAND} ||
72+ ${CLANG_TIDY_COMMAND} ||
73+ ${CLANG_TIDY_COMMAND}
74+
75+ - name : Check for changes
76+ id : files_changed
77+ continue-on-error : true
78+ run : |
79+ git diff --exit-code
7080
7181 - name : Fix local includes and clang-format style
72- if : ${{ steps.run_clang_tidy .outcome != 'success' }}
82+ if : ${{ steps.files_changed .outcome != 'success' }}
7383 run : |
7484 pre-commit run --all-files fix-local-includes || true
7585 pre-commit run --all-files clang-format || true
7686
77- - name : Print issues found
78- if : ${{ steps.run_clang_tidy.outcome != 'success' }}
79- run : |
80- sed -i '/error\||/!d' ./output.txt
81- cat output.txt
82- rm output.txt
83-
8487 - name : Create an issue
85- if : ${{ steps.run_clang_tidy .outcome != 'success' && github.event_name != 'pull_request' }}
88+ if : ${{ ( steps.clang_tidy .outcome != 'success' || steps.files_changed.outcome != 'success') && github.event_name != 'pull_request' }}
8689 id : create_issue
8790 uses : ./.github/actions/create-issue
8891 env :
@@ -95,16 +98,16 @@ jobs:
9598 List of the issues found: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/
9699
97100 - uses : crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
98- if : ${{ steps.run_clang_tidy .outcome != 'success' && github.event_name != 'pull_request' }}
101+ if : ${{ steps.files_changed .outcome != 'success' && github.event_name != 'pull_request' }}
99102 with :
100103 gpg_private_key : ${{ secrets.ACTIONS_GPG_PRIVATE_KEY }}
101104 passphrase : ${{ secrets.ACTIONS_GPG_PASSPHRASE }}
102105 git_user_signingkey : true
103106 git_commit_gpgsign : true
104107
105108 - name : Create PR with fixes
106- if : ${{ steps.run_clang_tidy .outcome != 'success' && github.event_name != 'pull_request' }}
107- uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
109+ if : ${{ steps.files_changed .outcome != 'success' && github.event_name != 'pull_request' }}
110+ uses : peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
108111 env :
109112 GH_REPO : ${{ github.repository }}
110113 GH_TOKEN : ${{ github.token }}
@@ -119,5 +122,5 @@ jobs:
119122 reviewers : " godexsoft,kuznetsss,PeterChen13579,mathbunnyru"
120123
121124 - name : Fail the job
122- if : ${{ steps.run_clang_tidy .outcome != 'success' }}
125+ if : ${{ steps.clang_tidy.outcome != 'success' || steps.files_changed .outcome != 'success' }}
123126 run : exit 1
0 commit comments