Skip to content

fix(pose_instability_detector): fix a rare error #1854

fix(pose_instability_detector): fix a rare error

fix(pose_instability_detector): fix a rare error #1854

name: cppcheck-differential
on:
pull_request:
jobs:
cppcheck-differential:
runs-on: ubuntu-latest
steps:
- name: Set PR fetch depth
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- name: Checkout PR branch and all PR commits
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git
# cppcheck from apt does not yet support --check-level args, and thus install from snap
- name: Install Cppcheck from snap
run: |
sudo snap install cppcheck
- name: Fetch the base branch with enough history for a common merge-base commit
run: git fetch origin ${{ github.base_ref }}
shell: bash
- name: Get changed files
id: changed-files
run: |
git diff --name-only "origin/${{ github.base_ref }}"...HEAD > changed_files.txt
cat changed_files.txt
shell: bash
- name: Run Cppcheck on 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
shell: bash
- name: Show cppcheck-report result
run: |
cat cppcheck-report.txt
- name: Upload Cppcheck report
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'
run: exit 1