From f959598e073cef93da3323e78187472a9efeb601 Mon Sep 17 00:00:00 2001 From: kobayu858 <129580202+kobayu858@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:18:50 +0900 Subject: [PATCH] feat(clang-tidy): determine error using exit_code (#329) Signed-off-by: kobayu858 --- clang-tidy/action.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/clang-tidy/action.yaml b/clang-tidy/action.yaml index 1488000b..81ea18d2 100644 --- a/clang-tidy/action.yaml +++ b/clang-tidy/action.yaml @@ -139,14 +139,15 @@ 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 + 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 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 @@ -158,16 +159,13 @@ 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 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