From 9ada50dd66ffaf3ff68126de6dc7b39c99e90aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korina=20=C5=A0imi=C4=8Devi=C4=87?= Date: Fri, 5 Jan 2024 13:37:20 +0100 Subject: [PATCH] Setup CI posix pipeline Summary: related to T13434 results: https://github.com/ksimicevic/async-mqtt5/actions/runs/7423093001/job/20199741951 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Differential Revision: https://repo.mireo.local/D27242 --- .github/workflows/ci.yml | 133 ++++++++++++++++++++++++++ test/unit/CMakeLists.txt | 2 +- test/unit/test/compilation_checks.cpp | 2 +- 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..970615e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,133 @@ +name: CI + +on: [push, pull_request] + +env: + BOOST_VERSION: 1.82.0 + BOOST_DIR_VER_NAME: 1_82_0 + +jobs: + posix: + name: "${{ matrix.toolset }} std=c++${{ matrix.cxxstd }} ${{ matrix.build-type }}" + defaults: + run: + shell: bash + + strategy: + fail-fast: false + matrix: + include: + - toolset: g++-11 + compiler: g++-11 + install: g++-11 + os: ubuntu-latest + container: ubuntu:22.04 + cxxstd: '17' + build-type: 'Release' + cxxflags: '-Wall -Wextra' + ldflags: '' + + - toolset: g++-12 + compiler: g++-12 + install: g++-12 + os: ubuntu-latest + container: ubuntu:22.04 + cxxstd: '20' + build-type: 'Release' + cxxflags: '-Wall -Wextra' + ldflags: '' + + - toolset: clang++-12 + compiler: clang++-12 + install: clang++-12 + os: ubuntu-latest + container: ubuntu:22.04 + cxxstd: '17' + build-type: 'Release' + cxxflags: '-Wall -Wextra -fdeclspec' + ldflags: '' + + - toolset: clang++-14-libc++-14 + compiler: clang++-14 + install: 'clang++-14 libc++-14-dev libc++abi-14-dev' + os: ubuntu-latest + container: ubuntu:22.04 + cxxstd: '17' + build-type: 'Release' + cxxflags: '-Wall -Wextra -stdlib=libc++' + ldflags: '-lc++' + + - toolset: clang++-14-libc++-14 + compiler: clang++-14 + install: 'clang++-14 libc++-14-dev libc++abi-14-dev' + os: ubuntu-latest + container: ubuntu:22.04 + cxxstd: '20' + build-type: 'Release' + cxxflags: '-Wall -Wextra -stdlib=libc++' + ldflags: '-lc++' + + - toolset: clang++-15 + compiler: clang++-15 + install: clang++-15 + os: ubuntu-latest + container: ubuntu:22.04 + cxxstd: '20' + build-type: 'Release' + cxxflags: '-Wall -Wextra -fdeclspec' + ldflags: '' + + runs-on: ${{ matrix.os }} + container: ${{matrix.container}} + env: + CXXFLAGS: ${{matrix.cxxflags}} -Wall -Wextra + LDFLAGS: ${{matrix.ldflags}} + CMAKE_BUILD_PARALLEL_LEVEL: 4 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup container environment + if: matrix.container + run: | + apt-get update + apt-get -y install sudo wget tar cmake git openssl libssl-dev pkg-config + + - name: Install compiler + run: sudo apt-get install -y ${{ matrix.install }} + + - name: Install Boost + uses: MarkusJx/install-boost@v2.4.1 + id: install-boost + with: + boost_version: 1.82.0 + platform_version: 22.04 + + # try header only instead of using prebuilt binaries + # - name: Download Boost + # run: | + # wget https://boostorg.jfrog.io/artifactory/main/release/${{env.BOOST_VERSION}}/source/boost_${{env.BOOST_DIR_VER_NAME}}.tar.gz + # tar xzf boost_${{env.BOOST_DIR_VER_NAME}}.tar.gz + # mkdir boost + # mv boost_${{env.BOOST_DIR_VER_NAME}}/boost boost + # rm -rf boost_${{env.BOOST_DIR_VER_NAME}} boost_${{env.BOOST_DIR_VER_NAME}}.tar.gz + + - name: Run CMake + run: | + cmake -S . -B build/${{matrix.compiler}} \ + -DCMAKE_CXX_COMPILER="${{matrix.compiler}}" -DCMAKE_CXX_FLAGS="${{env.CXXFLAGS}}" -DCMAKE_PREFIX_PATH="build/${{matrix.compiler}}" + sudo cmake --install build/${{matrix.compiler}} + env: + BOOST_ROOT: ${{steps.install-boost.outputs.BOOST_ROOT}} + + - name: Build tests + run: | + cmake -S test/unit -B test/unit/build/${{matrix.compiler}} \ + -DCMAKE_CXX_COMPILER="${{matrix.compiler}}" -DCMAKE_CXX_FLAGS="${{env.CXXFLAGS}}" -DCMAKE_PREFIX_PATH="test/unit/build/${{matrix.compiler}}" + cmake --build test/unit/build/${{matrix.compiler}} + env: + BOOST_ROOT: ${{steps.install-boost.outputs.BOOST_ROOT}} + + - name: Run tests + run: ctest --test-dir test/unit/build/${{matrix.compiler}} --output-on-failure --no-tests=error diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index b4e65f9..c09c20e 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories(mqtt-test PRIVATE include) target_compile_features(mqtt-test PRIVATE cxx_std_17) target_compile_definitions(mqtt-test PRIVATE BOOST_TEST_NO_MAIN=1) -find_package(OpenSSL) +find_package(OpenSSL REQUIRED) target_link_libraries(mqtt-test PRIVATE Async::MQTT5 OpenSSL::SSL) add_test(NAME mqtt-test COMMAND mqtt-test) diff --git a/test/unit/test/compilation_checks.cpp b/test/unit/test/compilation_checks.cpp index 46694b2..cd239a4 100644 --- a/test/unit/test/compilation_checks.cpp +++ b/test/unit/test/compilation_checks.cpp @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(client_functions) { connack_props ca_props; ca_props.visit([&tcp_client](const auto& p, auto&) -> bool { using ptype = boost::remove_cv_ref_t; - prop::value_type_t value = tcp_client.connack_property(p); + [[maybe_unused]] prop::value_type_t value = tcp_client.connack_property(p); return true; });