Skip to content

Fixed #379.

Fixed #379. #1453

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- main
tags:
- '*'
jobs:
macos:
runs-on: macos-latest
strategy:
matrix:
pattern: [0, 1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies
run: |
rm -f /usr/local/bin/2to3*
rm -f /usr/local/bin/idle3*
rm -f /usr/local/bin/pydoc3*
rm -f /usr/local/bin/python3*
brew update
brew install --force boost lcov llvm
- name: Configure
env:
OPENSSL_ROOT_DIR: /usr/local/opt/openssl
S_CFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -fno-omit-frame-pointer -fsanitize=address
S_CXXFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -fno-omit-frame-pointer -fsanitize=address -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING -ftemplate-backtrace-limit=0
S_LDFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -fno-omit-frame-pointer -fsanitize=address
NS_CFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion
NS_CXXFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING -ftemplate-backtrace-limit=0
PROF_CXXFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -fprofile-arcs -ftest-coverage
NS_LDFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion
run: |
[ ${{ matrix.pattern }} == 0 ] || [ ${{ matrix.pattern }} == 1 ] && \
export CFLAGS=${S_CFLAGS} && export CXXFLAGS=${S_CXXFLAGS} && export LDFLAGS=${S_LDFLAGS}
[ ${{ matrix.pattern }} == 2 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 3 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS="${PROF_CXXFLAGS} "&& export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 3 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=OFF "
FLAGS="${FLAGS} -DASYNC_MQTT_BUILD_TOOLS=ON -DASYNC_MQTT_BUILD_UNIT_TESTS=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS=ON"
cmake -S ${{ github.workspace }} -B ${{ runner.temp }} ${FLAGS} -DCMAKE_C_FLAGS="${CFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}"
- name: Compile
env:
CXXFLAGS: -Werror -pedantic -Wall -Wextra -Wno-ignored-qualifiers -Wconversion
run: |
VERBOSE=1 cmake --build ${{ runner.temp }} --parallel $(sysctl -n hw.ncpu) --clean-first
- name: Test
working-directory: ${{ runner.temp }}
run: |
CTEST_ARGS="--log_level=all -- warning" ctest -V
- name: Generate Coverage
if: matrix.pattern == 3
working-directory: ${{ runner.temp }}
continue-on-error: true
run: |
export PATH="/Library/Developer/CommandLineTools/usr/bin:$PATH"
lcov --capture --directory ${{ runner.temp }} --exclude "/usr/*" --exclude "test/*" --exclude "/opt/*" --output-file coverage.info --gcov-tool ${{ github.workspace }}/llvm-gcov.sh --ignore-errors inconsistent,gcov,count,range
lcov --list coverage.info --ignore-errors inconsistent,count,range # debug info
- name: Upload coverage to Codecov
if: matrix.pattern == 3
uses: codecov/codecov-action@v3
with:
files: ${{ runner.temp }}/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
linux:
runs-on: ubuntu-latest
strategy:
matrix:
pattern: [0, 1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache boost
id: cache-boost
uses: actions/cache@v3
with:
path: usr
key: ${{ runner.os }}-boost-20240509
- name: Build boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: ./.github/depends/boost.sh -b 64 -t gcc
- name: Configure
env:
S_CFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -fno-omit-frame-pointer -fsanitize=address
S_CXXFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -fno-omit-frame-pointer -fsanitize=address -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING -ftemplate-backtrace-limit=0
S_LDFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -fno-omit-frame-pointer -fsanitize=address
NS_CFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion
NS_CXXFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING -ftemplate-backtrace-limit=0
PROF_CXXFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -fprofile-arcs -ftest-coverage
NS_CXXFLAGS_GCC: -Werror -Wall -Wextra -Wno-ignored-qualifiers -Wconversion -pedantic -Wno-noexcept-type -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -ftemplate-backtrace-limit=0
NS_LDFLAGS: -Werror -g -Wall -Wextra -Wno-ignored-qualifiers -Wconversion
run: |
[ ${{ matrix.pattern }} == 0 ] || [ ${{ matrix.pattern }} == 1 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 2 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 3 ] && \
export CFLAGS=${NS_CFLAGS} && export CXXFLAGS=${NS_CXXFLAGS_GCC} && export LDFLAGS=${NS_LDFLAGS}
[ ${{ matrix.pattern }} == 0 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 1 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 2 ] && FLAGS="-DCMAKE_CXX_COMPILER=clang++ -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE=ON "
[ ${{ matrix.pattern }} == 3 ] && FLAGS="-DCMAKE_CXX_COMPILER=g++-12 -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=OFF -DASYNC_MQTT_USE_LOG=OFF -DASYNC_MQTT_PRINT_PAYLOAD=OFF -DASYNC_MQTT_BUILD_EXAMPLES=OFF "
FLAGS="$FLAGS -DASYNC_MQTT_BUILD_TOOLS=ON -DASYNC_MQTT_BUILD_UNIT_TESTS=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS=ON"
BOOST_ROOT=/home/runner/work/async_mqtt/async_mqtt/usr cmake -S ${{ github.workspace }} -B ${{ runner.temp }} ${FLAGS} -DCMAKE_C_FLAGS="${CFLAGS}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}"
- name: Compile
run: |
VERBOSE=1 cmake --build ${{ runner.temp }} --parallel $(nproc) --target check_deps
VERBOSE=1 cmake --build ${{ runner.temp }} --target broker
VERBOSE=1 cmake --build ${{ runner.temp }} --parallel $(nproc)
- name: Test
working-directory: ${{ runner.temp }}
run: |
CTEST_ARGS="--log_level=all -- warning" ctest -V
windows:
runs-on: windows-2019
strategy:
matrix:
pattern: [0, 1, 2]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache boost
id: cache-boost
uses: actions/cache@v3
with:
path: D:\a\async_mqtt\async_mqtt\boost
key: ${{ runner.os }}-boost-20240509-3
- name: install boost
if: steps.cache-boost.outputs.cache-hit != 'true'
shell: powershell
run: |
$Url = "https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.7z"
(New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost_1_85_0.7z")
7z.exe x "$env:TEMP\boost_1_85_0.7z"
cd boost_1_85_0
.\bootstrap.bat
.\b2.exe toolset=msvc link=static,shared define=_WIN32_WINNT=0x0A00 install -j2 --prefix=D:\a\async_mqtt\async_mqtt\boost --with-container --with-filesystem --with-log --with-program_options --with-system --with-test
- name: Build and test
shell: powershell
run: |
echo ${{ matrix.pattern }}
if (${{ matrix.pattern }} -eq 0) {
$BUILD_TOOLS = "OFF"
$BUILD_EXAMPLES = "OFF"
$BUILD_EXAMPLES_SEPARATE = "OFF"
$BUILD_UNIT_TESTS = "ON"
$BUILD_SYSTEM_TESTS = "OFF"
}
if (${{ matrix.pattern }} -eq 1) {
$BUILD_TOOLS = "ON"
$BUILD_EXAMPLES = "OFF"
$BUILD_EXAMPLES_SEPARATE = "OFF"
$BUILD_UNIT_TESTS = "OFF"
$BUILD_SYSTEM_TESTS = "ON"
}
if (${{ matrix.pattern }} -eq 2) {
$BUILD_TOOLS = "OFF"
$BUILD_EXAMPLES = "ON"
$BUILD_EXAMPLES_SEPARATE = "ON"
$BUILD_UNIT_TESTS = "OFF"
$BUILD_SYSTEM_TESTS = "OFF"
}
$env:BOOST_ROOT="$PWD\boost"
mkdir build
cd build
$env:CL="/D_WIN32_WINNT#0x0A00 /DBOOST_THREAD_VERSION#3 /DBOOST_ASIO_NO_DEPRECATED /bigobj /EHsc /Zc:preprocessor"
$env:PATH="$env:BOOST_ROOT\lib;"+$env:PATH
cmake -A x64 -G "Visual Studio 16 2019" -DASYNC_MQTT_USE_TLS=OFF -DASYNC_MQTT_USE_WS=OFF -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS="$BUILD_SYSTEM_TESTS" -DASYNC_MQTT_BUILD_UNIT_TESTS="$BUILD_UNIT_TESTS" -DASYNC_MQTT_BUILD_EXAMPLES="$BUILD_EXAMPLES" -DASYNC_MQTT_BUILD_EXAMPLES_SEPARATE="$BUILD_EXAMPLES_SEPARATE" -DASYNC_MQTT_BUILD_TOOLS="$BUILD_TOOLS" ..
if (!$?) {
return Write-Error "cmake failed"
}
cmake --build . --config Release
if (!$?) {
return Write-Error "cmake --build failed"
}
if ("$BUILD_TOOLS" -eq "ON") {
cd tool\Release
$env:PATH="$PWD;"+$env:PATH
cd ..\..
}
# If you want to debug a specific test file with logs, do as follows instead of execute ctest
# st_mqtt_connect.exe --log_level=all
if ("$BUILD_SYSTEM_TESTS" -eq "ON") {
cp test\system\st_broker.conf .
cp test\system\st_auth.json .
}
ctest -V -C Release
if (!$?) {
return Write-Error "ctest -V -C Release failed"
}