-
Notifications
You must be signed in to change notification settings - Fork 2
338 lines (296 loc) · 13.4 KB
/
cmake.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
name: CMake
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
AWS_SDK_CPP_MAJOR: 1
AWS_SDK_CPP_MINOR: 11
AWS_SDK_CPP_PATCH: 286
BOOST_MAJOR: 1
BOOST_MINOR: 84
BOOST_PATCH: 0
jobs:
formatting-check:
runs-on: ubuntu-22.04
name: Formatting checks
steps:
- name: Cheking out source tree
uses: actions/checkout@v4
with:
path: src
fetch-depth: 0
fetch-tags: true
- name: Check for new lines at the end of files
# https://medium.com/@alexey.inkin/how-to-force-newline-at-end-of-files-and-why-you-should-do-it-fdf76d1d090e
working-directory: ${{github.workspace}}/src
run: find . -not -path "./.git/*" -type f | xargs -L1 bash -c 'test -z "$(tail -c1 "$0")" || (echo "No newline at the end of $0" ; false)'
- name: Check formatting with git diff --check
working-directory: ${{github.workspace}}/src
run: git diff --check --color HEAD~
- name: Install dependencies on ubuntu
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install clang-format-17
- name: Info Clang Format
run: clang-format-17 --version
- name: Check formatting with git clang-format-17
working-directory: ${{github.workspace}}/src
run: git clang-format-17 --diff --binary=clang-format-17 HEAD~
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: ${{ matrix.config.name }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
config:
- {
name: "GCC 13 Debug",
build_type: "Debug",
cc: "gcc-13",
cxx: "g++-13",
label: "Debug-gcc13",
run_mtr: true
}
- {
name: "GCC 13 RelWithDebInfo",
build_type: "RelWithDebInfo",
cc: "gcc-13",
cxx: "g++-13",
label: "RelWithDebInfo-gcc13",
run_mtr: true
}
- {
name: "GCC 13 ASan",
build_type: "Debug",
cc: "gcc-13",
cxx: "g++-13",
sanitizer_cmake_flags: "-DWITH_ASAN=ON",
aws_cmake_flags: "-DENABLE_ADDRESS_SANITIZER=ON",
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-fsanitize=address",
label: "ASan-gcc13",
run_mtr: true,
mtr_options: "--sanitize"
}
- {
name: "Clang 17 Debug",
build_type: "Debug",
cc: "clang-17",
cxx: "clang++-17",
libcxx_cmake_flags: "-DWITH_STDLIB_LIBCXX=ON",
aws_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
label: "Debug-clang17",
run_clang_tidy: true
}
- {
name: "Clang 17 RelWithDebInfo",
build_type: "RelWithDebInfo",
cc: "clang-17",
cxx: "clang++-17",
libcxx_cmake_flags: "-DWITH_STDLIB_LIBCXX=ON",
aws_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
label: "RelWithDebInfo-clang17",
run_clang_tidy: true
}
- {
name: "Clang 17 ASan",
build_type: "Debug",
cc: "clang-17",
cxx: "clang++-17",
libcxx_cmake_flags: "-DWITH_STDLIB_LIBCXX=ON",
aws_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++ -DENABLE_ADDRESS_SANITIZER=ON",
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=\"-stdlib=libc++ -fsanitize=address\"",
sanitizer_cmake_flags: "-DWITH_ASAN=ON",
label: "ASan-clang17"
# TODO: re-enable running MTR under "Clang 17 ASan"
# run_mtr: true,
# mtr_options: "--sanitize"
# when "-stdlib=libc++ -fsanitize=address" alloc-dealloc-mismatch issue is fixed
# (https://github.com/llvm/llvm-project/issues/59432)
# or CI is upgraded to Clang 18
}
steps:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Info CPU
run: cat /proc/cpuinfo
- name: Info mount
run: mount
- name: Info df
run: df -h
- name: Info GitHub directories
run: |
echo github.workspace: ${{github.workspace}}
echo runner.temp : ${{runner.temp}}
- name: Install MySQL client libraries and CURL Development libraries
run: |
sudo apt-get update
sudo apt-get install libmysqlclient-dev libcurl4-openssl-dev
- name: Install MySQL server and MTR
if: matrix.config.run_mtr
run: |
sudo apt-get install mysql-client mysql-server mysql-testsuite apparmor-utils
- name: Install Clang dependencies on ubuntu
if: startsWith(matrix.config.name, 'Clang')
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install clang-17 lld-17 clang-tidy-17 libc++-17-dev libc++1-17 libc++abi-17-dev libc++abi1-17
- name: Install GCC dependencies on ubuntu
if: startsWith(matrix.config.name, 'GCC')
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-13
- name: Info CC compiler
run: ${{matrix.config.cc}} --version
- name: Info CXX compiler
run: ${{matrix.config.cxx}} --version
- name: Creating deps directory
run: mkdir -p ${{runner.temp}}/deps
- name: Cache boost libraries
id: cache-boost-static-libraries
uses: actions/cache@v4
with:
path: ${{runner.temp}}/deps/boost-install-${{matrix.config.label}}
key: ${{format('boost-static-libraries-{0}-{1}-{2}-{3}', env.BOOST_MAJOR, env.BOOST_MINOR, env.BOOST_PATCH, matrix.config.label)}}
- name: Checking out Boost source tree
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: boostorg/boost
ref: ${{format('boost-{0}.{1}.{2}', env.BOOST_MAJOR, env.BOOST_MINOR, env.BOOST_PATCH)}}
path: boost
submodules: recursive
fetch-tags: true
- name: Configure CMake for Boost
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
run: |
cmake \
-B ${{github.workspace}}/boost-build-${{matrix.config.label}} \
-S ${{github.workspace}}/boost \
-DCMAKE_INSTALL_PREFIX=${{runner.temp}}/deps/boost-install-${{matrix.config.label}} \
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \
-DCMAKE_C_COMPILER=${{matrix.config.cc}} \
-DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} \
${{matrix.config.boost_cmake_flags}} \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF
- name: CMake info for Boost
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
run: cmake -L ${{github.workspace}}/boost-build-${{matrix.config.label}}
- name: Build for Boost
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
run: cmake --build ${{github.workspace}}/boost-build-${{matrix.config.label}} --config ${{matrix.config.build_type}} --parallel
- name: Install for Boost
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
run: cmake --install ${{github.workspace}}/boost-build-${{matrix.config.label}} --config ${{matrix.config.build_type}}
- name: Cache AWS SDK C++ libraries
id: cache-aws-sdk-cpp-libraries
uses: actions/cache@v4
with:
path: ${{runner.temp}}/deps/aws-sdk-cpp-install-${{matrix.config.label}}
key: ${{format('aws-cpp-sdk-libraries-{0}-{1}-{2}-{3}', env.AWS_SDK_CPP_MAJOR, env.AWS_SDK_CPP_MINOR, env.AWS_SDK_CPP_PATCH, matrix.config.label)}}
- name: Checking out AWS SDK C++ source tree
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: aws/aws-sdk-cpp
ref: ${{format('{0}.{1}.{2}', env.AWS_SDK_CPP_MAJOR, env.AWS_SDK_CPP_MINOR, env.AWS_SDK_CPP_PATCH)}}
path: aws-sdk-cpp
submodules: recursive
fetch-tags: true
- name: Configure CMake for AWS SDK C++
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
run: |
cmake \
-B ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} \
-S ${{github.workspace}}/aws-sdk-cpp \
-DCMAKE_INSTALL_PREFIX=${{runner.temp}}/deps/aws-sdk-cpp-install-${{matrix.config.label}} \
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \
-DCMAKE_C_COMPILER=${{matrix.config.cc}} \
-DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} \
${{matrix.config.aws_cmake_flags}} \
-DCPP_STANDARD=20 \
-DENABLE_UNITY_BUILD=ON \
-DBUILD_SHARED_LIBS=OFF \
-DFORCE_SHARED_CRT=OFF \
-DENABLE_TESTING=OFF \
-DAUTORUN_UNIT_TESTS=OFF \
-DBUILD_ONLY=s3-crt
- name: CMake info for AWS SDK C++
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
run: cmake -L ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}}
- name: Build for AWS SDK C++
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
run: cmake --build ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} --config ${{matrix.config.build_type}} --parallel
- name: Install for AWS SDK C++
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
run: cmake --install ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} --config ${{matrix.config.build_type}}
- name: Checking out source tree
uses: actions/checkout@v4
with:
path: src
fetch-depth: 0
fetch-tags: true
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake -Wdev -Werror=dev -Wdeprecated -Werror=deprecated \
-B ${{github.workspace}}/build-${{matrix.config.label}} \
-S ${{github.workspace}}/src \
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \
-DCMAKE_C_COMPILER=${{matrix.config.cc}} \
-DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} \
-DCPP_STANDARD=20 \
${{matrix.config.libcxx_cmake_flags}} \
${{matrix.config.sanitizer_cmake_flags}} \
-DCMAKE_PREFIX_PATH=${{runner.temp}}/deps/aws-sdk-cpp-install-${{matrix.config.label}} \
-DBoost_ROOT=${{runner.temp}}/deps/boost-install-${{matrix.config.label}} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: CMake info
run: cmake -L ${{github.workspace}}/build-${{matrix.config.label}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build-${{matrix.config.label}} --config ${{matrix.config.build_type}} --parallel
- name: Info Clang Tidy
if: matrix.config.run_clang_tidy
run: clang-tidy-17 --version
- name: Clang Tidy
if: matrix.config.run_clang_tidy
# Run Clang Tidy
run: run-clang-tidy-17 -header-filter=.* -j=${{steps.cpu-cores.outputs.count}} -use-color -p=${{github.workspace}}/build-${{matrix.config.label}}
- name: MTR tests
if: matrix.config.run_mtr
working-directory: /usr/lib/mysql-test
run: |
# Switching MySQL Server Apparmor profile to "complain" as we are creating a custom data directory
sudo aa-complain /usr/sbin/mysqld
# Linking the "binlog_streaming" from the source tree into the MTR suits directory on the system
sudo ln -s ${{github.workspace}}/src/mtr/binlog_streaming /usr/lib/mysql-test/suite/binlog_streaming
# Running MTR from the system package
BINSRV=${{github.workspace}}/build-${{matrix.config.label}}/binlog_server ./mtr \
--client-bindir=/usr/lib/mysql-test/bin --vardir=${{runner.temp}}/mtrvardir \
--force --max-test-fail=0 --retry=0 --nounit-tests --big-test --repeat=2 --parallel=${{steps.cpu-cores.outputs.count}} \
--suite=binlog_streaming ${{matrix.config.mtr_options}}
- name: CTest
working-directory: ${{github.workspace}}/build-${{matrix.config.label}}
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{matrix.config.build_type}} --parallel
- name: Info Build artefacts
run: |
ls -la ${{github.workspace}}
ls -la ${{runner.temp}}
ls -la ${{runner.temp}}/deps