diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index 59254d85d3367..f837756d2dbc2 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -31,35 +31,33 @@ jobs: run: git fetch origin ${{ github.base_ref }} shell: bash - - name: Get modified files - id: get-modified-files + - name: Get changed files + id: get-changed-files run: | - echo "changed_files=$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD | grep -E '\.(cpp|hpp)$' | tr '\n' ' ' || true)" >> $GITHUB_OUTPUT + echo "changed-files=$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD | grep -E '\.(cpp|hpp)$' | tr '\n' ' ' || true)" >> $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: ${{ steps.get-modified-files.outputs.changed_files }}" - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions ${{ steps.get-modified-files.outputs.changed_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.get-modified-files.outputs.changed_files != '' && steps.cppcheck.outcome == 'failure' }} + if: ${{ steps.get-changed-files.outputs.changed-files != '' && steps.cppcheck.outcome == 'failure' }} run: exit 1