From a101def0f8eb2e6afe67e4ecb277f231b4eef1c1 Mon Sep 17 00:00:00 2001 From: Yaroslav Stefinko Date: Fri, 7 Aug 2026 14:27:59 +0300 Subject: [PATCH] Add clang-tidy job/script Add GithubActions job and script which compiles and checks clang-tidy with minimal set of tidy configs Relates-To: OCMAM-143 Signed-off-by: Yaroslav Stefinko --- .clang-tidy | 39 +++++++++++++++++++++++++++++ .github/workflows/psv_pipelines.yml | 18 +++++++++++++ scripts/misc/clang-tidy-17-check.sh | 24 ++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .clang-tidy create mode 100755 scripts/misc/clang-tidy-17-check.sh diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..07b332fdf --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,39 @@ +# Checks: 'boost-*,bugprone-*,clang-diagnostic*,cppcoreguidelines-*,modernize-*,misc-*,performance-*,readability-*,-bugprone-easily-swappable-parameters,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-vararg,-modernize-use-trailing-return-type,-misc-include-cleaner,-misc-non-private-member-variables-in-classes' +WarningsAsErrors: '*' +HeaderFilterRegex: '.*\/(olp-cpp-sdk-core|olp-cpp-sdk-authentication|olp-cpp-sdk-dataservice-read|olp-cpp-sdk-dataservice-write)\/.*' +FormatStyle: 'file' +CheckOptions: + - key: readability-function-cognitive-complexity.IgnoreMacros + value: true + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.MethodCase + value: CamelCase + - key: readability-identifier-naming.MemberCase + value: lower_case + - key: readability-identifier-naming.PrivateMemberSuffix + value: _ + - key: readability-identifier-naming.ProtectedMemberSuffix + value: _ + - key: readability-identifier-naming.FunctionCase + value: CamelCase + - key: readability-identifier-naming.ConstexprVariableCase + value: CamelCase + - key: readability-identifier-naming.ConstexprVariablePrefix + value: k + - key: readability-identifier-naming.StaticConstantCase + value: CamelCase + - key: readability-identifier-naming.StaticConstantPrefix + value: k + - key: readability-identifier-naming.GlobalConstantCase + value: CamelCase + - key: readability-identifier-naming.GlobalConstantPrefix + value: k + - key: readability-identifier-naming.EnumConstantCase + value: CamelCase + - key: readability-identifier-naming.EnumConstantPrefix + value: k + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.VariableCase + value: lower_case diff --git a/.github/workflows/psv_pipelines.yml b/.github/workflows/psv_pipelines.yml index e88dfcd69..fb936eef0 100644 --- a/.github/workflows/psv_pipelines.yml +++ b/.github/workflows/psv_pipelines.yml @@ -26,6 +26,24 @@ jobs: run: ./scripts/misc/cpplint_ci.sh shell: bash + psv-linux-24-04-clang17-build-clang-tidy: + name: PSV.Linux.24.04.clang17.ClangTidy + if: github.event_name == 'pull_request' + runs-on: ubuntu-24.04 + steps: + - name: Check out repository + uses: actions/checkout@v7 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + libboost-all-dev \ + libcurl4-openssl-dev + shell: bash + - name: Run clang-tidy + run: ./scripts/misc/clang-tidy-17-check.sh + shell: bash + psv-linux-22-04-gcc9-build-test-codecov: name: PSV.Linux.22.04.gcc9.Tests.CodeCov runs-on: ubuntu-22.04 diff --git a/scripts/misc/clang-tidy-17-check.sh b/scripts/misc/clang-tidy-17-check.sh new file mode 100755 index 000000000..2d74133fa --- /dev/null +++ b/scripts/misc/clang-tidy-17-check.sh @@ -0,0 +1,24 @@ +#!/bin/bash -ex + +BUILD_DIR="build-clang-tidy" + +rm -rf "${BUILD_DIR}" +mkdir "${BUILD_DIR}" + +cmake -S . -B "${BUILD_DIR}" -G Ninja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_COMPILER=clang++-17 \ + -DCMAKE_C_COMPILER=clang-17 \ + -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \ + -DOLP_SDK_ENABLE_TESTING=OFF \ + -DOLP_SDK_BUILD_EXAMPLES=OFF + +cmake --build "${BUILD_DIR}" -- -j"$(nproc)" + +run-clang-tidy-17.py -p "${BUILD_DIR}" \ + -config-file="${PWD}/.clang-tidy" \ + "${PWD}/olp-cpp-sdk-core/.*" \ + "${PWD}/olp-cpp-sdk-authentication/.*" \ + "${PWD}/olp-cpp-sdk-dataservice-read/.*" \ + "${PWD}/olp-cpp-sdk-dataservice-write/.*"