Skip to content

Commit

Permalink
feat(clang-tidy): determine error using exit_code (#329)
Browse files Browse the repository at this point in the history
Signed-off-by: kobayu858 <[email protected]>
  • Loading branch information
kobayu858 authored Dec 11, 2024
1 parent 196ca1d commit f959598
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions clang-tidy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit f959598

Please sign in to comment.