Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clang-tidy): determine error using exit_code #329

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions clang-tidy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
if [ "${{ inputs.target-files }}" != "" ]; then
target_files="${{ inputs.target-files }}"
else
mapfile -t package_paths < <(colcon list --paths-only --packages-select ${{ inputs.target-packages }})

Check warning on line 116 in clang-tidy/action.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (mapfile)
ignore_patterns=()
ignore_patterns+=( -not -path "*/test/*" )
if [ -f ${{ inputs.clang-tidy-ignore-path }} ]; then
Expand All @@ -139,14 +139,16 @@
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
veqcc marked this conversation as resolved.
Show resolved Hide resolved
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
veqcc marked this conversation as resolved.
Show resolved Hide resolved
uses: autowarefoundation/autoware-github-actions/check-file-existence@v1
with:
files: /tmp/clang-tidy-result/report.log
Expand All @@ -158,16 +160,13 @@
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
Loading