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/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a7c4e7ea..f34a4206b 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 @@ -67,29 +66,25 @@ jobs: path: ${{env.Catch2_DIR}} key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest - - name: Configure - run: cmake --preset=ci-coverage - - - name: Build - run: cmake --build build/coverage -j 2 - - - 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-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 + file: build/coverage.info sanitize: - name: Sanitizer - needs: [download_deps] + name: Sanitize runs-on: ubuntu-latest steps: @@ -100,55 +95,36 @@ jobs: id: cache-catch2 with: path: ${{env.Catch2_DIR}} - key: catch2-${{env.CATCH2_VERSION}}-ubuntu-latest - - - name: Configure - run: cmake --preset=ci-sanitize - - - name: Build - run: cmake --build build/sanitize -j 2 + key: catch2-${{env.CATCH2_VERSION}}-${{matrix.config.os}} - - 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-build + testPreset: ci-sanitize - test: + tests: 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 + matrix: + 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 }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.type }} ${{ 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 update -q && sudo apt-get install clang-tidy cppcheck libsfml-dev -y -q - name: Restore Catch2 uses: actions/cache@v3 @@ -157,38 +133,21 @@ 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: Upload benchmark results - uses: actions/upload-artifact@v3 + - name: Run CMake + uses: lukka/run-cmake@v10 with: - name: ${{ matrix.config.name }} - path: | - ${{github.workspace}}/build/test_results/benchmarks/* + 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) @@ -203,15 +162,72 @@ jobs: # pull requests suggestions_per_comment: 10 + - 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/* + + 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 - needs: [sanitize, test] + needs: [sanitize, tests] 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/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/.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 22b48e3ac..000000000 --- a/.github/workflows/sonarcloud_build.yml +++ /dev/null @@ -1,67 +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: - 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 }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 46cb46281..13b27100b 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..32bbce03f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -26,26 +26,11 @@ "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" } }, { - "name": "ci-std", + "name": "std", "description": "This preset makes sure the project actually builds with at least the specified standard", "hidden": true, "cacheVariables": { @@ -54,6 +39,14 @@ "CMAKE_CXX_STANDARD_REQUIRED": "ON" } }, + { + "name": "ci-flags", + "hidden" : true, + "inherits" : ["dev-mode", "std"], + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON" + } + }, { "name": "flags-unix", "hidden": true, @@ -73,30 +66,27 @@ "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 }, + + + + { - "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" } }, { @@ -105,6 +95,9 @@ "environment": { "CC" : "gcc-10", "CXX": "g++-10" + }, + "cacheVariables": { + "RPP_GCOV_TOOL" : "/usr/bin/gcov-10" } }, { @@ -116,21 +109,27 @@ } }, { - "name": "ci-build", - "binaryDir": "${sourceDir}/build", - "hidden": true + "name" : "ci-build-tests", + "hidden": true, + "cacheVariables": { + "RPP_BUILD_TESTS" : "ON", + "RPP_BUILD_EXAMPLES" : "ON" + } }, { - "name" : "ci-build-rxcpp", + "name" : "ci-build-examples", "hidden": true, "cacheVariables": { - "RPP_BUILD_RXCPP" : "ON" + "RPP_BUILD_EXAMPLES" : "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 +138,35 @@ "RPP_BUILD_SFML_CODE" : "ON" } }, + { + "name": "coverage-unix", + "inherits": ["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-build", + "binaryDir": "${sourceDir}/build", + "inherits" : ["ci-flags"] + }, { "name": "ci-coverage", - "inherits": ["coverage-unix", "ci-gcc"], + "inherits": ["ci-build", "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", "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 +174,67 @@ }, { "name": "ci-macos-tests", - "inherits": ["ci-build-tests", "ci-unix"] + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-unix"] }, { "name": "ci-ubuntu-clang-tests", - "inherits": ["ci-build-tests", "ci-unix", "ci-clang", "cppcheck", "ci-build-sfml"] + "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-tests", "ci-unix", "ci-gcc", "ci-build-sfml"] + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-build-sfml", "ci-unix", "ci-gcc", "cppcheck"] }, { "name": "ci-windows-tests", - "inherits": ["ci-build-tests", "ci-win64"] + "inherits": ["ci-build", "ci-build-tests", "ci-build-examples", "ci-win64"] + }, + + + + + { + "name": "ci-macos-benchmarks", + "inherits": ["ci-build", "ci-build-benchmarks", "ci-unix"] + }, + { + "name": "ci-ubuntu-clang-benchmarks", + "inherits": ["ci-build", "ci-build-benchmarks", "ci-unix", "ci-clang", "cppcheck" ] + }, + { + "name": "ci-ubuntu-gcc-benchmarks", + "inherits": ["ci-build", "ci-build-benchmarks", "ci-unix", "ci-gcc", "cppcheck"] + }, + { + "name": "ci-windows-benchmarks", + "inherits": ["ci-build", "ci-build-benchmarks", "ci-win64"] + } + ], + "buildPresets" :[ + { + "name" : "ci-build", + "jobs" : 2, + "configuration" : "Release", + "configurePreset" : "ci-build" + } + ] + , + "testPresets": [ + { + "name": "ci-tests", + "configuration": "Release", + "output": { + "outputOnFailure": true + }, + "configurePreset" : "ci-build" + }, + { + "name": "ci-sanitize", + "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" + } } ] -} +} \ No newline at end of file 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)] 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) 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" diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index ce131eb40..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) +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..0776ad3af --- /dev/null +++ b/src/benchmarks/CMakeLists.txt @@ -0,0 +1,33 @@ +# 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 +# + + +function(add_benchmark benchmark_name) + set(TARGET ${benchmark_name}_benchmark) + + add_executable(${TARGET} ${TARGET}.cpp) + + 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() + + add_test(NAME ${TARGET} COMMAND $ -r xml -o ${RPP_TEST_BENCHMARKS_RESULTS_DIR}/${TARGET}_result.txt) + +endfunction() + +add_benchmark(rpp) + +if (RPP_BUILD_RXCPP) + add_benchmark(rxcpp) +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()