forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (169 loc) · 8.67 KB
/
static_analysis.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: static_analysis
on:
push:
branches: ['**']
pull_request:
branches: ['**']
jobs:
CppCheck:
name: CppCheck
timeout-minutes: 30
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install
shell: bash
run: |
sudo apt-get update;
sudo apt-get install -qq cppcheck;
- name: Run
shell: bash
#Selected run options:
# ./xxx : Folders to scan
# --quiet : Don't show current checked configuration in log
# --std=c++11 : Use C++11 standard (default but worth mentioning)
# --xml : Output in XML format
# -j4 : Run parallel jobs for a faster scan. current HW is 2 core (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) using 4 to future proof
# --enable : Additional check to run. options are [all, warning, style, performance, protability, information, unusedFunction, missingInclude]
# -I : Include directories
# -i : Ignore directories. Ignore third-party libs that we don't want to check
# --suppress : Don't issue errors about files matching the expression (when -i for folders is not enough)
# --force : Check all configurations, takes a very long time (~2 hours) and did not find additional errors. Removed.
# --max-configs=6 : Using less configuration permutations (default is 12) to reduce run time. Detects less errors. Removed.
# -Dxxx : preprocessor configuration to use. Relevant flags taken from build on Ubuntu.
run: >
cppcheck ./src ./include ./common ./tools ./examples ./third-party/realdds ./third-party/rsutils
--quiet --std=c++11 --xml -j4 --enable=warning
-I./src -I./include -I./third-party/rsutils/include -I./common
-i./src/mf -i./src/uvc -i./src/win -i./src/winusb --suppress=*:third-party/json.hpp
-DBUILD_WITH_DDS -DHWM_OVER_XU -DRS2_USE_V4L2_BACKEND -DUNICODE -DUSING_UDEV -DCHECK_FOR_UPDATES -D__linux__
&> cppcheck_run.log
- name: Diff
id: diff-step
continue-on-error: true
shell: bash
run: |
python3 .github/workflows/cppcheck-parse.py --severity E cppcheck_run.log | sort --key 3 > cppcheck_run.parsed.log
python3 .github/workflows/cppcheck-parse.py --severity E .github/workflows/cppcheck_run.log | sort --key 3 > cppcheck_run.parsed.golden
diff cppcheck_run.parsed.golden cppcheck_run.parsed.log \
&& echo "No diffs found in cppcheck_run.log"
- name: Ensure cppcheck_run.parsed.log was updated
id: diff-parsed-step
continue-on-error: true
shell: bash
run: |
diff cppcheck_run.parsed.golden .github/workflows/cppcheck_run.parsed.log \
&& echo "No diffs found in cppcheck_run.parsed.log"
- name: Upload logs
uses: actions/upload-artifact@v3
with:
name: cppcheck_log
path: |
cppcheck_run.log
cppcheck_run.parsed.log
- name: Provide correct exit status
shell: bash
run: |
ERROR_COUNT=$(grep cppcheck_run.log -e "severity=\"error\"" -c) || ERROR_COUNT=0
EXPECTED_ERROR_COUNT=$(grep .github/workflows/cppcheck_run.log -e "severity=\"error\"" -c) || EXPECTED_ERROR_COUNT=0
if [ $ERROR_COUNT -eq $EXPECTED_ERROR_COUNT ]
then
echo "cppcheck_run succeeded, found" $ERROR_COUNT "errors, as expected"
if [ ${{steps.diff-step.outcome}} == "failure" ]
then
echo "however, the ---> DIFF FAILED <---"
elif [ ${{steps.diff-parsed-step.outcome}} == "failure" ]
then
echo "however, the ---> PARSED log was not UPDATED <---"
else
exit 0
fi
elif [ $ERROR_COUNT -lt $EXPECTED_ERROR_COUNT ]
then
echo "cppcheck_run ---> SUCCEEDED <--- but found" $ERROR_COUNT "errors when expecting" $EXPECTED_ERROR_COUNT
else
echo "cppcheck_run ---> FAILED <--- with" $ERROR_COUNT "errors; expecting" $EXPECTED_ERROR_COUNT
fi
echo "see the diff step above, or the 'cppcheck_log' artifact (under Summary) for details"
echo "commit all files in the artifact to .github/workflows/ if these are valid results"
exit 1
#---------------------------------------------------------------------------------------------------#
# We verify the minimal CMake version we support is preserved when building with default CMake flags
minimal_cmake_version:
name: "Minimal CMake version"
timeout-minutes: 30
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: "Install Dependencies"
run: |
work_dir=$(pwd)
# Go back from RealSense directory to parent directory
cd ..
git clone https://github.com/nlohmann/cmake_min_version.git
cd cmake_min_version
# We clone a specific commit which we tested the process as working
git checkout 687dc56e1cf52c865cebf6ac94ad67906d6e1369
echo "Install LibRealSense pre-installed packages requirements"
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at
python3 -mvenv venv
venv/bin/pip3 install -r requirements.txt
- name: "Get Current CMake version"
id: cmake_version
run: |
work_dir=$(pwd)
cd ..
cd cmake_min_version
venv/bin/python3 cmake_downloader.py --first_minor
output=$(venv/bin/python3 cmake_min_version.py $work_dir)
# Sample of Expected Output of cmake_min_version.py ***
# [ 0%] CMake 3.9.2 ✔ works
# [ 12%] CMake 3.2.2 ✘ error
# CMakeLists.txt:7 (cmake_minimum_required)
# [ 33%] CMake 3.8.0 ✔ works
# [ 50%] CMake 3.7.1 ✘ error
# CMakeLists.txt:16 (target_compile_features)
# [ 80%] CMake 3.7.2 ✘ error
# CMakeLists.txt:16 (target_compile_features)
# [100%] Minimal working version: CMake 3.8.0
# cmake_minimum_required(VERSION 3.8.0)
echo "$output"
# Retrieve CMake minimal version from the last line of the tool output.
current_cmake_version=$(echo ${output} | grep -oP "VERSION \d+\.\d+" || echo "VERSION NOT FOUND")
if [ "$current_cmake_version" == "VERSION NOT FOUND" ]
then
echo "Error - CMake version not found."
exit 1
fi
current_cmake_major_ver=$(echo $current_cmake_version | grep -oP "\d+\.\d+" | cut -d'.' -f 1)
current_cmake_minor_ver=$(echo $current_cmake_version | grep -oP "\d+\.\d+" | cut -d'.' -f 2)
# Saving cmake output in GitHub output
echo "current_cmake_major_ver=$current_cmake_major_ver" >> $GITHUB_OUTPUT
echo "current_cmake_minor_ver=$current_cmake_minor_ver" >> $GITHUB_OUTPUT
- name: "Check minimal CMake version"
env:
EXPECTED_CMAKE_MAJOR_VER: 3
EXPECTED_CMAKE_MINOR_VER: 8
CURRENT_CMAKE_MAJOR_VER: ${{ steps.cmake_version.outputs.current_cmake_major_ver }}
CURRENT_CMAKE_MINOR_VER: ${{ steps.cmake_version.outputs.current_cmake_minor_ver }}
run: |
if [ $CURRENT_CMAKE_MAJOR_VER -lt ${EXPECTED_CMAKE_MAJOR_VER} ]
then
STATUS="PASSED"
elif [ $CURRENT_CMAKE_MAJOR_VER -eq ${EXPECTED_CMAKE_MAJOR_VER} ] && [ $CURRENT_CMAKE_MINOR_VER -eq ${EXPECTED_CMAKE_MINOR_VER} ]
then
STATUS="PASSED"
elif [ $CURRENT_CMAKE_MAJOR_VER -eq ${EXPECTED_CMAKE_MAJOR_VER} ] && [ $CURRENT_CMAKE_MINOR_VER -lt ${EXPECTED_CMAKE_MINOR_VER} ]
then
STATUS="PASSED"
else
STATUS="FAILED"
fi
if [ $STATUS == "PASSED" ]
then
echo "The test PASSED, current CMake version is $CURRENT_CMAKE_MAJOR_VER.$CURRENT_CMAKE_MINOR_VER and it is not higher than VERSION ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER}"
else
echo "Error - The minimal CMake version required for LibRS is ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER} but on this build the minimal CMake version that works is $CURRENT_CMAKE_MAJOR_VER.$CURRENT_CMAKE_MINOR_VER"
exit 1
fi