-
Notifications
You must be signed in to change notification settings - Fork 289
316 lines (279 loc) · 14 KB
/
ci.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
name: CI
'on':
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
ASAN_OPTIONS: detect_odr_violation=2
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- cmake-flags: >-
-GNinja
-DCMAKE_CXX_COMPILER=clang++-18
-DCMAKE_C_COMPILER=clang-18
-DUSERVER_SANITIZE="ub addr"
-DCMAKE_BUILD_TYPE=Debug
-DUSERVER_NO_WERROR=OFF
-DUSERVER_NAMESPACE=userver_ns
-DUSERVER_NAMESPACE_BEGIN="namespace userver_ns { inline namespace
v1 {"
-DUSERVER_NAMESPACE_END="}}"
-DUSERVER_PG_SERVER_INCLUDE_DIR=/usr/include/postgresql/16/server
-DUSERVER_PG_SERVER_LIBRARY_DIR=/usr/lib/postgresql/16/lib
os: ubuntu-24.04
info: clang-18 + debug + sanitize addr+ub
tests-flags: ''
ccache-dir: ~/.cache/ccache
- cmake-flags: >-
-GNinja
-DCMAKE_CXX_COMPILER=clang++-14
-DCMAKE_C_COMPILER=clang-14
-DUSERVER_SANITIZE="ub addr"
-DCMAKE_BUILD_TYPE=Debug
-DUSERVER_NO_WERROR=OFF
-DUSERVER_NAMESPACE=userver_ns
-DUSERVER_NAMESPACE_BEGIN="namespace userver_ns { inline namespace
v1 {"
-DUSERVER_NAMESPACE_END="}}"
-DUSERVER_PG_SERVER_INCLUDE_DIR=/usr/include/postgresql/15/server
-DUSERVER_PG_SERVER_LIBRARY_DIR=/usr/lib/postgresql/15/lib
os: ubuntu-22.04
info: clang-14 + debug + sanitize addr+ub
tests-flags: ''
ccache-dir: ~/.cache/ccache
- cmake-flags: >-
-GNinja
-DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0
-DUSERVER_FEATURE_REDIS_HI_MALLOC=1
-DUSERVER_NO_WERROR=1
-DUSERVER_FORCE_DOWNLOAD_ABSEIL=0
-DUSERVER_DOWNLOAD_PACKAGE_ABSEIL=0
-DCMAKE_BUILD_TYPE=Release
os: ubuntu-20.04
info: g++-9 + release
tests-flags: '--gtest_filter=-HttpClient.RedirectHeaders:HttpClient.TestUseIPv4v6'
ccache-dir: ~/.ccache
# GCC-8 - testing minimal required compiler
- cmake-flags: >-
-GNinja
-DCMAKE_CXX_COMPILER=g++-8
-DCMAKE_C_COMPILER=gcc-8
-DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0
-DUSERVER_FEATURE_REDIS_HI_MALLOC=1
-DUSERVER_NO_WERROR=1
-DUSERVER_FORCE_DOWNLOAD_ABSEIL=0
-DUSERVER_DOWNLOAD_PACKAGE_ABSEIL=0
-DCMAKE_BUILD_TYPE=Debug
os: ubuntu-20.04
info: g++-8 + debug
tests-flags: '--gtest_filter=-HttpClient.RedirectHeaders:HttpClient.TestUseIPv4v6'
ccache-dir: ~/.ccache
name: '${{matrix.os}}: ${{matrix.info}}'
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Reuse ccache directory
uses: actions/cache@v4
with:
path: '${{matrix.ccache-dir}}'
key: '${{matrix.os}} ${{matrix.info}} ccache-dir ${{github.ref}} run-${{github.run_number}}'
restore-keys: |
${{matrix.os}} ${{matrix.info}} ccache-dir ${{github.ref}} run-'
${{matrix.os}} ${{matrix.info}} ccache-
- name: Setup ramdrive for testsuites
run: |
sudo mkdir -p "/mnt/ramdisk/$USER"
sudo chmod 777 "/mnt/ramdisk/$USER"
sudo mount -t tmpfs -o size=2048M tmpfs "/mnt/ramdisk/$USER"
- name: Free disk space
run: |
df -h
# See https://stackoverflow.com/questions/75536771/github-runner-out-of-disk-space-after-building-docker-image
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/lib/php* /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/opt/hostedtoolcache/CodeQL || true
sudo docker image prune --all --force
df -h
- name: Add confluentinc repositories
if: matrix.os != 'ubuntu-24.04'
run: |
# Adding librdkafka confluent repositories as in https://docs.confluent.io/platform/current/installation/installing_cp/deb-ubuntu.html#get-the-software
gpg_retrieve_keyserver() {
GNUPGHOME=$(mktemp -d)
GNUPGHOME="$GNUPGHOME" gpg --no-default-keyring --keyring "/usr/share/keyrings/$2.gpg" --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $1
rm -rf "$GNUPGHOME"
chmod a+r "/usr/share/keyrings/$2.gpg"
}
gpg_retrieve_keyserver 8B1DA6120C2BF624 confluent
printf "\
deb [arch=amd64 signed-by=/usr/share/keyrings/confluent.gpg] https://packages.confluent.io/deb/7.6 stable main\n\
deb [signed-by=/usr/share/keyrings/confluent.gpg] https://packages.confluent.io/clients/deb $(lsb_release -cs) main\n" \
| sudo tee /etc/apt/sources.list.d/confluent.list
- name: Install clang-format
if: matrix.os == 'ubuntu-20.04'
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
sudo apt install clang-format-14
sudo ln -sf /usr/bin/clang-format-14 /usr/bin/clang-format
clang-format --version
- name: Install grpc, protobuf and abseil
if: matrix.os == 'ubuntu-20.04'
run: |
git clone --recursive -b v1.45.0 https://github.com/grpc/grpc new_grpc
cmake -S./new_grpc -B./new_grpc/build -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON
cmake --build new_grpc/build -- -j$(nproc)
sudo cmake --install new_grpc/build
- name: Add missing repositories
run: |
sudo apt update
# Instructions from https://clickhouse.com/docs/en/getting-started/install/
sudo apt install -y apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754
echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list
# Adding mariadb repositories (from https://www.linuxcapable.com/how-to-install-mariadb-on-ubuntu-linux/ )
curl -fsSL http://mirror.mariadb.org/PublicKey_v2 | sudo gpg --dearmor -o "/usr/share/keyrings/mariadb.gpg"
sudo chmod a+r "/usr/share/keyrings/mariadb.gpg"
# Restore the correct URL after https://jira.mariadb.org/browse/MDBF-651
#echo "deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/mariadb.gpg] https://deb.mariadb.org/10.11/ubuntu $(lsb_release -cs) main" \
# | tee /etc/apt/sources.list.d/mariadb.list
echo "deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/mariadb.gpg] https://mirror.kumi.systems/mariadb/repo/10.11/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mariadb.list
# Adding mongodb repositories
wget -qO- https://pgp.mongodb.com/server-7.0.asc | sudo gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-server-7.0.gpg >/dev/null
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" \
| sudo tee -a /etc/apt/sources.list.d/mongodb-org-7.0.list
# Mongo is not officially supported on Ubuntu 24.04, so install it from jammy
# Install Kafka
sudo apt install -y default-jre
curl https://dlcdn.apache.org/kafka/3.8.0/kafka_2.13-3.8.0.tgz -o kafka.tgz
sudo mkdir -p /etc/kafka
sudo tar xf kafka.tgz --directory=/etc/kafka
sudo cp -r /etc/kafka/kafka_2.13-3.8.0/* /etc/kafka/
sudo rm -rf /etc/kafka/kafka_2.13-3.8.0
ls -lha /etc/kafka
- name: Install common deps
run: |
sudo apt update
sudo apt install --allow-downgrades -y clickhouse-common-static redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ')
- name: Install postgres 15
if: matrix.os == 'ubuntu-22.04'
run: |
# GH Ubuntu image has libpq version 15+ from pg's repo that is API incompatible with postgresql-14.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7FCC7D46ACCC4CF8
echo "deb https://apt-archive.postgresql.org/pub/repos/apt jammy-pgdg-archive main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt install -y postgresql-15 postgresql-client-15 postgresql-server-dev-15
- name: Install g++-8
if: matrix.info == 'g++-8 + debug'
run: |
sudo apt install --allow-downgrades -y g++-8
- name: Install RabbitMQ packages
run: |
./scripts/rabbitmq/ubuntu_install_rabbitmq_server.sh
- name: Setup ccache
run: |
ccache -M 2.0GB
ccache -s
- name: Run cmake
run: |
mkdir build_debug
cd build_debug
cmake ${{matrix.cmake-flags}} ..
- name: Run clang-tidy
if: matrix.info == 'clang-14 + debug + sanitize addr+ub'
run: |
[[ -z "${GITHUB_BASE_REF}" ]] && BRANCH_VAR=HEAD~1 || BRANCH_VAR=origin/${GITHUB_BASE_REF}
echo "${BRANCH_VAR}"
echo "$(git diff --name-only ${BRANCH_VAR})"
EXCLUDE_PATTERNS="-e '.pb.cc' -e '.pb.cpp' -e 'benchmark.cpp' -e '/pq-extra/' -e '/tools/' -e 'third_party' "
LIST_CHECK_FILES=$(git diff --name-only ${BRANCH_VAR} | grep --color=never '.cpp' | grep -v ${EXCLUDE_PATTERNS} | tr '\n' ' ')
if [[ -n ${LIST_CHECK_FILES} ]]
then
sudo apt install -y clang-tidy-14
curl -o tools/run-clang-tidy https://raw.githubusercontent.com/llvm-mirror/clang-tools-extra/release_90/clang-tidy/tool/run-clang-tidy.py
python3 ./tools/run-clang-tidy -clang-tidy-binary clang-tidy-14 -p build_debug -q -j$(nproc) ${LIST_CHECK_FILES}
else
echo "Nothing check in clang-tidy"
fi
- name: Compile
run: |
pwd
cd build_debug
cmake --build . -j $(nproc)
- name: Run tests (universal)
run: |
echo "UBSAN_OPTIONS=${UBSAN_OPTIONS} ASAN_OPTIONS=${ASAN_OPTIONS}"
cd build_debug
./universal/userver-universal-unittest ${{matrix.tests-flags}}
- name: Run tests (core)
run: |
cd build_debug
./core/userver-core-unittest ${{matrix.tests-flags}}
- name: Run tests (kafka)
run: |
cd build_debug
mkdir kafka || :
cd kafka
ctest -V
- name: Run tests (clickhouse)
run: |
cd build_debug
mkdir clickhouse || :
cd clickhouse
ctest -V
- name: Run tests (rabbitmq)
run: |
cd build_debug
mkdir rabbitmq || :
cd rabbitmq
ctest -V
- name: Run tests (postgresql)
run: |
cd build_debug
mkdir postgresql || :
cd postgresql
ctest -V
- name: Run tests (redis)
run: |
cd build_debug/redis/
ctest -V
- name: Run tests (mongo)
# libbson unnecessarily overaligns structures and GCC-9 does not support overaligned new
if: matrix.info != 'g++-9 + debug + sanitize addr+ub'
run: |
sudo apt install mongodb-mongosh
cd build_debug
mkdir mongo || :
cd mongo
if [ -f ./userver-mongo-unittest ]; then ./userver-mongo-unittest ; fi
# Mongo is not available on Ubuntu 22.04 from default repos
if [ "${{matrix.os}}" != "ubuntu-22.04" ]; then ctest -V -R userver-mongo-mongotest ; fi
- name: Run tests (gRPC)
if: matrix.os != 'ubuntu-24.04'
run: |
cd build_debug
mkdir grpc || :
cd grpc
ulimit -n 4096 && ctest -V
- name: Run tests (mysql)
# MySQL benchmarks do not work on new Ubuntu
if: matrix.os != 'ubuntu-24.04'
run: |
sudo apt install mariadb-server
cd build_debug
mkdir mysql || :
cd mysql
ctest -V