Skip to content

Commit 32bcee7

Browse files
veqccpalas21
authored andcommitted
fix(ci): skip when modified package has no cpp/hpp files (autowarefoundation#7829)
* fix(ci): skip when modified package has no cpp/hpp files Signed-off-by: veqcc <ryuta.kambe@tier4.jp> * test Signed-off-by: veqcc <ryuta.kambe@tier4.jp> * fix Signed-off-by: veqcc <ryuta.kambe@tier4.jp> * restore Signed-off-by: veqcc <ryuta.kambe@tier4.jp> --------- Signed-off-by: veqcc <ryuta.kambe@tier4.jp> Signed-off-by: palas21 <palas21@itu.edu.tr>
1 parent 89098b3 commit 32bcee7

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

.github/workflows/cppcheck-differential.yaml

+18-6
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,43 @@ jobs:
5353
done
5454
echo "full-paths=$paths" >> $GITHUB_OUTPUT
5555
56+
- name: Filter packages with no cpp/hpp files
57+
id: filter-paths-no-cpp-files
58+
run: |
59+
filtered_paths=""
60+
for dir in ${{ steps.get-full-paths.outputs.full-paths }}; do
61+
if [ -d "$dir" ] && find "$dir" -name "*.cpp" -o -name "*.hpp" | grep -q .; then
62+
filtered_paths="$filtered_paths $dir"
63+
fi
64+
done
65+
echo "filtered-full-paths=$filtered_paths" >> $GITHUB_OUTPUT
66+
5667
# cspell: ignore suppr
5768
- name: Run Cppcheck on modified packages
58-
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
69+
if: ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths != '' }}
5970
continue-on-error: true
6071
id: cppcheck
6172
run: |
62-
echo "Running Cppcheck on modified packages: ${{ steps.get-modified-packages.outputs.modified-packages }}"
63-
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions --inline-suppr ${{ steps.get-full-paths.outputs.full-paths }} 2> cppcheck-report.txt
73+
echo "Running Cppcheck on modified packages: ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths }}"
74+
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions --inline-suppr ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths }} 2> cppcheck-report.txt
6475
shell: bash
6576

6677
- name: Setup Problem Matchers for cppcheck
78+
if: ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths != '' }}
6779
run: echo "::add-matcher::.github/cppcheck-problem-matcher.json"
6880

6981
- name: Show cppcheck-report result
70-
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
82+
if: ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths != '' }}
7183
run: |
7284
cat cppcheck-report.txt
7385
7486
- name: Upload Cppcheck report
75-
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
87+
if: ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths != '' }}
7688
uses: actions/upload-artifact@v2
7789
with:
7890
name: cppcheck-report
7991
path: cppcheck-report.txt
8092

8193
- name: Fail the job if Cppcheck failed
82-
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' && steps.cppcheck.outcome == 'failure' }}
94+
if: ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths != '' && steps.cppcheck.outcome == 'failure' }}
8395
run: exit 1

0 commit comments

Comments
 (0)