Skip to content

Commit 27b98c0

Browse files
chore(ci): fix failure condition when modified files are empty (#7704)
* chore(ci): fix failure condition when modified files are empty Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com> * chore: delete unnecessary new line Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com> * chore: delete lidar_centerpoint_tvm package for test Signed-off-by: GitHub <noreply@github.com> * chore(ci): fix workflow conditions Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com> * chore(ci): filter un-existing files in cppcheck-differential Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com> * Revert "chore: delete lidar_centerpoint_tvm package for test" This reverts commit 3b8bcb3. * chore: fix pre-commit errors Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com> --------- Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com> Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Simon Eisenmann <simon.eisenmann@driveblocks.ai>
1 parent 92c78e7 commit 27b98c0

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

.github/workflows/cppcheck-differential.yaml

+9-13
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,33 @@ jobs:
3131
run: git fetch origin ${{ github.base_ref }}
3232
shell: bash
3333

34-
- name: Get changed files
35-
id: changed-files
34+
- name: Get changed files (existing files only)
35+
id: get-changed-files
3636
run: |
37-
git diff --name-only "origin/${{ github.base_ref }}"...HEAD > changed_files.txt
38-
cat changed_files.txt
37+
echo "changed-files=$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD | grep -E '\.(cpp|hpp)$' | while read -r file; do [ -e "$file" ] && echo -n "$file "; done)" >> $GITHUB_OUTPUT
3938
shell: bash
4039

4140
- name: Run Cppcheck on changed files
41+
if: ${{ steps.get-changed-files.outputs.changed-files != '' }}
4242
continue-on-error: true
4343
id: cppcheck
4444
run: |
45-
files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true)
46-
if [ -n "$files" ]; then
47-
echo "Running Cppcheck on changed files: $files"
48-
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt
49-
else
50-
echo "No C++ files changed."
51-
touch cppcheck-report.txt
52-
fi
45+
echo "Running Cppcheck on changed files: ${{ steps.get-changed-files.outputs.changed-files }}"
46+
cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions ${{ steps.get-changed-files.outputs.changed-files }} 2> cppcheck-report.txt
5347
shell: bash
5448

5549
- name: Show cppcheck-report result
50+
if: ${{ steps.get-changed-files.outputs.changed-files != '' }}
5651
run: |
5752
cat cppcheck-report.txt
5853
5954
- name: Upload Cppcheck report
55+
if: ${{ steps.get-changed-files.outputs.changed-files != '' }}
6056
uses: actions/upload-artifact@v2
6157
with:
6258
name: cppcheck-report
6359
path: cppcheck-report.txt
6460

6561
- name: Fail the job if Cppcheck failed
66-
if: steps.cppcheck.outcome == 'failure'
62+
if: ${{ steps.get-changed-files.outputs.changed-files != '' && steps.cppcheck.outcome == 'failure' }}
6763
run: exit 1

0 commit comments

Comments
 (0)