Skip to content

Commit

Permalink
add cppcheck-all-files and remove clang-tidy-differential
Browse files Browse the repository at this point in the history
Signed-off-by: ISP akm <[email protected]>
  • Loading branch information
xygyo77 committed Jun 20, 2024
1 parent 5de7f01 commit b08a628
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 36 deletions.
37 changes: 1 addition & 36 deletions .github/workflows/build-and-test-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,4 @@ jobs:
files: ${{ steps.test.outputs.coverage-report-files }}
fail_ci_if_error: false
verbose: true
flags: differential

clang-tidy-differential:
runs-on: ubuntu-latest
container: ros:humble
needs: build-and-test-differential
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Remove exec_depend
uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1

- 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 clang-tidy
if: ${{ steps.get-modified-files.outputs.all_changed_files != '' }}
uses: autowarefoundation/autoware-github-actions/clang-tidy@v1
with:
rosdistro: humble
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
target-files: ${{ steps.get-modified-files.outputs.all_changed_files }}
clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy
build-depends-repos: build_depends.repos
flags: differential
69 changes: 69 additions & 0 deletions .github/workflows/cppcheck-all-files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: cppcheck-all-files

on:
workflow_dispatch:

jobs:
cppcheck-full:
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 wget

Check warning on line 17 in .github/workflows/cppcheck-all-files.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (libpcre)
# 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)

Check warning on line 29 in .github/workflows/cppcheck-all-files.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (nproc)
sudo make install
# 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
- name: Get all C++ files
id: all-files
run: |
find . -type f \( -name "*.cpp" -o -name "*.hpp" \) > all_files.txt
cat all_files.txt
- name: Run Cppcheck on all files
continue-on-error: true
id: cppcheck
run: |
files=$(cat all_files.txt)
if [ -n "$files" ]; then
echo "Running Cppcheck on all files: $files"
cppcheck --inline-suppr --enable=all --inconclusive --check-level=exhaustive --error-exitcode=1 --suppressions-list=.cppcheck_suppressions $files 2> cppcheck-report.txt

Check warning on line 50 in .github/workflows/cppcheck-all-files.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (suppr)
else
echo "No C++ files found."
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@v4
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 b08a628

Please sign in to comment.