Skip to content

Commit 8691248

Browse files
authored
[CI] Add cppcheck in the build (#3151)
1 parent 1695253 commit 8691248

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/cppcheck.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
name: cppcheck
3+
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
cppcheck:
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: 'recursive'
17+
18+
- name: Set up dependencies
19+
run: |
20+
sudo apt update -y
21+
sudo apt install -y cppcheck
22+
23+
- name: Run cppcheck
24+
run: |
25+
cppcheck --version | tee cppcheck.log
26+
cppcheck \
27+
--force \
28+
--enable=warning,performance,portability \
29+
--inline-suppr \
30+
--suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \
31+
--language=c++ \
32+
--std=c++14 \
33+
-I api/include \
34+
-I exporters/elasticsearch/include \
35+
-I exporters/etw/include \
36+
-I exporters/memory/include \
37+
-I exporters/ostream/include \
38+
-I exporters/otlp/include \
39+
-I exporters/prometheus/include \
40+
-I exporters/zipkin/include \
41+
-I ext/include \
42+
-I opentracing-shim/include \
43+
-I sdk/include \
44+
-i build \
45+
-i test \
46+
-i third_party \
47+
-j $(nproc) \
48+
. 2>&1 | tee --append cppcheck.log
49+
50+
- uses: actions/upload-artifact@v4
51+
if: success() || failure()
52+
with:
53+
name: Logs (cppcheck)
54+
path: ./cppcheck.log
55+
56+
- name: Count warnings
57+
run: |
58+
set +e
59+
COUNT=`grep -c -E "\[.+\]" cppcheck.log`
60+
echo "cppcheck reported ${COUNT} warning(s)"
61+
# TODO: uncomment to enforce failing the build
62+
# if [ $COUNT -ne 0 ] ; then exit 1 ; fi

0 commit comments

Comments
 (0)