Skip to content

Commit 558560e

Browse files
committed
Add cppcheck in CI
1 parent b89fbde commit 558560e

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/cppcheck.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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-latest
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 --no-install-recommends --no-install-suggests \
22+
build-essential \
23+
cppcheck \
24+
cmake \
25+
ninja-build \
26+
libssl-dev \
27+
libcurl4-openssl-dev \
28+
libprotobuf-dev \
29+
protobuf-compiler \
30+
libgmock-dev \
31+
libgtest-dev \
32+
libbenchmark-dev
33+
34+
- name: Prepare CMake
35+
run: |
36+
mkdir build && cd build
37+
CC="clang" CXX="clang++" cmake ..
38+
39+
- name: Run cppcheck
40+
run: |
41+
cppcheck \
42+
--force \
43+
--quiet \
44+
--enable=warning,performance,portability \
45+
--inline-suppr \
46+
--suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \
47+
--language=c++ \
48+
--std=c++14 \
49+
-I api/include \
50+
-I exporters/elasticsearch/include \
51+
-I exporters/etw/include \
52+
-I exporters/memory/include \
53+
-I exporters/ostream/include \
54+
-I exporters/otlp/include \
55+
-I exporters/prometheus/include \
56+
-I exporters/zipkin/include \
57+
-I ext/include \
58+
-I opentracing-shim/include \
59+
-I sdk/include \
60+
-i build \
61+
-i test \
62+
-i third_party \
63+
-j $(nproc) \
64+
. 2>&1 | tee cppcheck.log
65+
66+
- uses: actions/upload-artifact@v4
67+
if: success() || failure()
68+
with:
69+
name: Logs (cppcheck)
70+
path: ./cppcheck.log
71+
72+
- name: Count warnings
73+
run: |
74+
set +e
75+
COUNT=`grep -c -E "\[.+\]" cppcheck.log`
76+
echo "cppcheck reported ${COUNT} warning(s)"
77+
if [ $COUNT -ne 0 ] ; then exit 1 ; fi

0 commit comments

Comments
 (0)