From 3b6e0882dc268edd1f9e04483cc9a028eec8f64e Mon Sep 17 00:00:00 2001 From: Kotaro Yoshimoto Date: Wed, 26 Jun 2024 17:02:22 +0900 Subject: [PATCH] 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 * chore: delete unnecessary new line Signed-off-by: Kotaro Yoshimoto * chore: delete lidar_centerpoint_tvm package for test Signed-off-by: GitHub * chore(ci): fix workflow conditions Signed-off-by: Kotaro Yoshimoto * chore(ci): filter un-existing files in cppcheck-differential Signed-off-by: Kotaro Yoshimoto * Revert "chore: delete lidar_centerpoint_tvm package for test" This reverts commit 3b8bcb3d1f253cf1ed85928f771b2aa837b41414. * chore: fix pre-commit errors Signed-off-by: Kotaro Yoshimoto --------- Signed-off-by: Kotaro Yoshimoto Signed-off-by: GitHub --- .github/workflows/cppcheck-differential.yaml | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 99f8aa1311b5e..7fe37ea006596 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -31,37 +31,33 @@ jobs: run: git fetch origin ${{ github.base_ref }} shell: bash - - name: Get changed files - id: changed-files + - name: Get changed files (existing files only) + id: get-changed-files run: | - git diff --name-only "origin/${{ github.base_ref }}"...HEAD > changed_files.txt - cat changed_files.txt + 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 shell: bash - name: Run Cppcheck on changed files + if: ${{ steps.get-changed-files.outputs.changed-files != '' }} continue-on-error: true id: cppcheck run: | - files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true) - if [ -n "$files" ]; then - echo "Running Cppcheck on changed files: $files" - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt - else - echo "No C++ files changed." - touch cppcheck-report.txt - fi + echo "Running Cppcheck on changed files: ${{ steps.get-changed-files.outputs.changed-files }}" + 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 shell: bash - name: Show cppcheck-report result + if: ${{ steps.get-changed-files.outputs.changed-files != '' }} run: | cat cppcheck-report.txt - name: Upload Cppcheck report + if: ${{ steps.get-changed-files.outputs.changed-files != '' }} uses: actions/upload-artifact@v2 with: name: cppcheck-report path: cppcheck-report.txt - name: Fail the job if Cppcheck failed - if: steps.cppcheck.outcome == 'failure' + if: ${{ steps.get-changed-files.outputs.changed-files != '' && steps.cppcheck.outcome == 'failure' }} run: exit 1