-
Notifications
You must be signed in to change notification settings - Fork 10
83 lines (69 loc) · 2.54 KB
/
cppcheck-differential.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: cppcheck-differential
on:
pull_request:
jobs:
cppcheck-differential:
runs-on: ubuntu-latest
steps:
- 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 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
- 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
# Display the modified packages
- name: Show modified packages
run: |
echo "Modified packages:"
echo "${{ steps.get-modified-packages.outputs.modified_packages }}"
- name: Get modified files
id: get-modified-files
uses: tj-actions/changed-files@v45
with:
files: |
**/*.cpp
**/*.hpp
# Display the modified files
- name: Show modified files
run: |
echo "Modified files:"
echo "${{ steps.get-modified-files.outputs.all_changed_files }}"
- name: Run Cppcheck on changed files
continue-on-error: true
id: cppcheck
run: |
files=$(echo ${{ 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
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@v4
with:
name: cppcheck-report
path: cppcheck-report.txt
- name: Fail the job if Cppcheck failed
if: steps.cppcheck.outcome == 'failure'
run: exit 1