diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index f8cb8c297..a1b13723a 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -89,6 +89,14 @@ jobs: sudo chmod +x /usr/bin/sccache rm -rf sccache-v0.10.0-x86_64-unknown-linux-musl + - name: Install ctcache + run: | + # pending open PR https://github.com/matus-chochlik/ctcache/pull/94 + git clone https://github.com/louwers/ctcache.git + cd ctcache + cd .. + mv ctcache /usr/local/bin + - name: Configure AWS Credentials if: vars.OIDC_AWS_ROLE_TO_ASSUME uses: aws-actions/configure-aws-credentials@v4 @@ -112,8 +120,22 @@ jobs: export SCCACHE_S3_NO_CREDENTIALS=1 fi + # ctcache configuration + export CTCACHE_HOST=34.229.50.221 + export CTCACHE_PORT=5000 + export CTCACHE_PROTO=http + + if [ -n "${{ secrets.CTCACHE_AUTH_KEY }}" ]; then + echo "setting CTCACHE_AUTH_KEY" + export CTCACHE_AUTH_KEY=${{ secrets.CTCACHE_AUTH_KEY }} + else + # do not write to cache if CTCACHE_AUTH_KEY not set + export CTCACHE_HOST_READ_ONLY=1 + fi + cmake --preset linux-${{ matrix.variant.renderer }} \ -DMLN_WITH_CLANG_TIDY=ON \ + -DCLANG_TIDY_COMMAND=/usr/local/bin/ctcache/clang-tidy \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DMLN_WITH_COVERAGE=ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 350f1816c..501f48980 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,18 +28,7 @@ if (MLN_DRAWABLE_RENDERER) message(FATAL "Do not pass MLN_DRAWABLE_RENDERER, the drawable renderer is now the default") endif() -if (MLN_WITH_CLANG_TIDY) - find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) - if(NOT CLANG_TIDY_COMMAND) - message(FATAL_ERROR "ENABLE_CLANG_TIDY is ON but clang-tidy is not found!") - else() - message(STATUS "Found clang-tidy at ${CLANG_TIDY_COMMAND}") - endif() - # TODO: there are options which are only available on GCC(e.g. -Werror=maybe-uninitialized), - # that's why we need to disable this `unknown-warning-option` here. - # We could check if current compiler supports particular flag before enabling it. - set(CLANG_TIDY_COMMAND "${CLANG_TIDY_COMMAND};--extra-arg=-Wno-unknown-warning-option;--extra-arg=-Wno-pragmas") -endif() +include(cmake/clang-tidy.cmake) if (MLN_WITH_QT AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0) diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake new file mode 100644 index 000000000..6b4768921 --- /dev/null +++ b/cmake/clang-tidy.cmake @@ -0,0 +1,17 @@ +if (MLN_WITH_CLANG_TIDY OR MLN_CLANG_TIDY_COMMAND) + if(MLN_CLANG_TIDY_COMMAND) + set(CLANG_TIDY_COMMAND MLN_CLANG_TIDY_COMMAND) + message(STATUS "Using clang-tidy at ${CLANG_TIDY_COMMAND}") + else() + find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) + if(NOT CLANG_TIDY_COMMAND) + message(FATAL_ERROR "ENABLE_CLANG_TIDY is ON but clang-tidy is not found!") + else() + message(STATUS "Found clang-tidy at ${CLANG_TIDY_COMMAND}") + endif() + endif() + # TODO: there are options which are only available on GCC(e.g. -Werror=maybe-uninitialized), + # that's why we need to disable this `unknown-warning-option` here. + # We could check if current compiler supports particular flag before enabling it. + set(CLANG_TIDY_COMMAND "${CLANG_TIDY_COMMAND};--extra-arg=-Wno-unknown-warning-option;--extra-arg=-Wno-pragmas") +endif()