From ea784b81c6e23b9ffb9827bb7bfee08357253b02 Mon Sep 17 00:00:00 2001 From: kobayu858 Date: Tue, 10 Dec 2024 13:47:29 +0900 Subject: [PATCH 1/3] refactor: error check Signed-off-by: kobayu858 --- clang-tidy/action.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 1488000b..d899659d 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -139,7 +139,9 @@ runs: if: ${{ steps.get-target-files.outputs.target-files != '' }} run: | mkdir /tmp/clang-tidy-result - run-clang-tidy -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log || true + run-clang-tidy -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log && true + exit_code=$? + echo "exit_code=$exit_code" >> $GITHUB_ENV echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt @@ -165,9 +167,6 @@ runs: path: /tmp/clang-tidy-result/ - name: Mark the workflow as failed if clang-tidy find an error - if: ${{ steps.check-report-txt-existence.outputs.exists == 'true' }} - run: | - if [ -n "$(grep ": error:" /tmp/clang-tidy-result/report.log)" ]; then - exit 1 - fi + if: ${{ env.exit_code != '0' }} + run: exit 1 shell: bash From ccbbf16273d98e10202af32174a8a993ad7350db Mon Sep 17 00:00:00 2001 From: kobayu858 Date: Tue, 10 Dec 2024 17:04:01 +0900 Subject: [PATCH 2/3] refactor: txt -> log Signed-off-by: kobayu858 --- clang-tidy/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index d899659d..302f91cb 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -148,7 +148,7 @@ runs: shell: bash - name: Check if the report.log file exists - id: check-report-txt-existence + id: check-report-log-existence uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 with: files: /tmp/clang-tidy-result/report.log @@ -160,7 +160,7 @@ runs: files: /tmp/clang-tidy-result/fixes.yaml - name: Upload artifacts - if: ${{ steps.check-report-txt-existence.outputs.exists == 'true' && steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + if: ${{ steps.check-report-log-existence.outputs.exists == 'true' && steps.check-fixes-yaml-existence.outputs.exists == 'true' }} uses: actions/upload-artifact@v4 with: name: clang-tidy-result From 4a686319351290b27ef0a3680b2ba3161e8d6610 Mon Sep 17 00:00:00 2001 From: kobayu858 Date: Tue, 10 Dec 2024 19:13:29 +0900 Subject: [PATCH 3/3] refactor: one line Signed-off-by: kobayu858 --- clang-tidy/action.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 302f91cb..81ea18d2 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -140,8 +140,7 @@ runs: run: | mkdir /tmp/clang-tidy-result run-clang-tidy -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml -j $(nproc) ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.log && true - exit_code=$? - echo "exit_code=$exit_code" >> $GITHUB_ENV + echo "exit_code=$?" >> $GITHUB_ENV echo "${{ github.event.number }}" > /tmp/clang-tidy-result/pr-id.txt echo "${{ github.event.pull_request.head.repo.full_name }}" > /tmp/clang-tidy-result/pr-head-repo.txt echo "${{ github.event.pull_request.head.ref }}" > /tmp/clang-tidy-result/pr-head-ref.txt