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): introducing .clang-tidy-ignore #326

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from 1 commit
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
35 changes: 22 additions & 13 deletions clang-tidy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
runs:
using: composite
steps:
- name: Show targets
run: |
echo "target packages: ${{ inputs.target-packages }}"
echo "target files: ${{ inputs.target-files }}"
shell: bash

- name: Install curl
run: |
sudo apt-get -yqq update
Expand Down Expand Up @@ -115,28 +109,43 @@
if [ "${{ inputs.target-files }}" != "" ]; then
target_files="${{ inputs.target-files }}"
else
package_path=$(colcon list --paths-only --packages-select ${{ inputs.target-packages }})
target_files=$(find $package_path -type f \( -name '*.cpp' -o -name '*.hpp' \) -not -path '*/test/*' -not -path '*/examples/*')
mapfile -t package_paths < <(colcon list --paths-only --packages-select ${{ inputs.target-packages }})

Check warning on line 112 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 .clang-tidy-ignore ]; then
mitsudome-r marked this conversation as resolved.
Show resolved Hide resolved
while IFS= read -r pattern; do
ignore_patterns+=( -not -path "$pattern" )
done < .clang-tidy-ignore
fi
target_files=$(find "${package_paths[@]}" -name '*.cpp' "${ignore_patterns[@]}" | tr '\n' ' ')
fi

echo "target-files=$target_files" >> $GITHUB_OUTPUT
shell: bash

- name: Show target files
if: ${{ steps.get-target-files.outputs.target-files != '' }}
run: |
echo "Target files:"
for file in "${{ steps.get-target-files.outputs.target-files }}" ; do
echo $file
done
shell: bash

- name: Analyze
if: ${{ steps.get-target-files.outputs.target-files != '' }}
run: |
mkdir /tmp/clang-tidy-result
clang-tidy -p build/ -export-fixes /tmp/clang-tidy-result/fixes.yaml ${{ steps.get-target-files.outputs.target-files }} > /tmp/clang-tidy-result/report.txt || 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 "${{ 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.txt file exists
- name: Check if the report.log file exists
veqcc marked this conversation as resolved.
Show resolved Hide resolved
id: check-report-txt-existence
uses: autowarefoundation/autoware-github-actions/check-file-existence@v1
with:
files: /tmp/clang-tidy-result/report.txt
files: /tmp/clang-tidy-result/report.log

- name: Check if the fixes.yaml file exists
id: check-fixes-yaml-existence
Expand All @@ -154,7 +163,7 @@
- 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.txt)" ]; then
if [ -n "$(grep ": error:" /tmp/clang-tidy-result/report.log)" ]; then
exit 1
fi
shell: bash
Loading