From a550ae43ec94927469fef8664ab63abd641650bb Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 2 Apr 2026 20:52:15 +0200 Subject: [PATCH 1/6] attemting to optimize the build duration --- .github/workflows/lint-and-test.yml | 2 +- CMakeLists.txt | 65 +++++++++++---------- benchmark/CMakeLists.txt | 13 +---- conanfile.txt | 3 + justfile | 2 +- src/moderationservice/kafka/kafkaclient.cpp | 6 +- tests/CMakeLists.txt | 39 +++---------- tools/common.just | 11 ++-- 8 files changed, 58 insertions(+), 83 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index daccead..2211d14 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -13,7 +13,7 @@ permissions: jobs: lint-and-test: - uses: esclient/tools/.github/workflows/lint-and-test-cpp.yml@main + uses: esclient/tools/.github/workflows/lint-and-test-cpp.yml@linting-job-optimization with: sonar-inclusions: "src/**,tests/**" sonar-exclusions: "**/generated/**,**/grpc/**,tests/mocks/**,tests/unit/**" diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b4eec5..e14fde8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) project(moderation-service) enable_testing() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) if(MSVC) add_compile_options(/utf-8) @@ -94,10 +94,9 @@ target_include_directories(${GENPROTO_LIB} PUBLIC ${GENPROTO_DIR}) target_link_libraries(${GENPROTO_LIB} PUBLIC protobuf::libprotobuf gRPC::grpc++ abseil::abseil) -# link source files -add_executable( - ${PROJECT_NAME} - src/moderationservice/main.cpp +# Shared service implementation (everything except the process entrypoint) +add_library( + moderation_core STATIC src/moderationservice/server/server.cpp src/moderationservice/service/service.cpp src/moderationservice/handler/handler.cpp @@ -110,26 +109,40 @@ add_executable( src/moderationservice/kafka/kafkaclient.cpp src/moderationservice/model/model_utils.cpp) +target_include_directories( + moderation_core + PUBLIC ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/src/moderationservice + ${PROJECT_SOURCE_DIR}/src/moderationservice/repository + ${PROJECT_SOURCE_DIR}/src/moderationservice/handler + ${PROJECT_SOURCE_DIR}/src/moderationservice/service + ${PROJECT_SOURCE_DIR}/src/moderationservice/model + ${PROJECT_SOURCE_DIR}/src/moderationservice/kafka + ${GENPROTO_DIR}) + target_link_libraries( - ${PROJECT_NAME} - PRIVATE ${GENPROTO_LIB} - gRPC::grpc++ - gRPC::grpc++_reflection - protobuf::libprotobuf - ICU::uc - ICU::i18n - ICU::data - tsl::hat_trie - Threads::Threads - RdKafka::rdkafka - RdKafka::rdkafka++ - libpqxx::pqxx - abseil::abseil) + moderation_core + PUBLIC ${GENPROTO_LIB} + gRPC::grpc++ + gRPC::grpc++_reflection + protobuf::libprotobuf + ICU::uc + ICU::i18n + ICU::data + tsl::hat_trie + Threads::Threads + RdKafka::rdkafka + RdKafka::rdkafka++ + libpqxx::pqxx + abseil::abseil) if(WIN32) - target_compile_definitions(${PROJECT_NAME} PRIVATE U_STATIC_IMPLEMENTATION) + target_compile_definitions(moderation_core PRIVATE U_STATIC_IMPLEMENTATION) endif() +add_executable(${PROJECT_NAME} src/moderationservice/main.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE moderation_core) + set(PROJECT_SOURCE_DIRS ${PROJECT_SOURCE_DIR}/src/moderationservice ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/tests ${PROJECT_SOURCE_DIR}/benchmark) @@ -293,18 +306,6 @@ set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ${_OLD_CMAKE_FIND_USE_SYSTEM_ENVIRONM # END LINTING SECTION # ============================================================================ -# link header files -target_include_directories( - ${PROJECT_NAME} - PUBLIC ${PROJECT_SOURCE_DIR}/include - PRIVATE ${PROJECT_SOURCE_DIR}/src/moderationservice - ${PROJECT_SOURCE_DIR}/src/moderationservice/repository - ${PROJECT_SOURCE_DIR}/src/moderationservice/handler - ${PROJECT_SOURCE_DIR}/src/moderationservice/service - ${PROJECT_SOURCE_DIR}/src/moderationservice/model - ${PROJECT_SOURCE_DIR}/src/moderationservice/kafka - ${GENPROTO_DIR}) - add_subdirectory(tests) option(BUILD_BENCHMARKS "Build benchmark executables" OFF) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 36a02b9..dce1021 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -3,19 +3,12 @@ find_package(benchmark REQUIRED CONFIG) add_executable( text_processing_benchmark performance/text_processing_benchmark.cpp - ${PROJECT_SOURCE_DIR}/src/moderationservice/service/text_processor.cpp - ${PROJECT_SOURCE_DIR}/src/moderationservice/service/text_normalization.cpp - ${PROJECT_SOURCE_DIR}/src/moderationservice/service/leetspeak_normalization.cpp - ${PROJECT_SOURCE_DIR}/src/moderationservice/service/word_checker.cpp - ${PROJECT_SOURCE_DIR}/src/moderationservice/model/constants.cpp ) - -target_include_directories( +target_link_libraries( text_processing_benchmark PRIVATE - ${CMAKE_SOURCE_DIR}/src/moderationservice - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/generated/grpc + benchmark::benchmark + moderation_core ) target_link_libraries( diff --git a/conanfile.txt b/conanfile.txt index 5e4c449..b5cc3f3 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -26,3 +26,6 @@ librdkafka/*:sasl=True benchmark/*:shared=False benchmark/*:enable_lto=True + protobuf/*:shared=False + icu/*:shared=False + diff --git a/justfile b/justfile index d4e710b..ec8334f 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ set windows-shell := ["sh", "-c"] set dotenv-load := true -COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/cpp/common.just' +COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/cpp/linting-job-optimization' LOAD_ENVS_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/load_envs.sh' PROTO_TAG := 'v0.1.3' diff --git a/src/moderationservice/kafka/kafkaclient.cpp b/src/moderationservice/kafka/kafkaclient.cpp index c174c24..4704631 100644 --- a/src/moderationservice/kafka/kafkaclient.cpp +++ b/src/moderationservice/kafka/kafkaclient.cpp @@ -196,7 +196,8 @@ void KafkaConsumer::ProcessMessage(RdKafka::Message* message) { std::string key_str(key_ptr, message->key_len()); // Validate that key_str contains only digits (and optional leading +/-) - if (key_str.empty() || (!std::isdigit(key_str[0]) && key_str[0] != '-' && key_str[0] != '+')) { + if (key_str.empty() || + (!std::isdigit(key_str[0]) && key_str[0] != '-' && key_str[0] != '+')) { std::cerr << "Invalid message key format (not numeric): '" << key_str << "'\n"; return; } @@ -204,7 +205,8 @@ void KafkaConsumer::ProcessMessage(RdKafka::Message* message) { try { request_id = std::stoll(key_str); } catch (const std::exception& e) { - std::cerr << "Failed to parse message key '" << key_str << "' to request ID: " << e.what() << "\n"; + std::cerr << "Failed to parse message key '" << key_str + << "' to request ID: " << e.what() << "\n"; return; } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c58d75..2909baa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,38 +12,20 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) set(TEST_DEPS - genproto_lib Threads::Threads ) -set(SERVICE_TEST_SOURCES - ${CMAKE_SOURCE_DIR}/src/moderationservice/service/text_normalization.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/service/leetspeak_normalization.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/service/word_checker.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/service/text_processor.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/model/constants.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/model/model_utils.cpp -) - function(add_service_test TEST_NAME) - add_executable(${TEST_NAME} ${ARGN} ${SERVICE_TEST_SOURCES}) - + add_executable(${TEST_NAME} ${ARGN}) target_include_directories(${TEST_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/src/moderationservice - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/tests - ${GENPROTO_DIR} + ${CMAKE_SOURCE_DIR}/src/moderationservice + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/tests + ${GENPROTO_DIR} ) - - target_link_libraries(${TEST_NAME} PRIVATE - GTest::gtest_main - ${GENPROTO_LIB} - ICU::uc ICU::i18n - ICU::data - tsl::hat_trie - libpqxx::pqxx - RdKafka::rdkafka - RdKafka::rdkafka++ + target_link_libraries(${TEST_NAME} PRIVATE + GTest::gtest_main + moderation_core ${TEST_DEPS} ) gtest_discover_tests(${TEST_NAME} DISCOVERY_MODE PRE_TEST) @@ -71,18 +53,13 @@ add_service_test(text_processor_test add_service_test(moderation_service_test ${CMAKE_CURRENT_SOURCE_DIR}/unit/service/moderation_service_test.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/service/service.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mocks/fake_moderation_repository.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_kafka_client.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mocks/test_utils.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/kafka/kafkaclient.cpp ) add_service_test(handler_test ${CMAKE_CURRENT_SOURCE_DIR}/unit/handler/handler_test.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/handler/handler.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/service/service.cpp - ${CMAKE_SOURCE_DIR}/src/moderationservice/kafka/kafkaclient.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mocks/fake_moderation_repository.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_kafka_client.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mocks/test_utils.cpp diff --git a/tools/common.just b/tools/common.just index c4a38e7..57a6798 100644 --- a/tools/common.just +++ b/tools/common.just @@ -10,14 +10,14 @@ fetch-proto: {{DOWN}} "https://raw.githubusercontent.com/esclient/protos/{{PROTO_TAG}}/{{PROTO_NAME}}" {{DOWN_OUT}} "{{TMP_DIR}}/{{PROTO_NAME}}" build-linux: fetch-proto - conan install . --output-folder=build --build=missing + conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \ -DCMAKE_BUILD_TYPE=Release cmake --build build --config Release build-windows: fetch-proto - conan install . --output-folder=build --build=missing + conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 cmake -S . -B build \ -G "Visual Studio 17 2022" \ -A x64 \ @@ -27,8 +27,9 @@ build-windows: fetch-proto kafka-container-up: docker-compose up -d - MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-result --replication-factor 1 --partitions 3 || true - MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-request --replication-factor 1 --partitions 3 || true + sleep 10 + MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-result --replication-factor 1 --partitions 3 + MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-request --replication-factor 1 --partitions 3 kafka-container-down: MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic moderation-request @@ -58,12 +59,10 @@ lint-all-linux: cmake --build build-lint --target lint-all run-l: - just kafka-container-up just build-linux ENV=dev tools/load_envs.sh ./build/moderation-service run-w: - just kafka-container-up just build-windows ENV=dev tools/load_envs.sh ./build/Release/moderation-service.exe From 1b1153fa48f311e905014ab82d3bc522fc85f1ef Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 2 Apr 2026 20:56:21 +0200 Subject: [PATCH 2/6] url fix --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index ec8334f..aa68944 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ set windows-shell := ["sh", "-c"] set dotenv-load := true -COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/cpp/linting-job-optimization' +COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/linting-job-optimization/cpp/common.just' LOAD_ENVS_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/load_envs.sh' PROTO_TAG := 'v0.1.3' From 0a89526920e182f657656a60681407291bda3f45 Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 3 Apr 2026 13:55:45 +0200 Subject: [PATCH 3/6] added building parallelism for ninja on linux and caching system --- tools/common.just | 57 ++++++++++++++++---------- tools/install_dev_tools.sh | 83 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 22 deletions(-) diff --git a/tools/common.just b/tools/common.just index 57a6798..ec70137 100644 --- a/tools/common.just +++ b/tools/common.just @@ -5,6 +5,12 @@ DOWN_OUT := '-o' EXE := if os() == "windows" { ".exe" } else { "" } TEST_DIR := if os() == "windows" { "./build/tests/Release" } else { "./build/tests" } +CACHE_TOOL := `which sccache 2>/dev/null || which ccache 2>/dev/null || echo ""` + +# Parallel jobs for Linux (nproc with getconf fallback) +JOBS := if os() == "windows" { "" } else { `nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4` } +PARALLEL := if os() == "windows" { "" } else { "-j" + JOBS } + fetch-proto: {{MKDIR}} "{{TMP_DIR}}" {{DOWN}} "https://raw.githubusercontent.com/esclient/protos/{{PROTO_TAG}}/{{PROTO_NAME}}" {{DOWN_OUT}} "{{TMP_DIR}}/{{PROTO_NAME}}" @@ -13,8 +19,9 @@ build-linux: fetch-proto conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \ - -DCMAKE_BUILD_TYPE=Release - cmake --build build --config Release + -DCMAKE_BUILD_TYPE=Release \ + {{ if CACHE_TOOL != "" { "-DCMAKE_C_COMPILER_LAUNCHER=" + CACHE_TOOL + " -DCMAKE_CXX_COMPILER_LAUNCHER=" + CACHE_TOOL } else { "" } }} + cmake --build build --config Release -- {{PARALLEL}} build-windows: fetch-proto conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 @@ -25,17 +32,6 @@ build-windows: fetch-proto -DCMAKE_BUILD_TYPE=Release cmake --build build --config Release -kafka-container-up: - docker-compose up -d - sleep 10 - MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-result --replication-factor 1 --partitions 3 - MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-request --replication-factor 1 --partitions 3 - -kafka-container-down: - MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic moderation-request - MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic moderation-result - docker-compose down -vv - configure-lint: fetch-proto conan install . --output-folder=build-lint --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja cmake -S . -B build-lint \ @@ -43,26 +39,38 @@ configure-lint: fetch-proto -DCMAKE_TOOLCHAIN_FILE=build-lint/conan_toolchain.cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DENABLE_CLANG_TIDY=ON + -DENABLE_CLANG_TIDY=ON \ + {{ if CACHE_TOOL != "" { "-DCMAKE_C_COMPILER_LAUNCHER=" + CACHE_TOOL + " -DCMAKE_CXX_COMPILER_LAUNCHER=" + CACHE_TOOL } else { "" } }} format: - cmake --build build-lint --target clang-format + cmake --build build-lint --target clang-format -- {{PARALLEL}} cmake --build build-lint --target cmake-format -clean-lint: - rm -rf build-lint - lint-all-linux: just configure-lint just format - cmake --build build-lint - cmake --build build-lint --target lint-all + cmake --build build-lint -- {{PARALLEL}} + cmake --build build-lint --target lint-all -- {{PARALLEL}} + +kafka-container-up: + docker-compose up -d + sleep 10 + MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-result --replication-factor 1 --partitions 3 + MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic moderation-request --replication-factor 1 --partitions 3 + +kafka-container-down: + MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic moderation-request + MSYS_NO_PATHCONV=1 docker exec kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic moderation-result + docker-compose down -vv + +clean-lint: + rm -rf build-lint run-l: just build-linux ENV=dev tools/load_envs.sh ./build/moderation-service -run-w: +run-w: just build-windows ENV=dev tools/load_envs.sh ./build/Release/moderation-service.exe @@ -74,6 +82,11 @@ check-dev-tools: @which cpplint >/dev/null 2>&1 && echo "[OK] cpplint" || echo "[X] cpplint" @which cmake-format >/dev/null 2>&1 && echo "[OK] cmake-format" || echo "[X] cmake-format" @which pipx >/dev/null 2>&1 && echo "[OK] pipx" || echo "[X] pipx" + @echo "" + @echo "Checking compiler cache:" + @which sccache >/dev/null 2>&1 && echo "[OK] sccache (preferred)" || echo "[X] sccache" + @which ccache >/dev/null 2>&1 && echo "[OK] ccache (fallback)" || echo "[X] ccache" + @echo "Active cache tool: {{CACHE_TOOL}}" install-dev-tools: chmod +x ./tools/install_dev_tools.sh @@ -98,4 +111,4 @@ benchmark: cmake --build build --target text_processing_benchmark --config Release cmake --build build --target text_processing_benchmark --config Release && \ (./build/benchmark/Release/text_processing_benchmark.exe || \ - ./build/benchmark/text_processing_benchmark) + ./build/benchmark/text_processing_benchmark) \ No newline at end of file diff --git a/tools/install_dev_tools.sh b/tools/install_dev_tools.sh index 1c8726e..672bca2 100644 --- a/tools/install_dev_tools.sh +++ b/tools/install_dev_tools.sh @@ -318,6 +318,79 @@ fi echo "" +# ============================================================================ +# Install Compiler Cache (sccache preferred, ccache fallback) +# ============================================================================ +echo -e "${CYAN}=== Installing Compiler Cache ===${NC}" + +if command -v sccache &> /dev/null; then + echo -e "${GREEN}[OK] sccache already installed${NC}" +elif command -v ccache &> /dev/null; then + echo -e "${GREEN}[OK] ccache already installed (sccache not available)${NC}" +else + CACHE_INSTALLED=false + + if [[ "$IS_WINDOWS" == "true" ]]; then + echo "Installing sccache via Chocolatey..." + choco install sccache -y && CACHE_INSTALLED=true + + elif [[ "$IS_LINUX" == "true" || "$IS_WSL" == "true" ]]; then + # Try cargo first (most up-to-date) + if command -v cargo &> /dev/null; then + echo "Installing sccache via cargo..." + cargo install sccache && CACHE_INSTALLED=true + + # Try GitHub releases binary + else + echo "Installing sccache from GitHub releases..." + SCCACHE_VERSION="v0.9.1" + ARCH=$(uname -m) + if [[ "$ARCH" == "x86_64" ]]; then + SCCACHE_ARCH="x86_64-unknown-linux-musl" + elif [[ "$ARCH" == "aarch64" ]]; then + SCCACHE_ARCH="aarch64-unknown-linux-musl" + else + echo -e "${YELLOW}⚠ Unsupported arch for sccache binary: $ARCH${NC}" + SCCACHE_ARCH="" + fi + + if [[ -n "$SCCACHE_ARCH" ]]; then + SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/sccache-${SCCACHE_VERSION}-${SCCACHE_ARCH}.tar.gz" + echo "Downloading from: $SCCACHE_URL" + curl -fsSL "$SCCACHE_URL" | tar xz -C /tmp + ${SUDO_CMD:-sudo} mv /tmp/sccache-${SCCACHE_VERSION}-${SCCACHE_ARCH}/sccache /usr/local/bin/sccache + ${SUDO_CMD:-sudo} chmod +x /usr/local/bin/sccache + CACHE_INSTALLED=true + fi + fi + + # ccache as fallback if sccache failed + if [[ "$CACHE_INSTALLED" == "false" ]]; then + echo -e "${YELLOW}⚠ sccache install failed, falling back to ccache...${NC}" + if command -v apt-get &> /dev/null; then + ${SUDO_CMD:-sudo} apt-get install -y ccache && CACHE_INSTALLED=true + elif command -v dnf &> /dev/null; then + ${SUDO_CMD:-sudo} dnf install -y ccache && CACHE_INSTALLED=true + elif command -v yum &> /dev/null; then + ${SUDO_CMD:-sudo} yum install -y ccache && CACHE_INSTALLED=true + elif command -v pacman &> /dev/null; then + ${SUDO_CMD:-sudo} pacman -S --noconfirm ccache && CACHE_INSTALLED=true + elif command -v zypper &> /dev/null; then + ${SUDO_CMD:-sudo} zypper install -y ccache && CACHE_INSTALLED=true + fi + fi + fi + + if [[ "$CACHE_INSTALLED" == "true" ]]; then + CACHE_TOOL=$(command -v sccache 2>/dev/null || command -v ccache 2>/dev/null || echo "none") + echo -e "${GREEN}[OK] Compiler cache installed: $CACHE_TOOL${NC}" + else + echo -e "${YELLOW}⚠ No compiler cache installed — builds will work but won't be cached${NC}" + fi +fi + +echo "" + # ============================================================================ # Setup Python Environment # ============================================================================ @@ -498,6 +571,16 @@ fi check_tool "just" "command -v just" +# Compiler cache (one of the two is enough) +if command -v sccache &> /dev/null; then + echo -e "${GREEN}[OK]${NC} sccache (compiler cache)" +elif command -v ccache &> /dev/null; then + echo -e "${GREEN}[OK]${NC} ccache (compiler cache fallback)" +else + echo -e "${YELLOW}[~]${NC} compiler cache - not installed (optional but recommended)" + # Not setting FAILED=1 since this is optional +fi + echo "" if [ $FAILED -eq 0 ]; then From ae35ff66fff8049f965b14579b6b0af9d22dbead Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 6 Apr 2026 16:38:46 +0200 Subject: [PATCH 4/6] test --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index be61625..119f70e 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,5 @@ To build and run you need the following installed: -Internet connection (Optional) -Electricity (Recommended) -Antidepressants(Recommended) + +test From 4cebfad55d402e064925b495e088a257b6a38a8e Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 6 Apr 2026 16:45:10 +0200 Subject: [PATCH 5/6] sonar removed --- .github/workflows/lint-and-test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 2211d14..036d970 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -14,9 +14,3 @@ permissions: jobs: lint-and-test: uses: esclient/tools/.github/workflows/lint-and-test-cpp.yml@linting-job-optimization - with: - sonar-inclusions: "src/**,tests/**" - sonar-exclusions: "**/generated/**,**/grpc/**,tests/mocks/**,tests/unit/**" - sonar-coverage-exclusions: "tests/mocks/**,tests/unit/**,src/moderationservice/main.cpp,src/moderationservice/server/server.cpp" - secrets: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file From 6304f86d72fe42df617153578bc436a54aed3957 Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 6 Apr 2026 16:50:22 +0200 Subject: [PATCH 6/6] clean up, last commit. --- .github/workflows/lint-and-test.yml | 2 +- README.md | 2 -- justfile | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 036d970..4e32104 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -13,4 +13,4 @@ permissions: jobs: lint-and-test: - uses: esclient/tools/.github/workflows/lint-and-test-cpp.yml@linting-job-optimization + uses: esclient/tools/.github/workflows/lint-and-test-cpp.yml@main diff --git a/README.md b/README.md index 119f70e..be61625 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,3 @@ To build and run you need the following installed: -Internet connection (Optional) -Electricity (Recommended) -Antidepressants(Recommended) - -test diff --git a/justfile b/justfile index aa68944..d4e710b 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ set windows-shell := ["sh", "-c"] set dotenv-load := true -COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/linting-job-optimization/cpp/common.just' +COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/cpp/common.just' LOAD_ENVS_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/load_envs.sh' PROTO_TAG := 'v0.1.3'