@@ -53,31 +53,43 @@ jobs:
53
53
done
54
54
echo "full-paths=$paths" >> $GITHUB_OUTPUT
55
55
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
+
56
67
# cspell: ignore suppr
57
68
- 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 != '' }}
59
70
continue-on-error : true
60
71
id : cppcheck
61
72
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
64
75
shell : bash
65
76
66
77
- name : Setup Problem Matchers for cppcheck
78
+ if : ${{ steps.filter-paths-no-cpp-files.outputs.filtered-full-paths != '' }}
67
79
run : echo "::add-matcher::.github/cppcheck-problem-matcher.json"
68
80
69
81
- 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 != '' }}
71
83
run : |
72
84
cat cppcheck-report.txt
73
85
74
86
- 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 != '' }}
76
88
uses : actions/upload-artifact@v2
77
89
with :
78
90
name : cppcheck-report
79
91
path : cppcheck-report.txt
80
92
81
93
- 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' }}
83
95
run : exit 1
0 commit comments