Skip to content

Commit

Permalink
modify cppcheck-differential
Browse files Browse the repository at this point in the history
Signed-off-by: ISP akm <akm@isp.co.jp>
  • Loading branch information
xygyo77 committed Jun 21, 2024
1 parent 794d37e commit 11d6de5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 38 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/cppcheck-all-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,18 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git libpcre3-dev wget
sudo apt-get install -y build-essential wget
# 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
# Download the cppcheck suppression file
- name: Download cppcheck suppression file
run: |
wget https://raw.githubusercontent.com/autowarefoundation/autoware.universe/main/.cppcheck_suppressions -O .cppcheck_suppressions
# 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 all C++ files
id: all-files
run: |
Expand Down
52 changes: 28 additions & 24 deletions .github/workflows/cppcheck-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,49 @@ on:
jobs:
cppcheck-differential:
runs-on: ubuntu-latest

container: ros:humble
needs: build-and-test-differential
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git libpcre3-dev wget
sudo apt-get install -y wget
# 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
# Download the cppcheck suppression file
- name: Download cppcheck suppression file
run: |
wget https://raw.githubusercontent.com/autowarefoundation/autoware.universe/main/.cppcheck_suppressions -O .cppcheck_suppressions
# 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: Remove exec_depend
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1

- 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 modified packages
id: get-modified-packages
uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1

- name: Get modified files
id: get-modified-files
uses: tj-actions/changed-files@v44
with:
files: |
**/*.cpp
**/*.hpp
- name: Run Cppcheck on changed files
continue-on-error: true
id: cppcheck
run: |
files=$(cat changed_files.txt | grep -E '\.(cpp|hpp)$' || true)
files=$(steps.get-modified-files.outputs.all_changed_files)
if [ -n "$files" ]; then
echo "Running Cppcheck on changed files: $files"
cppcheck --inline-suppr --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt
Expand All @@ -60,11 +63,12 @@ jobs:
cat cppcheck-report.txt
- name: Upload Cppcheck report
uses: actions/upload-artifact@v4
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

0 comments on commit 11d6de5

Please sign in to comment.