From 3f7187a5b1a71a6ca9843fd88e7f17d8f5683ae3 Mon Sep 17 00:00:00 2001 From: Alex E Date: Mon, 18 Nov 2024 00:25:32 -0500 Subject: [PATCH 1/3] Add cppcheck in CI --- .github/workflows/cppcheck.yml | 77 ++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/cppcheck.yml diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml new file mode 100644 index 0000000000..0cdaee419f --- /dev/null +++ b/.github/workflows/cppcheck.yml @@ -0,0 +1,77 @@ + +name: cppcheck + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + cppcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up dependencies + run: | + sudo apt update -y + sudo apt install -y --no-install-recommends --no-install-suggests \ + build-essential \ + cppcheck \ + cmake \ + ninja-build \ + libssl-dev \ + libcurl4-openssl-dev \ + libprotobuf-dev \ + protobuf-compiler \ + libgmock-dev \ + libgtest-dev \ + libbenchmark-dev + + - name: Prepare CMake + run: | + mkdir build && cd build + CC="clang" CXX="clang++" cmake .. + + - name: Run cppcheck + run: | + cppcheck \ + --force \ + --quiet \ + --enable=warning,performance,portability \ + --inline-suppr \ + --suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \ + --language=c++ \ + --std=c++14 \ + -I api/include \ + -I exporters/elasticsearch/include \ + -I exporters/etw/include \ + -I exporters/memory/include \ + -I exporters/ostream/include \ + -I exporters/otlp/include \ + -I exporters/prometheus/include \ + -I exporters/zipkin/include \ + -I ext/include \ + -I opentracing-shim/include \ + -I sdk/include \ + -i build \ + -i test \ + -i third_party \ + -j $(nproc) \ + . 2>&1 | tee cppcheck.log + + - uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: Logs (cppcheck) + path: ./cppcheck.log + + - name: Count warnings + run: | + set +e + COUNT=`grep -c -E "\[.+\]" cppcheck.log` + echo "cppcheck reported ${COUNT} warning(s)" + if [ $COUNT -ne 0 ] ; then exit 1 ; fi From 0a7c170f738fb35e8dbc6560d553f25a37880041 Mon Sep 17 00:00:00 2001 From: Alex E Date: Mon, 18 Nov 2024 02:25:01 -0500 Subject: [PATCH 2/3] Put back some verbosity --- .github/workflows/cppcheck.yml | 153 ++++++++++++++++----------------- 1 file changed, 76 insertions(+), 77 deletions(-) diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 0cdaee419f..79344f14e0 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -1,77 +1,76 @@ - -name: cppcheck - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - cppcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Set up dependencies - run: | - sudo apt update -y - sudo apt install -y --no-install-recommends --no-install-suggests \ - build-essential \ - cppcheck \ - cmake \ - ninja-build \ - libssl-dev \ - libcurl4-openssl-dev \ - libprotobuf-dev \ - protobuf-compiler \ - libgmock-dev \ - libgtest-dev \ - libbenchmark-dev - - - name: Prepare CMake - run: | - mkdir build && cd build - CC="clang" CXX="clang++" cmake .. - - - name: Run cppcheck - run: | - cppcheck \ - --force \ - --quiet \ - --enable=warning,performance,portability \ - --inline-suppr \ - --suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \ - --language=c++ \ - --std=c++14 \ - -I api/include \ - -I exporters/elasticsearch/include \ - -I exporters/etw/include \ - -I exporters/memory/include \ - -I exporters/ostream/include \ - -I exporters/otlp/include \ - -I exporters/prometheus/include \ - -I exporters/zipkin/include \ - -I ext/include \ - -I opentracing-shim/include \ - -I sdk/include \ - -i build \ - -i test \ - -i third_party \ - -j $(nproc) \ - . 2>&1 | tee cppcheck.log - - - uses: actions/upload-artifact@v4 - if: success() || failure() - with: - name: Logs (cppcheck) - path: ./cppcheck.log - - - name: Count warnings - run: | - set +e - COUNT=`grep -c -E "\[.+\]" cppcheck.log` - echo "cppcheck reported ${COUNT} warning(s)" - if [ $COUNT -ne 0 ] ; then exit 1 ; fi + +name: cppcheck + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + cppcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up dependencies + run: | + sudo apt update -y + sudo apt install -y --no-install-recommends --no-install-suggests \ + build-essential \ + cppcheck \ + cmake \ + ninja-build \ + libssl-dev \ + libcurl4-openssl-dev \ + libprotobuf-dev \ + protobuf-compiler \ + libgmock-dev \ + libgtest-dev \ + libbenchmark-dev + + - name: Prepare CMake + run: | + mkdir build && cd build + CC="clang" CXX="clang++" cmake .. + + - name: Run cppcheck + run: | + cppcheck \ + --force \ + --enable=warning,performance,portability \ + --inline-suppr \ + --suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \ + --language=c++ \ + --std=c++14 \ + -I api/include \ + -I exporters/elasticsearch/include \ + -I exporters/etw/include \ + -I exporters/memory/include \ + -I exporters/ostream/include \ + -I exporters/otlp/include \ + -I exporters/prometheus/include \ + -I exporters/zipkin/include \ + -I ext/include \ + -I opentracing-shim/include \ + -I sdk/include \ + -i build \ + -i test \ + -i third_party \ + -j $(nproc) \ + . 2>&1 | tee cppcheck.log + + - uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: Logs (cppcheck) + path: ./cppcheck.log + + - name: Count warnings + run: | + set +e + COUNT=`grep -c -E "\[.+\]" cppcheck.log` + echo "cppcheck reported ${COUNT} warning(s)" + if [ $COUNT -ne 0 ] ; then exit 1 ; fi From e343d541d893f0154d9e56639ee05c498e349bac Mon Sep 17 00:00:00 2001 From: Alex E Date: Mon, 18 Nov 2024 17:29:46 -0500 Subject: [PATCH 3/3] Clean up cppcheck CI --- .github/workflows/cppcheck.yml | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 79344f14e0..a6581634bc 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -9,7 +9,7 @@ on: jobs: cppcheck: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: @@ -18,26 +18,11 @@ jobs: - name: Set up dependencies run: | sudo apt update -y - sudo apt install -y --no-install-recommends --no-install-suggests \ - build-essential \ - cppcheck \ - cmake \ - ninja-build \ - libssl-dev \ - libcurl4-openssl-dev \ - libprotobuf-dev \ - protobuf-compiler \ - libgmock-dev \ - libgtest-dev \ - libbenchmark-dev - - - name: Prepare CMake - run: | - mkdir build && cd build - CC="clang" CXX="clang++" cmake .. + sudo apt install -y cppcheck - name: Run cppcheck run: | + cppcheck --version | tee cppcheck.log cppcheck \ --force \ --enable=warning,performance,portability \ @@ -60,7 +45,7 @@ jobs: -i test \ -i third_party \ -j $(nproc) \ - . 2>&1 | tee cppcheck.log + . 2>&1 | tee --append cppcheck.log - uses: actions/upload-artifact@v4 if: success() || failure() @@ -73,4 +58,5 @@ jobs: set +e COUNT=`grep -c -E "\[.+\]" cppcheck.log` echo "cppcheck reported ${COUNT} warning(s)" - if [ $COUNT -ne 0 ] ; then exit 1 ; fi + # TODO: uncomment to enforce failing the build + # if [ $COUNT -ne 0 ] ; then exit 1 ; fi