-
Notifications
You must be signed in to change notification settings - Fork 12
202 lines (198 loc) · 12.2 KB
/
gha.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
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"
}