From 203950cbe6b19e64d03e6d68f8fc153507303781 Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Tue, 7 Nov 2023 13:17:29 +0100 Subject: [PATCH 1/5] Add CI builds with Boost.ASIO --- .github/workflows/ci.yml | 103 ++++++++++++++++++++++++++---------- dev/restinio/CMakeLists.txt | 2 + externals.rb | 2 +- 3 files changed, 77 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f2487c0..aa522ea2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ name: CI on: push: - branches: ["master"] + branches: ["master", "0.7-dev"] pull_request: jobs: @@ -77,61 +77,81 @@ jobs: Build-Linux: # The type of runner that the job will run on - name: Ubuntu-22.04 (${{ matrix.compiler.cname }}, ${{ matrix.build_type }}, C++${{ matrix.compiler.cppstd }}) + name: Ubuntu-22.04 (${{ matrix.build_settings.toolset }}-${{ matrix.build_settings.toolset_version }}, ${{ matrix.build_type }}, C++${{ matrix.build_settings.cppstd }}, ${{matrix.build_settings.asio_source}} asio) runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - compiler: - - cname: gcc-9 - cxxname: g++-9 - ar: gcc-ar-9 + build_settings: + - toolset: gcc + toolset_version: 9 cppstd: 17 + asio_source: standalone - - cname: gcc-12 - cxxname: g++-12 - ar: gcc-ar-12 + - toolset: gcc + toolset_version: 9 cppstd: 17 - - cname: gcc-12 - cxxname: g++-12 - ar: gcc-ar-12 + asio_source: boost + + - toolset: gcc + toolset_version: 12 + cppstd: 17 + asio_source: standalone + - toolset: gcc + toolset_version: 12 + cppstd: 20 + asio_source: standalone + - toolset: gcc + toolset_version: 12 cppstd: 20 + asio_source: boost - - cname: clang-13 - cxxname: clang++-13 - ar: llvm-ar-13 + - toolset: clang + toolset_version: 13 cppstd: 17 + asio_source: standalone - - cname: clang-15 - cxxname: clang++-15 - ar: llvm-ar-15 + - toolset: clang + toolset_version: 15 cppstd: 17 - - cname: clang-15 - cxxname: clang++-15 - ar: llvm-ar-15 + asio_source: standalone + - toolset: clang + toolset_version: 15 cppstd: 20 + asio_source: standalone build_type: - Release - Debug env: - CC: ${{ matrix.compiler.cname }} - CXX: ${{ matrix.compiler.cxxname }} - AR: ${{ matrix.compiler.ar }} - RESTINIO_BUILD_DIR: _build_${{ matrix.compiler.cname }}_cpp${{ matrix.compiler.cppstd }}_${{ matrix.build_type }} + RESTINIO_BUILD_TAG: ${{ matrix.build_settings.toolset }}-${{ matrix.build_settings.toolset_version }}_cpp${{ matrix.build_settings.cppstd }}_${{ matrix.build_type }}_${{matrix.build_settings.asio_source}}_asio steps: - uses: actions/checkout@v3 - - name: Print env + - name: Prepare env run: | echo github.event.action: ${{ github.event.action }} echo github.event_name: ${{ github.event_name }} + echo "RESTINIO_BUILD_DIR=_build_${RESTINIO_BUILD_TAG}" >> $GITHUB_ENV + echo "CC=${{ matrix.build_settings.toolset }}-${{ matrix.build_settings.toolset_version }}" >> $GITHUB_ENV + if [ "${{ matrix.build_settings.toolset }}" == "gcc" ]; then + echo "CXX=g++-${{ matrix.build_settings.toolset_version }}" >> $GITHUB_ENV + echo "AR=gcc-ar-${{ matrix.build_settings.toolset_version }}" >> $GITHUB_ENV + else + echo "CXX=clang++-${{ matrix.build_settings.toolset_version }}" >> $GITHUB_ENV + echo "AR=llvm-ar-${{ matrix.build_settings.toolset_version }}" >> $GITHUB_ENV + fi - name: Install dependencies run: | sudo gem install Mxx_ru - - name: Configure + + # run: | + # sudo apt-get update && sudo apt-get install -y libboost-all-dev + + - name: Configure (standalone ASIO) + if: ${{ matrix.build_settings.asio_source == 'standalone' }} shell: bash run: | mxxruexternals @@ -139,8 +159,33 @@ jobs: cmake \ -B ${RESTINIO_BUILD_DIR} \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DRESTINIO_EXPLICIT_CPPSTD=${{ matrix.compiler.cppstd }} \ - -DRESTINIO_TEST_SUFFIX=" [${{ matrix.compiler.cname }}_cpp${{ matrix.compiler.cppstd }}_${{ matrix.build_type }}]" + -DRESTINIO_EXPLICIT_CPPSTD=${{ matrix.build_settings.cppstd }} \ + -DRESTINIO_TEST_SUFFIX=" [${RESTINIO_BUILD_TAG}]" + + - name: Obtain Boost + if: ${{ matrix.build_settings.asio_source == 'boost' }} + uses: MarkusJx/install-boost@v2.4.4 + id: install-boost + with: + boost_version: 1.83.0 + boost_install_dir: ${{github.workspace}}/local_boost + toolset: ${{ matrix.build_settings.toolset }} + platform_version: 22.04 + + - name: Configure (Boost ASIO) + if: ${{ matrix.build_settings.asio_source == 'boost' }} + shell: bash + run: | + mxxruexternals + cd dev + cmake \ + -B ${RESTINIO_BUILD_DIR} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DRESTINIO_EXPLICIT_CPPSTD=${{ matrix.build_settings.cppstd }} \ + -DRESTINIO_ASIO_SOURCE=boost \ + -DBOOST_ROOT=${{ steps.install-boost.outputs.BOOST_ROOT }} \ + -DRESTINIO_TEST_SUFFIX=" [${RESTINIO_BUILD_TAG}]" + - name: Build working-directory: ./dev shell: bash diff --git a/dev/restinio/CMakeLists.txt b/dev/restinio/CMakeLists.txt index 683cce47..23988565 100644 --- a/dev/restinio/CMakeLists.txt +++ b/dev/restinio/CMakeLists.txt @@ -77,6 +77,8 @@ elseif (RESTINIO_ASIO_SOURCE STREQUAL "boost") "Unable to identify how to depend on Boost::asio. " "Giving up...") endif () + + target_compile_definitions(${RESTINIO_LIBRARY_NAME} INTERFACE RESTINIO_USE_BOOST_ASIO) else () message(FATAL_ERROR "Invalid value for RESTINIO_ASIO_SOURCE (${RESTINIO_ASIO_SOURCE})") endif () diff --git a/externals.rb b/externals.rb index 11166cad..72c2044f 100644 --- a/externals.rb +++ b/externals.rb @@ -1,5 +1,5 @@ MxxRu::arch_externals :so5 do |e| - e.url 'https://github.com/Stiffstream/sobjectizer/archive/v.5.8.1.tar.gz' + e.url 'https://github.com/Stiffstream/sobjectizer/archive/v.5.7.5.tar.gz' e.map_dir 'dev/so_5' => 'dev' end From 5112a482df1a825e7203b6c2c14db9f6ec5cec3e Mon Sep 17 00:00:00 2001 From: Yauheni Akhotnikau Date: Wed, 8 Nov 2023 09:32:29 +0300 Subject: [PATCH 2/5] [skip ci] SObjectizer updated to v.5.8.1.1. --- externals.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals.rb b/externals.rb index 72c2044f..8fac1b19 100644 --- a/externals.rb +++ b/externals.rb @@ -1,5 +1,5 @@ MxxRu::arch_externals :so5 do |e| - e.url 'https://github.com/Stiffstream/sobjectizer/archive/v.5.7.5.tar.gz' + e.url 'https://github.com/Stiffstream/sobjectizer/archive/v.5.8.1.1.tar.gz' e.map_dir 'dev/so_5' => 'dev' end From 9bbf20a0b3ae7233a9c326b4667b8af275260ce3 Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Wed, 8 Nov 2023 13:06:36 +0100 Subject: [PATCH 3/5] Add system boost package to CI --- .github/workflows/ci.yml | 34 ++++++++++++++----- dev/CMakeLists.txt | 2 +- .../router/express_boost_regex/CMakeLists.txt | 3 +- .../express_router_boost_regex/CMakeLists.txt | 4 +-- .../CMakeLists.txt | 3 +- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa522ea2..d9ebc3f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,6 +63,7 @@ jobs: cmake \ --build $RESTINIO_BUILD_DIR \ --config ${{ matrix.build_type }} \ + --parallel ${NUMBER_OF_PROCESSORS} \ --verbose - name: Test shell: bash @@ -93,6 +94,11 @@ jobs: cppstd: 17 asio_source: boost + - toolset: gcc + toolset_version: 9 + cppstd: 17 + asio_source: boost-system-package + - toolset: gcc toolset_version: 12 cppstd: 17 @@ -145,16 +151,15 @@ jobs: - name: Install dependencies run: | sudo gem install Mxx_ru + if [ "${{ matrix.build_settings.asio_source }}" == "boost-system-package" ]; then + sudo apt-get update && sudo apt-get install -y libboost-all-dev + fi + mxxruexternals - - # run: | - # sudo apt-get update && sudo apt-get install -y libboost-all-dev - - - name: Configure (standalone ASIO) + - name: Configure if: ${{ matrix.build_settings.asio_source == 'standalone' }} shell: bash run: | - mxxruexternals cd dev cmake \ -B ${RESTINIO_BUILD_DIR} \ @@ -172,11 +177,10 @@ jobs: toolset: ${{ matrix.build_settings.toolset }} platform_version: 22.04 - - name: Configure (Boost ASIO) + - name: Configure if: ${{ matrix.build_settings.asio_source == 'boost' }} shell: bash run: | - mxxruexternals cd dev cmake \ -B ${RESTINIO_BUILD_DIR} \ @@ -186,12 +190,25 @@ jobs: -DBOOST_ROOT=${{ steps.install-boost.outputs.BOOST_ROOT }} \ -DRESTINIO_TEST_SUFFIX=" [${RESTINIO_BUILD_TAG}]" + - name: Configure + if: ${{ matrix.build_settings.asio_source == 'boost-system-package' }} + shell: bash + run: | + cd dev + cmake \ + -B ${RESTINIO_BUILD_DIR} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DRESTINIO_EXPLICIT_CPPSTD=${{ matrix.build_settings.cppstd }} \ + -DRESTINIO_ASIO_SOURCE=boost \ + -DRESTINIO_TEST_SUFFIX=" [${RESTINIO_BUILD_TAG}]" + - name: Build working-directory: ./dev shell: bash run: | cmake \ --build $RESTINIO_BUILD_DIR \ + --parallel $(nproc) \ --verbose - name: Test shell: bash @@ -247,6 +264,7 @@ jobs: run: | cmake \ --build $RESTINIO_BUILD_DIR \ + --parallel $(sysctl -n hw.ncpu) \ --verbose - name: Test shell: bash diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index bc50c066..318c7496 100644 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -137,7 +137,7 @@ if (RESTINIO_ASIO_SOURCE STREQUAL "standalone") endif () else () if (NOT RESTINIO_USE_SYSTEM_BOOST_ASIO) - find_package(Boost REQUIRED) + find_package(Boost REQUIRED COMPONENTS headers regex) endif () endif () diff --git a/dev/test/router/express_boost_regex/CMakeLists.txt b/dev/test/router/express_boost_regex/CMakeLists.txt index 540b9799..e0278c19 100644 --- a/dev/test/router/express_boost_regex/CMakeLists.txt +++ b/dev/test/router/express_boost_regex/CMakeLists.txt @@ -8,5 +8,4 @@ set(UNITTEST_SRCFILES main.cpp ) include(${CMAKE_SOURCE_DIR}/cmake/unittest.cmake) -TARGET_INCLUDE_DIRECTORIES(${UNITTEST} PRIVATE ${Boost_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(${UNITTEST} PRIVATE ${Boost_REGEX_LIBRARY}) +TARGET_LINK_LIBRARIES(${UNITTEST} PRIVATE Boost::regex) diff --git a/dev/test/router/express_router_boost_regex/CMakeLists.txt b/dev/test/router/express_router_boost_regex/CMakeLists.txt index 98744083..ca8f0cfd 100644 --- a/dev/test/router/express_router_boost_regex/CMakeLists.txt +++ b/dev/test/router/express_router_boost_regex/CMakeLists.txt @@ -1,5 +1,5 @@ set(UNITTEST _unit.test.router.express_router_boost_regex) include(${CMAKE_SOURCE_DIR}/cmake/unittest.cmake) -TARGET_INCLUDE_DIRECTORIES(${UNITTEST} PRIVATE ${Boost_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(${UNITTEST} PRIVATE ${Boost_REGEX_LIBRARY}) +TARGET_LINK_LIBRARIES(${UNITTEST} PRIVATE Boost::regex) + diff --git a/dev/test/router/express_router_boost_regex_bench/CMakeLists.txt b/dev/test/router/express_router_boost_regex_bench/CMakeLists.txt index 4704e298..292034df 100644 --- a/dev/test/router/express_router_boost_regex_bench/CMakeLists.txt +++ b/dev/test/router/express_router_boost_regex_bench/CMakeLists.txt @@ -1,5 +1,4 @@ set(TEST_BENCH _test.router.express_router_boost_regex_bench) include(${CMAKE_SOURCE_DIR}/cmake/testbench.cmake) -TARGET_INCLUDE_DIRECTORIES(${TEST_BENCH} PRIVATE ${Boost_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(${TEST_BENCH} PRIVATE ${Boost_REGEX_LIBRARY}) +TARGET_LINK_LIBRARIES(${TEST_BENCH} PRIVATE Boost::regex) From 7a12037e7ad47565d96e243097a257d2acb56afb Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Wed, 8 Nov 2023 23:06:21 +0100 Subject: [PATCH 4/5] [skip ci] add FIXME to failing tests --- .../async_chained_handlers_2/main.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dev/test/handle_requests/async_chained_handlers_2/main.cpp b/dev/test/handle_requests/async_chained_handlers_2/main.cpp index 256a8222..f4b46c11 100644 --- a/dev/test/handle_requests/async_chained_handlers_2/main.cpp +++ b/dev/test/handle_requests/async_chained_handlers_2/main.cpp @@ -260,14 +260,17 @@ tc_fixed_size_chain_accept_in_middle() env.introduce_coop( so_5::disp::active_obj::make_dispatcher( env ).binder(), [&]( so_5::coop_t & coop ) { - destinations[ 3u ] = coop.make_agent< dummy_stage_t >( - stages_completed, destinations[ 0u ] )->so_direct_mbox(); - destinations[ 2u ] = coop.make_agent< dummy_stage_t >( - stages_completed, destinations[ 3u ] )->so_direct_mbox(); destinations[ 1u ] = coop.make_agent< response_maker_t >( stages_completed )->so_direct_mbox(); destinations[ 0u ] = coop.make_agent< dummy_stage_t >( stages_completed, destinations[ 1u ] )->so_direct_mbox(); + destinations[ 3u ] = coop.make_agent< dummy_stage_t >( + stages_completed, destinations[ 0u ] )->so_direct_mbox(); + destinations[ 2u ] = coop.make_agent< dummy_stage_t >( + stages_completed, destinations[ 3u ] )->so_direct_mbox(); + + // FIXME: THis code must be completed before + // starting http server. } ); } }; @@ -280,21 +283,26 @@ tc_fixed_size_chain_accept_in_middle() .address( "127.0.0.1" ) .request_handler( [&destinations]( auto controller ) { + // TODO: assert can be removed once the above FIX is done. + assert(destinations[ 0u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 0u ], std::move(controller) ); return restinio::async_chain::ok(); }, [&destinations]( auto controller ) { + assert(destinations[ 1u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 1u ], std::move(controller) ); return restinio::async_chain::ok(); }, [&destinations]( auto controller ) { + assert(destinations[ 2u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 2u ], std::move(controller) ); return restinio::async_chain::ok(); }, [&destinations]( auto controller ) { + assert(destinations[ 3u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 3u ], std::move(controller) ); return restinio::async_chain::ok(); From 066ae954322fb028d880b2a32ec89d24daf733b8 Mon Sep 17 00:00:00 2001 From: Yauheni Akhotnikau Date: Thu, 9 Nov 2023 08:56:12 +0300 Subject: [PATCH 5/5] BugFix in implementation of SObjectizer-based tests. --- .../async_chained_handlers_2/main.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dev/test/handle_requests/async_chained_handlers_2/main.cpp b/dev/test/handle_requests/async_chained_handlers_2/main.cpp index f4b46c11..d6db6b49 100644 --- a/dev/test/handle_requests/async_chained_handlers_2/main.cpp +++ b/dev/test/handle_requests/async_chained_handlers_2/main.cpp @@ -15,6 +15,8 @@ #include "../../common/test_extra_data_factory.ipp" +#include + using atomic_counter_t = std::atomic< unsigned int >; template< typename Extra_Data_Factory > @@ -156,6 +158,7 @@ tc_fixed_size_chain() std::array< so_5::mbox_t, 4u > destinations; + std::promise< void > coop_registered_promise; so_5::wrapped_env_t sobjectizer{ [&]( so_5::environment_t & env ) { env.introduce_coop( @@ -170,8 +173,10 @@ tc_fixed_size_chain() destinations[ 0u ] = coop.make_agent< dummy_stage_t >( stages_completed, destinations[ 1u ] )->so_direct_mbox(); } ); + coop_registered_promise.set_value(); } }; + coop_registered_promise.get_future().get(); http_server_t http_server{ restinio::own_io_context(), @@ -255,6 +260,7 @@ tc_fixed_size_chain_accept_in_middle() std::array< so_5::mbox_t, 4u > destinations; + std::promise< void > coop_registered_promise; so_5::wrapped_env_t sobjectizer{ [&]( so_5::environment_t & env ) { env.introduce_coop( @@ -268,12 +274,11 @@ tc_fixed_size_chain_accept_in_middle() stages_completed, destinations[ 0u ] )->so_direct_mbox(); destinations[ 2u ] = coop.make_agent< dummy_stage_t >( stages_completed, destinations[ 3u ] )->so_direct_mbox(); - - // FIXME: THis code must be completed before - // starting http server. } ); + coop_registered_promise.set_value(); } }; + coop_registered_promise.get_future().get(); http_server_t http_server{ restinio::own_io_context(), @@ -283,26 +288,21 @@ tc_fixed_size_chain_accept_in_middle() .address( "127.0.0.1" ) .request_handler( [&destinations]( auto controller ) { - // TODO: assert can be removed once the above FIX is done. - assert(destinations[ 0u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 0u ], std::move(controller) ); return restinio::async_chain::ok(); }, [&destinations]( auto controller ) { - assert(destinations[ 1u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 1u ], std::move(controller) ); return restinio::async_chain::ok(); }, [&destinations]( auto controller ) { - assert(destinations[ 2u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 2u ], std::move(controller) ); return restinio::async_chain::ok(); }, [&destinations]( auto controller ) { - assert(destinations[ 3u ]); so_5::send< so_5::mutable_msg< your_turn_t > >( destinations[ 3u ], std::move(controller) ); return restinio::async_chain::ok(); @@ -362,6 +362,7 @@ tc_fixed_size_chain_response_with_pause() std::array< so_5::mbox_t, 2u > destinations; + std::promise< void > coop_registered_promise; so_5::wrapped_env_t sobjectizer{ [&]( so_5::environment_t & env ) { env.introduce_coop( @@ -372,8 +373,10 @@ tc_fixed_size_chain_response_with_pause() destinations[ 0u ] = coop.make_agent< dummy_stage_t >( stages_completed, destinations[ 1u ] )->so_direct_mbox(); } ); + coop_registered_promise.set_value(); } }; + coop_registered_promise.get_future().get(); http_server_t http_server{ restinio::own_io_context(), @@ -452,6 +455,7 @@ tc_growable_size_chain() std::array< so_5::mbox_t, 4u > destinations; + std::promise< void > coop_registered_promise; so_5::wrapped_env_t sobjectizer{ [&]( so_5::environment_t & env ) { env.introduce_coop( @@ -466,8 +470,10 @@ tc_growable_size_chain() destinations[ 0u ] = coop.make_agent< dummy_stage_t >( stages_completed, destinations[ 1u ] )->so_direct_mbox(); } ); + coop_registered_promise.set_value(); } }; + coop_registered_promise.get_future().get(); typename request_handler_t::builder_t handler_builder; @@ -560,6 +566,7 @@ tc_growable_size_chain_accept_in_middle() std::array< so_5::mbox_t, 4u > destinations; + std::promise< void > coop_registered_promise; so_5::wrapped_env_t sobjectizer{ [&]( so_5::environment_t & env ) { env.introduce_coop( @@ -574,8 +581,10 @@ tc_growable_size_chain_accept_in_middle() destinations[ 0u ] = coop.make_agent< dummy_stage_t >( stages_completed, destinations[ 1u ] )->so_direct_mbox(); } ); + coop_registered_promise.set_value(); } }; + coop_registered_promise.get_future().get(); typename request_handler_t::builder_t handler_builder;