From 0bc5e7cad5c9280efae0e654e36b7f0ec36f39fe Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 16:59:20 +0300 Subject: [PATCH 01/17] Split CI to multiple jobs --- .github/workflows/ci.yml | 103 ++++++------ CMakeLists.txt | 9 +- CMakePresets.json | 148 +++++++++++++----- cmake/dependencies.cmake | 2 +- cmake/variables.cmake | 16 +- src/CMakeLists.txt | 3 + src/benchmarks/CMakeLists.txt | 36 +++++ .../rpp_benchmark.cpp} | 0 src/{tests => benchmarks}/rxcpp_benchmark.cpp | 0 src/tests/CMakeLists.txt | 30 ---- 10 files changed, 208 insertions(+), 139 deletions(-) create mode 100644 src/benchmarks/CMakeLists.txt rename src/{tests/benchmarks.cpp => benchmarks/rpp_benchmark.cpp} (100%) rename src/{tests => benchmarks}/rxcpp_benchmark.cpp (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a7c4e7ea..7e630f671 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: run: cmake --preset=ci-coverage - name: Build - run: cmake --build build/coverage -j 2 + run: cmake --preset=ci-build-release - name: Test working-directory: build/coverage @@ -106,7 +106,7 @@ jobs: run: cmake --preset=ci-sanitize - name: Build - run: cmake --build build/sanitize -j 2 + run: cmake --preset=ci-build-release - name: Test working-directory: build/sanitize @@ -123,32 +123,33 @@ jobs: needs: [download_deps] strategy: - matrix: + matrix: config: - - name: "ci-ubuntu-gcc" + - name: "ci-ubuntu-gcc-tests" + os: ubuntu-latest + - name: "ci-ubuntu-clang-tests-with-cppcheck" + os: ubuntu-latest + - name: "ci-windows-tests" + os: windows-latest + + - name: "ci-ubuntu-gcc-benchmarks" os: ubuntu-latest - - name: "ci-ubuntu-clang" + - name: "ci-ubuntu-clang-benchmarks-with-cppcheck" os: ubuntu-latest - - name: "ci-windows" + - name: "ci-windows-benchmarks" os: windows-latest - runs-on: ${{ matrix.config.os }} - name: Unit-tests - ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.name }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Install static analyzers - if: matrix.config.name == 'ci-ubuntu-clang' - run: sudo apt-get install clang-tidy cppcheck -y -q - - - name: Install SFML + - name: Install deps if: matrix.config.os != 'windows-latest' - run: | - sudo apt-get update - sudo apt-get install -y libsfml-dev + run: sudo apt-get install cppcheck libsfml-dev -y -q - name: Restore Catch2 uses: actions/cache@v3 @@ -157,51 +158,41 @@ jobs: path: ${{env.Catch2_DIR}} key: catch2-${{env.CATCH2_VERSION}}-${{matrix.config.os}} - - name: Configure - shell: pwsh - run: cmake --preset=${{ matrix.config.name }}-tests - - - name: Build - run: cmake --build build --config Release -j 2 - - - name: Install - run: cmake --install build --config Release --prefix prefix - - - name: Test - working-directory: build - run: ctest --output-on-failure -C Release - - - name: Run benchmarks - run: cmake --build build --config Release --target run_rpp_ci_benchmarks + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: ${{ matrix.config.name }} + buildPreset: 'ci-build-release' + testPreset: 'ci-tests' - name: Upload benchmark results + if: contains(matrix.config.name, "benchmarks") uses: actions/upload-artifact@v3 with: name: ${{ matrix.config.name }} - path: | - ${{github.workspace}}/build/test_results/benchmarks/* - - - name: Analyze diff with clang-tidy - if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' - run: | - mkdir clang-tidy-result - git diff -U0 origin/main | clang-tidy-diff -j 0 -p1 -path build -export-fixes clang-tidy-result/fixes.yml -extra-arg=-std=c++20 -checks=bugprone-*,concurrency-*,performance-* - - - name: Run clang-tidy-pr-comments action - if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' - uses: platisd/clang-tidy-pr-comments@master - with: - # The GitHub token (or a personal access token) - github_token: ${{ secrets.GITHUB_TOKEN }} - # The path to the clang-tidy fixes generated previously - clang_tidy_fixes: clang-tidy-result/fixes.yml - # Optionally set to true if you want the Action to request - # changes in case warnings are found - request_changes: false - # Optionally set the number of comments per review - # to avoid GitHub API timeouts for heavily loaded - # pull requests - suggestions_per_comment: 10 + path: ${{github.workspace}}/build/test_results/benchmarks/* + + # - name: Analyze diff with clang-tidy + # if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' + # run: | + # mkdir clang-tidy-result + # git diff -U0 origin/main | clang-tidy-diff -j 0 -p1 -path build -export-fixes clang-tidy-result/fixes.yml -extra-arg=-std=c++20 -checks=bugprone-*,concurrency-*,performance-* + + # - name: Run clang-tidy-pr-comments action + # if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' + # uses: platisd/clang-tidy-pr-comments@master + # with: + # # The GitHub token (or a personal access token) + # github_token: ${{ secrets.GITHUB_TOKEN }} + # # The path to the clang-tidy fixes generated previously + # clang_tidy_fixes: clang-tidy-result/fixes.yml + # # Optionally set to true if you want the Action to request + # # changes in case warnings are found + # request_changes: false + # # Optionally set the number of comments per review + # # to avoid GitHub API timeouts for heavily loaded + # # pull requests + # suggestions_per_comment: 10 docs: name: Build Doxygen Docs diff --git a/CMakeLists.txt b/CMakeLists.txt index 46cb46281..112143169 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,12 +36,15 @@ include(cmake/project-is-top-level.cmake) include(cmake/variables.cmake) include(cmake/dependencies.cmake) -if (RPP_BUILD_TESTS) +if (RPP_BUILD_TESTS or RPP_BUILD_BENCHMARKS) enable_testing() set(RPP_TEST_RESULTS_DIR ${CMAKE_BINARY_DIR}/test_results) file(MAKE_DIRECTORY ${RPP_TEST_RESULTS_DIR}) - set(RPP_TEST_BENCHMARKS_RESULTS_DIR ${RPP_TEST_RESULTS_DIR}/benchmarks) - file(MAKE_DIRECTORY ${RPP_TEST_BENCHMARKS_RESULTS_DIR}) + + if (RPP_BUILD_BENCHMARKS) + set(RPP_TEST_BENCHMARKS_RESULTS_DIR ${RPP_TEST_RESULTS_DIR}/benchmarks) + file(MAKE_DIRECTORY ${RPP_TEST_BENCHMARKS_RESULTS_DIR}) + endif() endif() add_subdirectory(src) diff --git a/CMakePresets.json b/CMakePresets.json index 0b328c738..dafabcf26 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -26,22 +26,7 @@ "hidden": true, "inherits": "cmake-pedantic", "cacheVariables": { - "RPP_DEVELOPER_MODE": "ON", - "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON" - } - }, - { - "name": "cppcheck", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr;--std=c++20;--enable=information;--check-config;--suppress=missingIncludeSystem" - } - }, - { - "name": "clang-tidy", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/" + "RPP_DEVELOPER_MODE": "ON" } }, { @@ -51,11 +36,20 @@ "cacheVariables": { "CMAKE_CXX_EXTENSIONS": "OFF", "CMAKE_CXX_STANDARD": "20", - "CMAKE_CXX_STANDARD_REQUIRED": "ON" + "CMAKE_CXX_STANDARD_REQUIRED": "ON", + } + }, + { + "name": "internal-flags", + "hidden" : true, + "inherits" : "dev-mode", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON" } }, { "name": "flags-unix", + "inherits" : "internal-flags", "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": "-Wall -Werror -Wextra -Wpedantic -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal" @@ -64,6 +58,7 @@ { "name": "flags-windows", "description": "Note that all the flags after /W4 are required for MSVC to conform to the language standard", + "inherits" : "internal-flags", "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": "/utf-8 /W4 /permissive- /volatile:iso /Zc:preprocessor /EHsc /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew" @@ -85,18 +80,22 @@ "architecture": "x64", "hidden": true }, + + + + { - "name": "coverage-unix", - "binaryDir": "${sourceDir}/build/coverage", - "inherits": "ci-unix", + "name": "cppcheck", "hidden": true, "cacheVariables": { - "RPP_ENABLE_COVERAGE": "ON", - "CMAKE_BUILD_TYPE": "Coverage", - "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions -fprofile-arcs -ftest-coverage", - "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", - "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage", - "RPP_GCOV_TOOL" : "/usr/bin/gcov-10" + "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr;--std=c++20;--enable=information;--check-config;--suppress=missingIncludeSystem" + } + }, + { + "name": "clang-tidy", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/" } }, { @@ -105,6 +104,9 @@ "environment": { "CC" : "gcc-10", "CXX": "g++-10" + }, + "cacheVariables": { + "RPP_GCOV_TOOL" : "/usr/bin/gcov-10" } }, { @@ -116,21 +118,24 @@ } }, { - "name": "ci-build", + "name": "ci-build-dir", "binaryDir": "${sourceDir}/build", "hidden": true }, { - "name" : "ci-build-rxcpp", + "name" : "ci-build-tests", "hidden": true, "cacheVariables": { - "RPP_BUILD_RXCPP" : "ON" + "RPP_BUILD_TESTS" : "ON" } }, { - "name": "ci-build-tests", - "inherits": ["ci-build", "ci-build-rxcpp", "dev-mode"], - "hidden": true + "name" : "ci-build-benchmarks", + "hidden": true, + "cacheVariables": { + "RPP_BUILD_RXCPP" : "ON", + "RPP_BUILD_BENCHMARKS" : "ON" + } }, { "name" : "ci-build-sfml", @@ -139,21 +144,31 @@ "RPP_BUILD_SFML_CODE" : "ON" } }, + { + "name": "coverage-unix", + "inherits": ["ci-build", "ci-unix", "ci-gcc"], + "hidden": true, + "cacheVariables": { + "RPP_ENABLE_COVERAGE": "ON", + "CMAKE_BUILD_TYPE": "Coverage", + "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions -fprofile-arcs -ftest-coverage", + "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", + "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage" + } + }, { "name": "ci-coverage", - "inherits": ["coverage-unix", "ci-gcc"], + "inherits": ["ci-build-dir", "ci-build-tests", "coverage-unix"], "cacheVariables": { - "COVERAGE_HTML_COMMAND": "", - "RPP_BUILD_TESTS" : "ON" + "COVERAGE_HTML_COMMAND": "" } }, { "name": "ci-sanitize", - "binaryDir": "${sourceDir}/build/sanitize", - "inherits": ["ci-unix", "dev-mode", "ci-clang"], + "inherits": ["ci-build-dir", "ci-build-tests", "ci-unix", "ci-clang"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Sanitize", "CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common" @@ -161,19 +176,66 @@ }, { "name": "ci-macos-tests", - "inherits": ["ci-build-tests", "ci-unix"] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-unix"] }, { - "name": "ci-ubuntu-clang-tests", - "inherits": ["ci-build-tests", "ci-unix", "ci-clang", "cppcheck", "ci-build-sfml"] + "name": "ci-ubuntu-clang-tests-with-cppcheck", + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] }, { "name": "ci-ubuntu-gcc-tests", - "inherits": ["ci-build-tests", "ci-unix", "ci-gcc", "ci-build-sfml"] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-gcc"] }, { "name": "ci-windows-tests", - "inherits": ["ci-build-tests", "ci-win64"] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-win64"] + }, + + + + + { + "name": "ci-macos-benchmarks", + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-unix"] + }, + { + "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] + }, + { + "name": "ci-ubuntu-gcc-benchmarks", + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-gcc"] + }, + { + "name": "ci-windows-benchmarks", + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-win64"] + } + ], + "buildPresets" :[ + { + "name" : "ci-build-release", + "configurePreset": "ci-build-dir", + "jobs" : 2, + "configuration" : "Release" + } + ] + , + "testPresets": [ + { + "name": "ci-tests", + "configurePreset": "ci-build-dir", + "configuration": "Release", + "output": { + "outputOnFailure": true + } + }, + { + "name": "ci-sanitize", + "inherits": "ci-tests", + "environment": { + "ASAN_OPTIONS": "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_leaks=1", + "UBSAN_OPTIONS": "print_stacktrace=1" + } } ] -} +} \ No newline at end of file diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index ce131eb40..f17fef8a0 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -20,7 +20,7 @@ if (RPP_BUILD_RXCPP) endif() # ===================== Catch 2 =================== -if (RPP_BUILD_TESTS) +if (RPP_BUILD_TESTS or RPP_BUILD_BENCHMARKS) find_package(Catch2 3 QUIET) if(TARGET Catch2::Catch2WithMain) diff --git a/cmake/variables.cmake b/cmake/variables.cmake index c094e5b64..be21a8d9a 100644 --- a/cmake/variables.cmake +++ b/cmake/variables.cmake @@ -36,12 +36,16 @@ endif() # ------------ Options to tweak --------------------- -option(RPP_BUILD_TESTS "Build unit tests tree." "${RPP_DEVELOPER_MODE}") -option(RPP_BUILD_EXAMPLES "Build examples tree." "${RPP_DEVELOPER_MODE}") -option(RPP_ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) option(RPP_BUILD_SFML_CODE "Enable SFML support in examples/code." OFF) -option(RPP_BUILD_RXCPP "Build RxCpp to compare results with it." OFF) -if(RPP_ENABLE_COVERAGE) - include(cmake/coverage.cmake) +if (RPP_DEVELOPER_MODE) + option(RPP_BUILD_TESTS "Build unit tests tree." OFF) + option(RPP_BUILD_BENCHMARKS "Build benchmarks tree." OFF) + option(RPP_BUILD_EXAMPLES "Build examples tree." OFF) + option(RPP_ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) + option(RPP_BUILD_RXCPP "Build RxCpp to compare results with it." OFF) + + if(RPP_ENABLE_COVERAGE) + include(cmake/coverage.cmake) + endif() endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55c03b2bb..f287f0088 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,9 @@ add_subdirectory(rpp) +if (RPP_BUILD_BENCHMARKS) + add_subdirectory(benchmarks) +endif() if(RPP_BUILD_TESTS) add_subdirectory(tests) endif() diff --git a/src/benchmarks/CMakeLists.txt b/src/benchmarks/CMakeLists.txt new file mode 100644 index 000000000..5687053dd --- /dev/null +++ b/src/benchmarks/CMakeLists.txt @@ -0,0 +1,36 @@ +# ReactivePlusPlus library +# +# Copyright Aleksey Loginov 2022 - present. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) +# +# Project home: https://github.com/victimsnino/ReactivePlusPlus +# + +set(TARGET rpp_benchmark) + +add_executable(${TARGET} + benchmarks.cpp +) + +target_link_libraries(${TARGET} PRIVATE rpp Catch2::Catch2WithMain) +set_target_properties(${TARGET} PROPERTIES FOLDER Tests) + +add_test(NAME ${TARGET} COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt) + + +if (RPP_BUILD_RXCPP) + set(TARGET rxcpp_benchmark) + + add_executable(${TARGET} + rxcpp_benchmark.cpp + ) + + target_link_libraries(${TARGET} PRIVATE rxcpp Catch2::Catch2WithMain) + get_target_property(RXCPP_DIR rxcpp INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(${TARGET} SYSTEM PRIVATE ${RXCPP_DIR}) + set_target_properties(${TARGET} PROPERTIES FOLDER Tests) + + add_test(NAME ${TARGET} COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt) +endif() \ No newline at end of file diff --git a/src/tests/benchmarks.cpp b/src/benchmarks/rpp_benchmark.cpp similarity index 100% rename from src/tests/benchmarks.cpp rename to src/benchmarks/rpp_benchmark.cpp diff --git a/src/tests/rxcpp_benchmark.cpp b/src/benchmarks/rxcpp_benchmark.cpp similarity index 100% rename from src/tests/rxcpp_benchmark.cpp rename to src/benchmarks/rxcpp_benchmark.cpp diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 99e270791..54f6ee38c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -8,7 +8,6 @@ # Project home: https://github.com/victimsnino/ReactivePlusPlus # -# ====================== Gather tests ====================== file(GLOB_RECURSE FILES "test_*.cpp") foreach(SOURCE ${FILES}) @@ -30,33 +29,4 @@ foreach(SOURCE ${FILES}) endforeach() -# ================ BENCHMARKS ================= -add_custom_target(run_rpp_ci_benchmarks) - -set(TARGET rpp_benchmark) - -add_executable(${TARGET} - benchmarks.cpp -) - -target_link_libraries(${TARGET} PRIVATE rpp Catch2::Catch2WithMain) -set_target_properties(${TARGET} PROPERTIES FOLDER Tests) - -add_custom_command(TARGET run_rpp_ci_benchmarks COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt COMMENT "Running benchmark ${TARGET}...") - - -if (RPP_BUILD_RXCPP) - set(TARGET rxcpp_benchmark) - - add_executable(${TARGET} - rxcpp_benchmark.cpp - ) - - target_link_libraries(${TARGET} PRIVATE rxcpp Catch2::Catch2WithMain) - get_target_property(RXCPP_DIR rxcpp INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(${TARGET} SYSTEM PRIVATE ${RXCPP_DIR}) - set_target_properties(${TARGET} PROPERTIES FOLDER Tests) - - add_custom_command(TARGET run_rpp_ci_benchmarks COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt COMMENT "Running benchmark ${TARGET}...") -endif() From 63d4ebe026fdbbf8b600e6a24026ed3e5dbae996 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 17:03:18 +0300 Subject: [PATCH 02/17] temporarly disable --- .github/workflows/sonarcloud_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarcloud_build.yml b/.github/workflows/sonarcloud_build.yml index 22b48e3ac..d3064c3c5 100644 --- a/.github/workflows/sonarcloud_build.yml +++ b/.github/workflows/sonarcloud_build.yml @@ -17,6 +17,7 @@ env: jobs: build_and_collect_data: + if: false runs-on: ubuntu-latest env: SONAR_SERVER_URL: "https://sonarcloud.io" From 9f72bddf0b0e3df2b2dd38359596675d2390f706 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 17:05:16 +0300 Subject: [PATCH 03/17] Fixes --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e630f671..048a8738c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,18 +125,18 @@ jobs: strategy: matrix: config: - - name: "ci-ubuntu-gcc-tests" + - name: ci-ubuntu-gcc-tests os: ubuntu-latest - - name: "ci-ubuntu-clang-tests-with-cppcheck" + - name: ci-ubuntu-clang-tests-with-cppcheck os: ubuntu-latest - - name: "ci-windows-tests" + - name: ci-windows-tests os: windows-latest - - name: "ci-ubuntu-gcc-benchmarks" + - name: ci-ubuntu-gcc-benchmarks os: ubuntu-latest - - name: "ci-ubuntu-clang-benchmarks-with-cppcheck" + - name: ci-ubuntu-clang-benchmarks-with-cppcheck os: ubuntu-latest - - name: "ci-windows-benchmarks" + - name: ci-windows-benchmarks os: windows-latest runs-on: ${{ matrix.config.os }} @@ -166,7 +166,7 @@ jobs: testPreset: 'ci-tests' - name: Upload benchmark results - if: contains(matrix.config.name, "benchmarks") + if: contains(matrix.config.name, 'benchmarks') uses: actions/upload-artifact@v3 with: name: ${{ matrix.config.name }} From dcf25aea32777bdec80f0df4ba1762aada0d7e3e Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 17:16:16 +0300 Subject: [PATCH 04/17] fix presets --- CMakePresets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index dafabcf26..60f234343 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -36,7 +36,7 @@ "cacheVariables": { "CMAKE_CXX_EXTENSIONS": "OFF", "CMAKE_CXX_STANDARD": "20", - "CMAKE_CXX_STANDARD_REQUIRED": "ON", + "CMAKE_CXX_STANDARD_REQUIRED": "ON" } }, { @@ -146,7 +146,7 @@ }, { "name": "coverage-unix", - "inherits": ["ci-build", "ci-unix", "ci-gcc"], + "inherits": ["ci-unix", "ci-gcc"], "hidden": true, "cacheVariables": { "RPP_ENABLE_COVERAGE": "ON", From bdc58c648573eec247b410f6ed39c33e59f0ee50 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 17:22:48 +0300 Subject: [PATCH 05/17] fix --- CMakeLists.txt | 2 +- cmake/dependencies.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 112143169..13b27100b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ include(cmake/project-is-top-level.cmake) include(cmake/variables.cmake) include(cmake/dependencies.cmake) -if (RPP_BUILD_TESTS or RPP_BUILD_BENCHMARKS) +if (RPP_BUILD_TESTS OR RPP_BUILD_BENCHMARKS) enable_testing() set(RPP_TEST_RESULTS_DIR ${CMAKE_BINARY_DIR}/test_results) file(MAKE_DIRECTORY ${RPP_TEST_RESULTS_DIR}) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index f17fef8a0..5f6175617 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -20,7 +20,7 @@ if (RPP_BUILD_RXCPP) endif() # ===================== Catch 2 =================== -if (RPP_BUILD_TESTS or RPP_BUILD_BENCHMARKS) +if (RPP_BUILD_TESTS OR RPP_BUILD_BENCHMARKS) find_package(Catch2 3 QUIET) if(TARGET Catch2::Catch2WithMain) From 481ab3586ad043b9f093b20c5398357de078292d Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 17:48:33 +0300 Subject: [PATCH 06/17] fixes --- .github/workflows/ci.yml | 4 +- CMakePresets.json | 109 +++++++++++++++++++++++++++++++++++++-- cmake/coverage.cmake | 2 +- 3 files changed, 108 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 048a8738c..b0b57aeb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,8 +162,8 @@ jobs: uses: lukka/run-cmake@v10 with: configurePreset: ${{ matrix.config.name }} - buildPreset: 'ci-build-release' - testPreset: 'ci-tests' + buildPreset: ${{ matrix.config.name }} + testPreset: ${{ matrix.config.name }} - name: Upload benchmark results if: contains(matrix.config.name, 'benchmarks') diff --git a/CMakePresets.json b/CMakePresets.json index 60f234343..5dd9af25b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -213,29 +213,130 @@ ], "buildPresets" :[ { - "name" : "ci-build-release", - "configurePreset": "ci-build-dir", + "name" : "ci-build", + "hidden": true, "jobs" : 2, "configuration" : "Release" + }, + + { + "name": "ci-coverage", + "configurePreset" : "ci-coverage", + "inherits" : "ci-build" + }, + { + "name": "ci-sanitize", + "configurePreset" : "ci-sanitize", + "inherits" : "ci-build" + }, + { + "name": "ci-macos-tests", + "configurePreset" : "ci-macos-tests", + "inherits" : "ci-build" + }, + { + "name": "ci-ubuntu-clang-tests-with-cppcheck", + "configurePreset" : "ci-ubuntu-clang-tests-with-cppcheck", + "inherits" : "ci-build" + }, + { + "name": "ci-ubuntu-gcc-tests", + "configurePreset" : "ci-ubuntu-gcc-tests", + "inherits" : "ci-build" + }, + { + "name": "ci-windows-tests", + "configurePreset" : "ci-windows-tests", + "inherits" : "ci-build" + }, + + + { + "name": "ci-macos-benchmarks", + "configurePreset" : "ci-macos-benchmarks", + "inherits" : "ci-build" + }, + { + "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", + "configurePreset" : "ci-ubuntu-clang-benchmarks-with-cppcheck", + "inherits" : "ci-build" + }, + { + "name": "ci-ubuntu-gcc-benchmarks", + "configurePreset" : "ci-ubuntu-gcc-benchmarks", + "inherits" : "ci-build" + }, + { + "name": "ci-windows-benchmarks", + "configurePreset" : "ci-windows-benchmarks", + "inherits" : "ci-build" } ] , "testPresets": [ { "name": "ci-tests", - "configurePreset": "ci-build-dir", "configuration": "Release", + "hidden": true, "output": { "outputOnFailure": true } }, + { + "name": "ci-coverage", + "configurePreset" : "ci-coverage", + "inherits" : "ci-tests" + }, { "name": "ci-sanitize", - "inherits": "ci-tests", + "configurePreset" : "ci-sanitize", + "inherits" : "ci-tests", "environment": { "ASAN_OPTIONS": "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_leaks=1", "UBSAN_OPTIONS": "print_stacktrace=1" } + }, + { + "name": "ci-macos-tests", + "configurePreset" : "ci-macos-tests", + "inherits" : "ci-tests" + }, + { + "name": "ci-ubuntu-clang-tests-with-cppcheck", + "configurePreset" : "ci-ubuntu-clang-tests-with-cppcheck", + "inherits" : "ci-tests" + }, + { + "name": "ci-ubuntu-gcc-tests", + "configurePreset" : "ci-ubuntu-gcc-tests", + "inherits" : "ci-tests" + }, + { + "name": "ci-windows-tests", + "configurePreset" : "ci-windows-tests", + "inherits" : "ci-tests" + }, + + + { + "name": "ci-macos-benchmarks", + "configurePreset" : "ci-macos-benchmarks", + "inherits" : "ci-tests" + }, + { + "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", + "configurePreset" : "ci-ubuntu-clang-benchmarks-with-cppcheck", + "inherits" : "ci-tests" + }, + { + "name": "ci-ubuntu-gcc-benchmarks", + "configurePreset" : "ci-ubuntu-gcc-benchmarks", + "inherits" : "ci-tests" + }, + { + "name": "ci-windows-benchmarks", + "configurePreset" : "ci-windows-benchmarks", + "inherits" : "ci-tests" } ] } \ No newline at end of file diff --git a/cmake/coverage.cmake b/cmake/coverage.cmake index 57a4896dd..7854eb032 100644 --- a/cmake/coverage.cmake +++ b/cmake/coverage.cmake @@ -12,7 +12,7 @@ set( -o "${PROJECT_BINARY_DIR}/coverage.info" -d "${PROJECT_BINARY_DIR}" --include "${PROJECT_SOURCE_DIR}/*" - --exclude "'/usr/*' ${HOME}'/.cache/*' '*/tests/*' '*/submodules/*'" + --exclude "'/usr/*' '*/tests/*' '*/submodules/*'" --gcov-tool "${RPP_GCOV_TOOL}" CACHE STRING "; separated command to generate a trace for the 'coverage' target" From 9815b3427b3d447cf8ebc2425a8562aa8e7210a2 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 17:52:46 +0300 Subject: [PATCH 07/17] fix CI --- .github/workflows/ci.yml | 39 +++++++++++++-------------------------- CMakePresets.json | 26 +++++++++++++++++--------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0b57aeb3..bd9940dcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,15 +67,12 @@ jobs: path: ${{env.Catch2_DIR}} key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest - - name: Configure - run: cmake --preset=ci-coverage - - - name: Build - run: cmake --preset=ci-build-release - - - name: Test - working-directory: build/coverage - run: ctest --output-on-failure + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: ci-coverage + buildPreset: ci-coverage + testPreset: ci-coverage - name: Process coverage info run: cmake --build build/coverage -t coverage @@ -102,23 +99,13 @@ jobs: path: ${{env.Catch2_DIR}} key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest - - name: Configure - run: cmake --preset=ci-sanitize - - - name: Build - run: cmake --preset=ci-build-release - - - name: Test - working-directory: build/sanitize - env: - ASAN_OPTIONS: "strict_string_checks=1:\ - detect_stack_use_after_return=1:\ - check_initialization_order=1:\ - strict_init_order=1:\ - detect_leaks=1" - UBSAN_OPTIONS: print_stacktrace=1 - run: ctest --output-on-failure - + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: ci-sanitize + buildPreset: ci-sanitize + testPreset: ci-sanitize + test: needs: [download_deps] diff --git a/CMakePresets.json b/CMakePresets.json index 5dd9af25b..17f8a5a3a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -126,7 +126,15 @@ "name" : "ci-build-tests", "hidden": true, "cacheVariables": { - "RPP_BUILD_TESTS" : "ON" + "RPP_BUILD_TESTS" : "ON", + "RPP_BUILD_EXAMPLES" : "ON" + } + }, + { + "name" : "ci-build-examples", + "hidden": true, + "cacheVariables": { + "RPP_BUILD_EXAMPLES" : "ON" } }, { @@ -176,19 +184,19 @@ }, { "name": "ci-macos-tests", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-unix"] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-unix"] }, { "name": "ci-ubuntu-clang-tests-with-cppcheck", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] }, { "name": "ci-ubuntu-gcc-tests", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-gcc"] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-gcc"] }, { "name": "ci-windows-tests", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-benchmarks", "ci-win64"] + "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-win64"] }, @@ -196,19 +204,19 @@ { "name": "ci-macos-benchmarks", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-unix"] + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-unix"] }, { "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-unix", "ci-clang", "cppcheck" ] }, { "name": "ci-ubuntu-gcc-benchmarks", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-build-sfml", "ci-unix", "ci-gcc"] + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-unix", "ci-gcc"] }, { "name": "ci-windows-benchmarks", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-build-benchmarks", "ci-win64"] + "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-win64"] } ], "buildPresets" :[ From f53f14b04c428dd36a99a4a1a3188f3517fae3c0 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 18:00:30 +0300 Subject: [PATCH 08/17] fix benchmarks --- src/benchmarks/CMakeLists.txt | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/benchmarks/CMakeLists.txt b/src/benchmarks/CMakeLists.txt index 5687053dd..0776ad3af 100644 --- a/src/benchmarks/CMakeLists.txt +++ b/src/benchmarks/CMakeLists.txt @@ -8,29 +8,26 @@ # Project home: https://github.com/victimsnino/ReactivePlusPlus # -set(TARGET rpp_benchmark) -add_executable(${TARGET} - benchmarks.cpp -) +function(add_benchmark benchmark_name) + set(TARGET ${benchmark_name}_benchmark) -target_link_libraries(${TARGET} PRIVATE rpp Catch2::Catch2WithMain) -set_target_properties(${TARGET} PROPERTIES FOLDER Tests) + add_executable(${TARGET} ${TARGET}.cpp) -add_test(NAME ${TARGET} COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt) + target_link_libraries(${TARGET} PRIVATE ${benchmark_name} Catch2::Catch2WithMain) + set_target_properties(${TARGET} PROPERTIES FOLDER Tests) + if (NOT benchmark_name STREQUAL "rpp") + get_target_property(DEP_DIR ${benchmark_name} INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(${TARGET} SYSTEM PRIVATE ${DEP_DIR}) + endif() -if (RPP_BUILD_RXCPP) - set(TARGET rxcpp_benchmark) + add_test(NAME ${TARGET} COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt) - add_executable(${TARGET} - rxcpp_benchmark.cpp - ) +endfunction() - target_link_libraries(${TARGET} PRIVATE rxcpp Catch2::Catch2WithMain) - get_target_property(RXCPP_DIR rxcpp INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(${TARGET} SYSTEM PRIVATE ${RXCPP_DIR}) - set_target_properties(${TARGET} PROPERTIES FOLDER Tests) +add_benchmark(rpp) - add_test(NAME ${TARGET} COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt) +if (RPP_BUILD_RXCPP) + add_benchmark(rxcpp) endif() \ No newline at end of file From 45a8da06333661e129cfda190c483bf1d360bdd9 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 18:23:23 +0300 Subject: [PATCH 09/17] fix CI --- .github/workflows/ci.yml | 71 ++++++------------ CMakePresets.json | 155 +++++++-------------------------------- 2 files changed, 48 insertions(+), 178 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd9940dcd..d35e5f417 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,60 +71,33 @@ jobs: uses: lukka/run-cmake@v10 with: configurePreset: ci-coverage - buildPreset: ci-coverage - testPreset: ci-coverage + buildPreset: ci-build + testPreset: ci-tests - name: Process coverage info - run: cmake --build build/coverage -t coverage + run: cmake --build build -t coverage - name: Submit to codecov.io uses: codecov/codecov-action@v3 with: - file: build/coverage/coverage.info - - sanitize: - name: Sanitizer - - needs: [download_deps] - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Restore Catch2 - uses: actions/cache@v3 - id: cache-catch2 - with: - path: ${{env.Catch2_DIR}} - key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest - - - name: Run CMake - uses: lukka/run-cmake@v10 - with: - configurePreset: ci-sanitize - buildPreset: ci-sanitize - testPreset: ci-sanitize + file: build/coverage.info test: needs: [download_deps] strategy: - matrix: + matrix: config: - - name: ci-ubuntu-gcc-tests - os: ubuntu-latest - - name: ci-ubuntu-clang-tests-with-cppcheck - os: ubuntu-latest - - name: ci-windows-tests - os: windows-latest - - - name: ci-ubuntu-gcc-benchmarks - os: ubuntu-latest - - name: ci-ubuntu-clang-benchmarks-with-cppcheck - os: ubuntu-latest - - name: ci-windows-benchmarks - os: windows-latest + - {name: Unit Tests Ubuntu GCC, configurePresets: ci-ubuntu-gcc-tests, os: ubuntu-latest, testPreset: ci-tests} + - {name: Unit Tests Ubuntu Clang, configurePresets: ci-ubuntu-clang-tests,os: ubuntu-latest, testPreset: ci-tests} + - {name: Unit Tests Windows, configurePresets: ci-windows-tests, os: windows-latest,testPreset: ci-tests} + + - {name: Benchmarks Ubuntu GCC, configurePresets: ci-ubuntu-gcc-benchmarks, os: ubuntu-latest, testPreset: ci-tests, benchmarkName: Ubuntu GCC} + - {name: Benchmarks Ubuntu Clang, configurePresets: ci-ubuntu-clang-benchmarks,os: ubuntu-latest, testPreset: ci-tests, benchmarkName: Ubuntu Clang} + - {name: Benchmarks Windows, configurePresets: ci-windows-benchmarks, os: windows-latest,testPreset: ci-tests, benchmarkName: Windows MSVC} + + - {name: Sanitize, configurePresets: ci-sanitize, os: windows-latest,testPreset: ci-sanitize} + runs-on: ${{ matrix.config.os }} name: ${{ matrix.config.name }} @@ -136,7 +109,7 @@ jobs: - name: Install deps if: matrix.config.os != 'windows-latest' - run: sudo apt-get install cppcheck libsfml-dev -y -q + run: sudo apt-get update -q && sudo apt-get install cppcheck libsfml-dev lcov -y -q - name: Restore Catch2 uses: actions/cache@v3 @@ -148,15 +121,15 @@ jobs: - name: Run CMake uses: lukka/run-cmake@v10 with: - configurePreset: ${{ matrix.config.name }} - buildPreset: ${{ matrix.config.name }} - testPreset: ${{ matrix.config.name }} + configurePreset: ${{ matrix.config.configurePresets }} + buildPreset: ci-build + testPreset: ${{ matrix.config.testPreset }} - name: Upload benchmark results - if: contains(matrix.config.name, 'benchmarks') + if: matrix.config.benchmarkName uses: actions/upload-artifact@v3 with: - name: ${{ matrix.config.name }} + name: ${{ matrix.config.benchmarkName }} path: ${{github.workspace}}/build/test_results/benchmarks/* # - name: Analyze diff with clang-tidy @@ -184,7 +157,7 @@ jobs: docs: name: Build Doxygen Docs - needs: [sanitize, test] + needs: [test] runs-on: ubuntu-latest diff --git a/CMakePresets.json b/CMakePresets.json index 17f8a5a3a..cf7f4dc8f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -30,7 +30,7 @@ } }, { - "name": "ci-std", + "name": "std", "description": "This preset makes sure the project actually builds with at least the specified standard", "hidden": true, "cacheVariables": { @@ -40,16 +40,15 @@ } }, { - "name": "internal-flags", + "name": "ci-flags", "hidden" : true, - "inherits" : "dev-mode", + "inherits" : ["dev-mode", "std"], "cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON" } }, { "name": "flags-unix", - "inherits" : "internal-flags", "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": "-Wall -Werror -Wextra -Wpedantic -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal" @@ -58,7 +57,6 @@ { "name": "flags-windows", "description": "Note that all the flags after /W4 are required for MSVC to conform to the language standard", - "inherits" : "internal-flags", "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": "/utf-8 /W4 /permissive- /volatile:iso /Zc:preprocessor /EHsc /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew" @@ -68,14 +66,14 @@ "name": "ci-unix", "generator": "Unix Makefiles", "hidden": true, - "inherits": ["flags-unix", "ci-std"], + "inherits": ["flags-unix"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } }, { "name": "ci-win64", - "inherits": ["flags-windows", "ci-std"], + "inherits": ["flags-windows"], "generator": "Visual Studio 17 2022", "architecture": "x64", "hidden": true @@ -117,11 +115,6 @@ "CXX": "clang++" } }, - { - "name": "ci-build-dir", - "binaryDir": "${sourceDir}/build", - "hidden": true - }, { "name" : "ci-build-tests", "hidden": true, @@ -166,17 +159,21 @@ }, - + { + "name": "ci-build", + "binaryDir": "${sourceDir}/build", + "inherits" : ["ci-flags"] + }, { "name": "ci-coverage", - "inherits": ["ci-build-dir", "ci-build-tests", "coverage-unix"], + "inherits": ["ci-build", "ci-build-tests", "coverage-unix"], "cacheVariables": { "COVERAGE_HTML_COMMAND": "" } }, { "name": "ci-sanitize", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-unix", "ci-clang"], + "inherits": ["ci-build", "ci-build-tests", "ci-unix", "ci-clang"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Sanitize", "CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common" @@ -184,19 +181,19 @@ }, { "name": "ci-macos-tests", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-unix"] + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-unix"] }, { - "name": "ci-ubuntu-clang-tests-with-cppcheck", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] + "name": "ci-ubuntu-clang-tests", + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-clang", "cppcheck" ] }, { "name": "ci-ubuntu-gcc-tests", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-gcc"] + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-gcc", "cppcheck"] }, { "name": "ci-windows-tests", - "inherits": ["ci-build-dir", "ci-build-tests", "ci-build-examples", "ci-win64"] + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-win64"] }, @@ -204,80 +201,27 @@ { "name": "ci-macos-benchmarks", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-unix"] + "inherits": ["ci-build", "ci-build-benchmarks", "ci-unix"] }, { - "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-unix", "ci-clang", "cppcheck" ] + "name": "ci-ubuntu-clang-benchmarks", + "inherits": ["ci-build", "ci-build-benchmarks", "ci-unix", "ci-clang", "cppcheck" ] }, { "name": "ci-ubuntu-gcc-benchmarks", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-unix", "ci-gcc"] + "inherits": ["ci-build", "ci-build-benchmarks", "ci-unix", "ci-gcc", "cppcheck"] }, { "name": "ci-windows-benchmarks", - "inherits": ["ci-build-dir", "ci-build-benchmarks", "ci-win64"] + "inherits": ["ci-build", "ci-build-benchmarks", "ci-win64"] } ], "buildPresets" :[ { "name" : "ci-build", - "hidden": true, "jobs" : 2, - "configuration" : "Release" - }, - - { - "name": "ci-coverage", - "configurePreset" : "ci-coverage", - "inherits" : "ci-build" - }, - { - "name": "ci-sanitize", - "configurePreset" : "ci-sanitize", - "inherits" : "ci-build" - }, - { - "name": "ci-macos-tests", - "configurePreset" : "ci-macos-tests", - "inherits" : "ci-build" - }, - { - "name": "ci-ubuntu-clang-tests-with-cppcheck", - "configurePreset" : "ci-ubuntu-clang-tests-with-cppcheck", - "inherits" : "ci-build" - }, - { - "name": "ci-ubuntu-gcc-tests", - "configurePreset" : "ci-ubuntu-gcc-tests", - "inherits" : "ci-build" - }, - { - "name": "ci-windows-tests", - "configurePreset" : "ci-windows-tests", - "inherits" : "ci-build" - }, - - - { - "name": "ci-macos-benchmarks", - "configurePreset" : "ci-macos-benchmarks", - "inherits" : "ci-build" - }, - { - "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", - "configurePreset" : "ci-ubuntu-clang-benchmarks-with-cppcheck", - "inherits" : "ci-build" - }, - { - "name": "ci-ubuntu-gcc-benchmarks", - "configurePreset" : "ci-ubuntu-gcc-benchmarks", - "inherits" : "ci-build" - }, - { - "name": "ci-windows-benchmarks", - "configurePreset" : "ci-windows-benchmarks", - "inherits" : "ci-build" + "configuration" : "Release", + "configurePreset" : "ci-build" } ] , @@ -285,15 +229,10 @@ { "name": "ci-tests", "configuration": "Release", - "hidden": true, "output": { "outputOnFailure": true - } - }, - { - "name": "ci-coverage", - "configurePreset" : "ci-coverage", - "inherits" : "ci-tests" + }, + "configurePreset" : "ci-build" }, { "name": "ci-sanitize", @@ -303,48 +242,6 @@ "ASAN_OPTIONS": "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_leaks=1", "UBSAN_OPTIONS": "print_stacktrace=1" } - }, - { - "name": "ci-macos-tests", - "configurePreset" : "ci-macos-tests", - "inherits" : "ci-tests" - }, - { - "name": "ci-ubuntu-clang-tests-with-cppcheck", - "configurePreset" : "ci-ubuntu-clang-tests-with-cppcheck", - "inherits" : "ci-tests" - }, - { - "name": "ci-ubuntu-gcc-tests", - "configurePreset" : "ci-ubuntu-gcc-tests", - "inherits" : "ci-tests" - }, - { - "name": "ci-windows-tests", - "configurePreset" : "ci-windows-tests", - "inherits" : "ci-tests" - }, - - - { - "name": "ci-macos-benchmarks", - "configurePreset" : "ci-macos-benchmarks", - "inherits" : "ci-tests" - }, - { - "name": "ci-ubuntu-clang-benchmarks-with-cppcheck", - "configurePreset" : "ci-ubuntu-clang-benchmarks-with-cppcheck", - "inherits" : "ci-tests" - }, - { - "name": "ci-ubuntu-gcc-benchmarks", - "configurePreset" : "ci-ubuntu-gcc-benchmarks", - "inherits" : "ci-tests" - }, - { - "name": "ci-windows-benchmarks", - "configurePreset" : "ci-windows-benchmarks", - "inherits" : "ci-tests" } ] } \ No newline at end of file From 3ddccc8b8ebaeb45c17451d4635880b6c61090ff Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 18:38:36 +0300 Subject: [PATCH 10/17] Remove unused --- .clang-tidy-temp | 162 ---------------------------------------------- CMakePresets.json | 7 -- 2 files changed, 169 deletions(-) delete mode 100644 .clang-tidy-temp diff --git a/.clang-tidy-temp b/.clang-tidy-temp deleted file mode 100644 index ec2d66bd4..000000000 --- a/.clang-tidy-temp +++ /dev/null @@ -1,162 +0,0 @@ ---- -# Enable ALL the things! Except not really -# misc-non-private-member-variables-in-classes: the options don't do anything -# Checks: "*,\ -# -google-readability-todo,\ -# -altera-*,\ -# -fuchsia-*,\ -# fuchsia-multiple-inheritance,\ -# -llvm-header-guard,\ -# -llvm-include-order,\ -# -llvmlibc-*,\ -# -misc-non-private-member-variables-in-classes" -Checks: "bugprone-*,concurrency-*,performance-*" -WarningsAsErrors: '' -CheckOptions: - - key: 'bugprone-argument-comment.StrictMode' - value: 'true' -# Prefer using enum classes with 2 values for parameters instead of bools - - key: 'bugprone-argument-comment.CommentBoolLiterals' - value: 'true' - - key: 'bugprone-misplaced-widening-cast.CheckImplicitCasts' - value: 'true' - - key: 'bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression' - value: 'true' - - key: 'bugprone-suspicious-string-compare.WarnOnLogicalNotComparison' - value: 'true' - - key: 'readability-simplify-boolean-expr.ChainedConditionalReturn' - value: 'true' - - key: 'readability-simplify-boolean-expr.ChainedConditionalAssignment' - value: 'true' - - key: 'readability-uniqueptr-delete-release.PreferResetCall' - value: 'true' - - key: 'cppcoreguidelines-init-variables.MathHeader' - value: '' - - key: 'cppcoreguidelines-narrowing-conversions.PedanticMode' - value: 'true' - - key: 'readability-else-after-return.WarnOnUnfixable' - value: 'true' - - key: 'readability-else-after-return.WarnOnConditionVariables' - value: 'true' - - key: 'readability-inconsistent-declaration-parameter-name.Strict' - value: 'true' - - key: 'readability-qualified-auto.AddConstToQualified' - value: 'true' - - key: 'readability-redundant-access-specifiers.CheckFirstDeclaration' - value: 'true' -# These seem to be the most common identifier styles - - key: 'readability-identifier-naming.AbstractClassCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ClassCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ClassConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ClassMemberCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ClassMethodCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstantMemberCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstantParameterCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstantPointerParameterCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstexprFunctionCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstexprMethodCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ConstexprVariableCase' - value: 'lower_case' - - key: 'readability-identifier-naming.EnumCase' - value: 'lower_case' - - key: 'readability-identifier-naming.EnumConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.FunctionCase' - value: 'lower_case' - - key: 'readability-identifier-naming.GlobalConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.GlobalConstantPointerCase' - value: 'lower_case' - - key: 'readability-identifier-naming.GlobalFunctionCase' - value: 'lower_case' - - key: 'readability-identifier-naming.GlobalPointerCase' - value: 'lower_case' - - key: 'readability-identifier-naming.GlobalVariableCase' - value: 'lower_case' - - key: 'readability-identifier-naming.InlineNamespaceCase' - value: 'lower_case' - - key: 'readability-identifier-naming.LocalConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.LocalConstantPointerCase' - value: 'lower_case' - - key: 'readability-identifier-naming.LocalPointerCase' - value: 'lower_case' - - key: 'readability-identifier-naming.LocalVariableCase' - value: 'lower_case' - - key: 'readability-identifier-naming.MacroDefinitionCase' - value: 'UPPER_CASE' - - key: 'readability-identifier-naming.MemberCase' - value: 'lower_case' - - key: 'readability-identifier-naming.MethodCase' - value: 'lower_case' - - key: 'readability-identifier-naming.NamespaceCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ParameterCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ParameterPackCase' - value: 'lower_case' - - key: 'readability-identifier-naming.PointerParameterCase' - value: 'lower_case' - - key: 'readability-identifier-naming.PrivateMemberCase' - value: 'lower_case' - - key: 'readability-identifier-naming.PrivateMemberPrefix' - value: 'm_' - - key: 'readability-identifier-naming.PublicMemberPrefix' - value: '' - - key: 'readability-identifier-naming.StaticVariablePrefix' - value: 's_' - - key: 'readability-identifier-naming.StaticConstantPrefix' - value: 's_' - - key: 'readability-identifier-naming.GlobalVariablePrefix' - value: 'g_' - - key: 'readability-identifier-naming.PrivateMethodCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ProtectedMemberCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ProtectedMemberPrefix' - value: 'm_' - - key: 'readability-identifier-naming.ProtectedMethodCase' - value: 'lower_case' - - key: 'readability-identifier-naming.PublicMemberCase' - value: 'lower_case' - - key: 'readability-identifier-naming.PublicMethodCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ScopedEnumConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.StaticConstantCase' - value: 'lower_case' - - key: 'readability-identifier-naming.StaticVariableCase' - value: 'lower_case' - - key: 'readability-identifier-naming.StructCase' - value: 'lower_case' - - key: 'readability-identifier-naming.TemplateParameterCase' - value: 'CamelCase' - - key: 'readability-identifier-naming.TemplateTemplateParameterCase' - value: 'CamelCase' - - key: 'readability-identifier-naming.TypeAliasCase' - value: 'CamelCase' - - key: 'readability-identifier-naming.TypedefCase' - value: 'lower_case' - - key: 'readability-identifier-naming.TypeTemplateParameterCase' - value: 'CamelCase' - - key: 'readability-identifier-naming.UnionCase' - value: 'lower_case' - - key: 'readability-identifier-naming.ValueTemplateParameterCase' - value: 'lower_case' - - key: 'readability-identifier-naming.VariableCase' - value: 'lower_case' - - key: 'readability-identifier-naming.VirtualMethodCase' - value: 'lower_case' -... diff --git a/CMakePresets.json b/CMakePresets.json index cf7f4dc8f..32bbce03f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -89,13 +89,6 @@ "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr;--std=c++20;--enable=information;--check-config;--suppress=missingIncludeSystem" } }, - { - "name": "clang-tidy", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/" - } - }, { "name": "ci-gcc", "hidden": true, From 02042ba6f2928b118ab72652db7253826efaf0fd Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 19:11:56 +0300 Subject: [PATCH 11/17] fix ci --- .github/workflows/ci.yml | 133 +++++++++++++++++++++++++++------------ 1 file changed, 93 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d35e5f417..9337a706b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,7 @@ jobs: - uses: actions/checkout@v3 - name: Install LCov - run: sudo apt-get update -q - && sudo apt-get install lcov -q -y + run: sudo apt-get update -q && sudo apt-get install lcov -q -y - name: Restore Catch2 uses: actions/cache@v3 @@ -81,26 +80,103 @@ jobs: uses: codecov/codecov-action@v3 with: file: build/coverage.info - - test: + + sanitize: + needs: [download_deps] + + name: Sanitize + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Restore Catch2 + uses: actions/cache@v3 + id: cache-catch2 + with: + path: ${{env.Catch2_DIR}} + key: catch2-${{env.CATCH2_VERSION}}-${{matrix.config.os}} + + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: ci-sanitize + buildPreset: ci-build + testPreset: ci-sanitize + + tests: needs: [download_deps] strategy: matrix: config: - - {name: Unit Tests Ubuntu GCC, configurePresets: ci-ubuntu-gcc-tests, os: ubuntu-latest, testPreset: ci-tests} - - {name: Unit Tests Ubuntu Clang, configurePresets: ci-ubuntu-clang-tests,os: ubuntu-latest, testPreset: ci-tests} - - {name: Unit Tests Windows, configurePresets: ci-windows-tests, os: windows-latest,testPreset: ci-tests} + - {name: ci-ubuntu-gcc, os: ubuntu-latest} + - {name: ci-ubuntu-clang,os: ubuntu-latest} + - {name: ci-windows, os: windows-latest} - - {name: Benchmarks Ubuntu GCC, configurePresets: ci-ubuntu-gcc-benchmarks, os: ubuntu-latest, testPreset: ci-tests, benchmarkName: Ubuntu GCC} - - {name: Benchmarks Ubuntu Clang, configurePresets: ci-ubuntu-clang-benchmarks,os: ubuntu-latest, testPreset: ci-tests, benchmarkName: Ubuntu Clang} - - {name: Benchmarks Windows, configurePresets: ci-windows-benchmarks, os: windows-latest,testPreset: ci-tests, benchmarkName: Windows MSVC} + runs-on: ${{ matrix.config.os }} + name: Unit Tests ${{ matrix.config.name }} - - {name: Sanitize, configurePresets: ci-sanitize, os: windows-latest,testPreset: ci-sanitize} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install deps + if: matrix.config.os != 'windows-latest' + run: sudo apt-get update -q && sudo apt-get install cppcheck libsfml-dev -y -q + + - name: Restore Catch2 + uses: actions/cache@v3 + id: cache-catch2 + with: + path: ${{env.Catch2_DIR}} + key: catch2-${{env.CATCH2_VERSION}}-${{matrix.config.os}} + + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: ${{ matrix.config.configurePresets }}-tests + buildPreset: ci-build + testPreset: ci-tests + + - name: Analyze diff with clang-tidy + if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' + run: | + mkdir clang-tidy-result + git diff -U0 origin/main | clang-tidy-diff -j 0 -p1 -path build -export-fixes clang-tidy-result/fixes.yml -extra-arg=-std=c++20 -checks=bugprone-*,concurrency-*,performance-* + + - name: Run clang-tidy-pr-comments action + if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' + uses: platisd/clang-tidy-pr-comments@master + with: + # The GitHub token (or a personal access token) + github_token: ${{ secrets.GITHUB_TOKEN }} + # The path to the clang-tidy fixes generated previously + clang_tidy_fixes: clang-tidy-result/fixes.yml + # Optionally set to true if you want the Action to request + # changes in case warnings are found + request_changes: false + # Optionally set the number of comments per review + # to avoid GitHub API timeouts for heavily loaded + # pull requests + suggestions_per_comment: 10 + + benchmarks: + needs: [download_deps] + + strategy: + matrix: + config: + - {name: ci-ubuntu-gcc, os: ubuntu-latest} + - {name: ci-ubuntu-clang,os: ubuntu-latest} + - {name: ci-windows, os: windows-latest} runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.name }} + name: Benchmarks ${{ matrix.config.name }} steps: - uses: actions/checkout@v3 @@ -109,7 +185,7 @@ jobs: - name: Install deps if: matrix.config.os != 'windows-latest' - run: sudo apt-get update -q && sudo apt-get install cppcheck libsfml-dev lcov -y -q + run: sudo apt-get update -q && sudo apt-get install cppcheck -y -q - name: Restore Catch2 uses: actions/cache@v3 @@ -121,43 +197,20 @@ jobs: - name: Run CMake uses: lukka/run-cmake@v10 with: - configurePreset: ${{ matrix.config.configurePresets }} + configurePreset: ${{ matrix.config.name }}-benchmarks buildPreset: ci-build - testPreset: ${{ matrix.config.testPreset }} + testPreset: ci-tests - name: Upload benchmark results - if: matrix.config.benchmarkName uses: actions/upload-artifact@v3 with: - name: ${{ matrix.config.benchmarkName }} + name: ${{ matrix.config.name }} path: ${{github.workspace}}/build/test_results/benchmarks/* - # - name: Analyze diff with clang-tidy - # if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' - # run: | - # mkdir clang-tidy-result - # git diff -U0 origin/main | clang-tidy-diff -j 0 -p1 -path build -export-fixes clang-tidy-result/fixes.yml -extra-arg=-std=c++20 -checks=bugprone-*,concurrency-*,performance-* - - # - name: Run clang-tidy-pr-comments action - # if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' - # uses: platisd/clang-tidy-pr-comments@master - # with: - # # The GitHub token (or a personal access token) - # github_token: ${{ secrets.GITHUB_TOKEN }} - # # The path to the clang-tidy fixes generated previously - # clang_tidy_fixes: clang-tidy-result/fixes.yml - # # Optionally set to true if you want the Action to request - # # changes in case warnings are found - # request_changes: false - # # Optionally set the number of comments per review - # # to avoid GitHub API timeouts for heavily loaded - # # pull requests - # suggestions_per_comment: 10 - docs: name: Build Doxygen Docs - needs: [test] + needs: [sanitize, tests, benchmarks] runs-on: ubuntu-latest From 36741d9587b9a350514d033b35395404d4f20da7 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 22:22:41 +0300 Subject: [PATCH 12/17] FIx --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9337a706b..ebe004c44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,7 +138,7 @@ jobs: - name: Run CMake uses: lukka/run-cmake@v10 with: - configurePreset: ${{ matrix.config.configurePresets }}-tests + configurePreset: ${{ matrix.config.name }}-tests buildPreset: ci-build testPreset: ci-tests From 867c6d9a207e458a19b0c8b55574868587784ed3 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 23:15:44 +0300 Subject: [PATCH 13/17] Simplify --- .github/workflows/ci.yml | 2 +- .github/workflows/comment.yml | 2 +- ci/compare_results.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebe004c44..83fe081b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: - name: Install deps if: matrix.config.os != 'windows-latest' - run: sudo apt-get update -q && sudo apt-get install cppcheck libsfml-dev -y -q + run: sudo apt-get update -q && sudo apt-get install clang-tidy cppcheck libsfml-dev -y -q - name: Restore Catch2 uses: actions/cache@v3 diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index fdf72a8da..2d30a1442 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -63,7 +63,7 @@ jobs: with: issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} comment-author: 'github-actions[bot]' - body-includes: GCC + body-includes: BENCHMARK RESULTS (AUTOGENERATED) - name: Create comment if: github.event.workflow_run.event == 'push' diff --git a/ci/compare_results.py b/ci/compare_results.py index 062242fad..b918af4eb 100644 --- a/ci/compare_results.py +++ b/ci/compare_results.py @@ -3,6 +3,7 @@ results = pd.read_csv("./gh-pages/results.csv", index_col="id") +print("# BENCHMARK RESULTS (AUTOGENERATED)") for platform, data in results.groupby("platform"): indexes = data["commit"].unique()[-2:] test_data =[v[1] for v in data[data["commit"].isin(indexes)].groupby("commit", sort=False, as_index=False)] From 0185ec44a5a7e439a99551d696db6f12f5a7ccb0 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 23:20:58 +0300 Subject: [PATCH 14/17] resolve sonarcloud --- .github/workflows/ci.yml | 58 +++++++++++++++++--- .github/workflows/sonarcloud_analyze.yml | 2 +- .github/workflows/sonarcloud_build.yml | 68 ------------------------ 3 files changed, 53 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/sonarcloud_build.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83fe081b5..0b553d69a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,8 +89,6 @@ jobs: steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Restore Catch2 uses: actions/cache@v3 @@ -180,8 +178,6 @@ jobs: steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Install deps if: matrix.config.os != 'windows-latest' @@ -207,6 +203,57 @@ jobs: name: ${{ matrix.config.name }} path: ${{github.workspace}}/build/test_results/benchmarks/* + sonarcloud: + needs: [download_deps] + name: Build and collect data for sonarcloud + runs-on: ubuntu-latest + + env: + SONAR_SERVER_URL: "https://sonarcloud.io" + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Restore Catch2 + uses: actions/cache@v3 + id: cache-catch2 + with: + path: ${{env.Catch2_DIR}} + key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest + + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar-wrapper + restore-keys: ${{ runner.os }}-sonar-wrapper + + - name: Download and set up build-wrapper + env: + BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip + run: | + mkdir -p $HOME/.sonar + curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} + unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ + echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH + + - name: Run build-wrapper + env: + CC: gcc-10 + CXX: g++-10 + run: | + mkdir build + cmake -S . -B build -DRPP_BUILD_TESTS=1 + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release --parallel 2 + + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: build_wrapper_results + path: ${{ env.BUILD_WRAPPER_OUT_DIR }} + docs: name: Build Doxygen Docs @@ -214,8 +261,7 @@ jobs: runs-on: ubuntu-latest - if: github.event_name == 'push' - && github.repository_owner == 'victimsnino' + if: github.event_name == 'push' && github.repository_owner == 'victimsnino' steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/sonarcloud_analyze.yml b/.github/workflows/sonarcloud_analyze.yml index 4539bfab8..ac0199226 100644 --- a/.github/workflows/sonarcloud_analyze.yml +++ b/.github/workflows/sonarcloud_analyze.yml @@ -1,7 +1,7 @@ name: SonarCloud Analyze on: workflow_run: - workflows: [SonarCloud Build] + workflows: [ci] types: [completed] jobs: analyze_results: diff --git a/.github/workflows/sonarcloud_build.yml b/.github/workflows/sonarcloud_build.yml deleted file mode 100644 index d3064c3c5..000000000 --- a/.github/workflows/sonarcloud_build.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: SonarCloud Build -on: - push: - branches: - - main - paths-ignore: - - '**.md' - pull_request: - branches: - - main - paths-ignore: - - '**.md' - -env: - CATCH2_VERSION: v3.1.0 - Catch2_DIR: ~/Catch2_BIN - -jobs: - build_and_collect_data: - if: false - runs-on: ubuntu-latest - env: - SONAR_SERVER_URL: "https://sonarcloud.io" - BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed - steps: - - uses: actions/checkout@v2 - with: - submodules: true - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - - name: Restore Catch2 - uses: actions/cache@v3 - id: cache-catch2 - with: - path: ${{env.Catch2_DIR}} - key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest - - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar-wrapper - restore-keys: ${{ runner.os }}-sonar-wrapper - - - name: Download and set up build-wrapper - env: - BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip - run: | - mkdir -p $HOME/.sonar - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ - echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH - - - name: Run build-wrapper - env: - CC: gcc-10 - CXX: g++-10 - run: | - mkdir build - cmake -S . -B build -DRPP_BUILD_TESTS=1 - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release --parallel 2 - - - name: Upload results - uses: actions/upload-artifact@v2 - with: - name: build_wrapper_results - path: ${{ env.BUILD_WRAPPER_OUT_DIR }} From 66e8ed2b36b80f815a24b0e8a3487d42ba585817 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 23:29:20 +0300 Subject: [PATCH 15/17] simplify a bit --- .github/workflows/ci.yml | 56 ++++++++-------------------------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b553d69a..235f0caaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,13 +109,13 @@ jobs: strategy: matrix: - config: - - {name: ci-ubuntu-gcc, os: ubuntu-latest} - - {name: ci-ubuntu-clang,os: ubuntu-latest} - - {name: ci-windows, os: windows-latest} + config: [{name: ci-ubuntu-gcc, os: ubuntu-latest}, + {name: ci-ubuntu-clang,os: ubuntu-latest}, + {name: ci-windows, os: windows-latest}] + type: [tests, benchmarks] runs-on: ${{ matrix.config.os }} - name: Unit Tests ${{ matrix.config.name }} + name: ${{ matrix.type }} ${{ matrix.config.name }} steps: - uses: actions/checkout@v3 @@ -136,18 +136,18 @@ jobs: - name: Run CMake uses: lukka/run-cmake@v10 with: - configurePreset: ${{ matrix.config.name }}-tests + configurePreset: ${{ matrix.config.name }}-${{ matrix.type }} buildPreset: ci-build testPreset: ci-tests - name: Analyze diff with clang-tidy - if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' + if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' && ${{ matrix.type }} == 'tests' run: | mkdir clang-tidy-result git diff -U0 origin/main | clang-tidy-diff -j 0 -p1 -path build -export-fixes clang-tidy-result/fixes.yml -extra-arg=-std=c++20 -checks=bugprone-*,concurrency-*,performance-* - name: Run clang-tidy-pr-comments action - if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' + if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' && ${{ matrix.type }} == 'tests' uses: platisd/clang-tidy-pr-comments@master with: # The GitHub token (or a personal access token) @@ -162,43 +162,9 @@ jobs: # pull requests suggestions_per_comment: 10 - benchmarks: - needs: [download_deps] - - strategy: - matrix: - config: - - {name: ci-ubuntu-gcc, os: ubuntu-latest} - - {name: ci-ubuntu-clang,os: ubuntu-latest} - - {name: ci-windows, os: windows-latest} - - - runs-on: ${{ matrix.config.os }} - name: Benchmarks ${{ matrix.config.name }} - - steps: - - uses: actions/checkout@v3 - - - name: Install deps - if: matrix.config.os != 'windows-latest' - run: sudo apt-get update -q && sudo apt-get install cppcheck -y -q - - - name: Restore Catch2 - uses: actions/cache@v3 - id: cache-catch2 - with: - path: ${{env.Catch2_DIR}} - key: catch2-${{env.CATCH2_VERSION}}-${{matrix.config.os}} - - - name: Run CMake - uses: lukka/run-cmake@v10 - with: - configurePreset: ${{ matrix.config.name }}-benchmarks - buildPreset: ci-build - testPreset: ci-tests - - name: Upload benchmark results uses: actions/upload-artifact@v3 + if: ${{ matrix.type }} == 'benchmarks' with: name: ${{ matrix.config.name }} path: ${{github.workspace}}/build/test_results/benchmarks/* @@ -207,7 +173,7 @@ jobs: needs: [download_deps] name: Build and collect data for sonarcloud runs-on: ubuntu-latest - + env: SONAR_SERVER_URL: "https://sonarcloud.io" BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed @@ -257,7 +223,7 @@ jobs: docs: name: Build Doxygen Docs - needs: [sanitize, tests, benchmarks] + needs: [sanitize, tests] runs-on: ubuntu-latest From bc2c6e4d04263a32ece01aa53b4e7096cd30da7e Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 23:36:24 +0300 Subject: [PATCH 16/17] fix --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 235f0caaf..f34a4206b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -141,13 +141,13 @@ jobs: testPreset: ci-tests - name: Analyze diff with clang-tidy - if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' && ${{ matrix.type }} == 'tests' + if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' && matrix.type == 'tests' run: | mkdir clang-tidy-result git diff -U0 origin/main | clang-tidy-diff -j 0 -p1 -path build -export-fixes clang-tidy-result/fixes.yml -extra-arg=-std=c++20 -checks=bugprone-*,concurrency-*,performance-* - name: Run clang-tidy-pr-comments action - if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' && ${{ matrix.type }} == 'tests' + if: matrix.config.name == 'ci-ubuntu-clang' && github.event_name != 'push' && matrix.type == 'tests' uses: platisd/clang-tidy-pr-comments@master with: # The GitHub token (or a personal access token) @@ -164,7 +164,7 @@ jobs: - name: Upload benchmark results uses: actions/upload-artifact@v3 - if: ${{ matrix.type }} == 'benchmarks' + if: matrix.type == 'benchmarks' with: name: ${{ matrix.config.name }} path: ${{github.workspace}}/build/test_results/benchmarks/* From 62a18a2be4e1fbe86eac1a3db6d4d343d6498e4c Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Wed, 31 Aug 2022 23:50:03 +0300 Subject: [PATCH 17/17] fix process_benchmark_data --- ci/process_benchmark_data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/process_benchmark_data.py b/ci/process_benchmark_data.py index 661f67a2a..5c0d3a5d7 100644 --- a/ci/process_benchmark_data.py +++ b/ci/process_benchmark_data.py @@ -11,7 +11,10 @@ for file in os.listdir(os.fsencode("./artifacts")): folder_with_results = os.fsdecode(file) for source in ['rpp', 'rxcpp']: - new_data = parse(f'./artifacts/{folder_with_results}/{source}_benchmark_result.txt') + file_name = f'./artifacts/{folder_with_results}/{source}_benchmark_result.txt' + if not os.path.exists(file_name): + continue + new_data = parse(file_name) new_data["platform"] = [folder_with_results]*len(new_data) new_data["commit"] = [f"{commit_message[:20]}{'...' if len(commit_message)> 20 else ''} ({git_commit})"]*len(new_data) new_data["source"] = [source]*len(new_data)