From 6948f0ba0626a39a642877e40accc09fd67e96e9 Mon Sep 17 00:00:00 2001 From: kminoda Date: Wed, 5 Jun 2024 10:05:15 +0900 Subject: [PATCH] fix pre-commit Signed-off-by: kminoda --- .github/workflows/cppcheck-all.yaml | 94 +++++++++---------- .github/workflows/cppcheck-differential.yaml | 96 ++++++++++---------- 2 files changed, 95 insertions(+), 95 deletions(-) diff --git a/.github/workflows/cppcheck-all.yaml b/.github/workflows/cppcheck-all.yaml index 2730befcb0124..db3bd5d259895 100644 --- a/.github/workflows/cppcheck-all.yaml +++ b/.github/workflows/cppcheck-all.yaml @@ -11,50 +11,50 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake git libpcre3-dev - - # cppcheck from apt does not yet support --check-level args, and thus install from source - - name: Install Cppcheck from source - run: | - mkdir /tmp/cppcheck - git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck - cd /tmp/cppcheck - git checkout 2.14.1 - mkdir build - cd build - cmake .. - make -j $(nproc) - sudo make install - - - name: Run Cppcheck on all files - continue-on-error: true - id: cppcheck - run: | - cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml - shell: bash - - - name: Count errors by error ID and severity - run: | - #!/bin/bash - temp_file=$(mktemp) - grep -oP '(?<=id=")[^"]+" severity="[^"]+' cppcheck-report.xml | sed 's/" severity="/,/g' > "$temp_file" - echo "Error counts by error ID and severity:" - sort "$temp_file" | uniq -c - rm "$temp_file" - shell: bash - - - name: Upload Cppcheck report - uses: actions/upload-artifact@v2 - with: - name: cppcheck-report - path: cppcheck-report.xml - - - name: Fail the job if Cppcheck failed - if: steps.cppcheck.outcome == 'failure' - run: exit 1 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libpcre3-dev + + # cppcheck from apt does not yet support --check-level args, and thus install from source + - name: Install Cppcheck from source + run: | + mkdir /tmp/cppcheck + git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck + cd /tmp/cppcheck + git checkout 2.14.1 + mkdir build + cd build + cmake .. + make -j $(nproc) + sudo make install + + - name: Run Cppcheck on all files + continue-on-error: true + id: cppcheck + run: | + cppcheck --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --xml . 2> cppcheck-report.xml + shell: bash + + - name: Count errors by error ID and severity + run: | + #!/bin/bash + temp_file=$(mktemp) + grep -oP '(?<=id=")[^"]+" severity="[^"]+' cppcheck-report.xml | sed 's/" severity="/,/g' > "$temp_file" + echo "Error counts by error ID and severity:" + sort "$temp_file" | uniq -c + rm "$temp_file" + shell: bash + + - name: Upload Cppcheck report + uses: actions/upload-artifact@v2 + with: + name: cppcheck-report + path: cppcheck-report.xml + + - name: Fail the job if Cppcheck failed + if: steps.cppcheck.outcome == 'failure' + run: exit 1 diff --git a/.github/workflows/cppcheck-differential.yaml b/.github/workflows/cppcheck-differential.yaml index dcb448f641ba0..914abd7df86ea 100644 --- a/.github/workflows/cppcheck-differential.yaml +++ b/.github/workflows/cppcheck-differential.yaml @@ -8,58 +8,58 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake git libpcre3-dev + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libpcre3-dev - # cppcheck from apt does not yet support --check-level args, and thus install from source - - name: Install Cppcheck from source - run: | - mkdir /tmp/cppcheck - git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck - cd /tmp/cppcheck - git checkout 2.14.1 - mkdir build - cd build - cmake .. - make -j $(nproc) - sudo make install + # cppcheck from apt does not yet support --check-level args, and thus install from source + - name: Install Cppcheck from source + run: | + mkdir /tmp/cppcheck + git clone https://github.com/danmar/cppcheck.git /tmp/cppcheck + cd /tmp/cppcheck + git checkout 2.14.1 + mkdir build + cd build + cmake .. + make -j $(nproc) + sudo make install - - name: Get changed files - id: changed-files - run: | - git fetch origin ${{ github.base_ref }} --depth=1 - git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt - cat changed_files.txt + - name: Get changed files + id: changed-files + run: | + git fetch origin ${{ github.base_ref }} --depth=1 + git diff --name-only FETCH_HEAD ${{ github.sha }} > changed_files.txt + cat changed_files.txt - - 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: 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: 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: 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 + - name: Fail the job if Cppcheck failed + if: steps.cppcheck.outcome == 'failure' + run: exit 1