forked from monero-project/monero
-
Notifications
You must be signed in to change notification settings - Fork 116
/
.drone.jsonnet
439 lines (412 loc) · 17.1 KB
/
.drone.jsonnet
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
local default_deps_nocxx = [
'libboost-program-options-dev',
'libboost-serialization-dev',
'libboost-thread-dev',
'libcurl4-openssl-dev',
'libevent-dev',
'libgtest-dev',
'libhidapi-dev',
'libreadline-dev',
'libsodium-dev',
'libsqlite3-dev',
'libssl-dev',
'libsystemd-dev',
'libunbound-dev',
'libunwind8-dev',
'libusb-1.0-0-dev',
'nettle-dev',
'pkg-config',
'python3',
'qttools5-dev',
];
local default_deps = ['g++'] + default_deps_nocxx; // g++ sometimes needs replacement
local gtest_filter = '-AddressFromURL.Failure:DNSResolver.DNSSEC*';
local docker_base = 'registry.oxen.rocks/';
local submodules_commands = ['git fetch --tags', 'git submodule update --init --recursive --depth=1 --jobs=4'];
local submodules = {
name: 'submodules',
image: 'drone/git',
commands: submodules_commands,
};
local apt_get_quiet = 'apt-get -o=Dpkg::Use-Pty=0 -q';
local cmake_options(opts) = std.join(' ', [' -D' + o + '=' + (if opts[o] then 'ON' else 'OFF') for o in std.objectFields(opts)]) + ' ';
// Regular build on a debian-like system:
local debian_pipeline(name,
image,
arch='amd64',
deps=default_deps,
build_type='Release',
lto=false,
werror=false, // FIXME
build_tests=true,
build_everything=false,
test_oxend=true, // Simple oxend offline startup test
run_tests=false, // Runs full test suite
cmake_extra='',
extra_cmds=[],
extra_steps=[],
jobs=6,
kitware_cmake_distro='',
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
steps: [
submodules,
{
name: 'build',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, GTEST_FILTER: gtest_filter },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
] + (
if kitware_cmake_distro != '' then
[
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y curl ca-certificates',
'curl https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor - >/etc/apt/trusted.gpg.d/kitware.gpg',
'echo deb https://apt.kitware.com/ubuntu/ ' + kitware_cmake_distro + ' main >/etc/apt/sources.list.d/kitware.list',
apt_get_quiet + ' update',
] else []
) + [
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends cmake git ninja-build ccache '
+ (if test_oxend then 'gdb ' else '') + std.join(' ', deps),
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE=' + build_type + ' ' +
'-DLOCAL_MIRROR=https://builds.lokinet.dev/deps '
+ cmake_options({ USE_LTO: lto, WARNINGS_AS_ERRORS: werror, BUILD_TESTS: build_tests || run_tests, BUILD_EVERYTHING: build_everything })
+ cmake_extra,
] + (
if arch == 'arm64' && jobs > 1 then
// The wallet code is too bloated to be compiled at -j2 with only 4GB ram, so do
// the huge bloated jobs at -j1 and the rest at -j2
['ninja -j1 rpc wallet -v', 'ninja -j2 daemon -v', 'ninja -j1 wallet_rpc_server -v', 'ninja -j2 -v']
else
['ninja -j' + jobs + ' -v']
) + (
if test_oxend then [
'(sleep 3; echo "status\ndiff\nexit") | TERM=xterm ../utils/build_scripts/drone-gdb.sh ./bin/oxend --offline --data-dir=startuptest',
] else []
) + (
if run_tests then [
'mkdir -v -p $$HOME/.oxen',
'GTEST_COLOR=1 ctest --output-on-failure -j' + jobs,
] else []
) + extra_cmds,
},
] + extra_steps,
};
local clang(version, lto=false) = debian_pipeline(
'Debian sid/clang-' + version + ' (amd64)',
docker_base + 'debian-sid-clang',
deps=['clang-' + version] + default_deps_nocxx,
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version + ' -DCMAKE_CXX_COMPILER=clang++-' + version + ' ',
lto=lto,
build_everything=true
);
local distro_deb_suffix = {
unstable: '',
sid: '',
forky: '~deb14',
trixie: '~deb13',
bookworm: '~deb12',
bullseye: '~deb11',
oracular: '~ubuntu2410',
noble: '~ubuntu2404',
jammy: '~ubuntu2204',
focal: '~ubuntu2004',
};
local distro_fmtspdsecp(distro) = !(distro == 'bullseye' || distro == 'jammy' || distro == 'focal');
local distro_build_env(distro, deb_suffix_base) = {
DEBIAN_CODENAME: distro,
DEBIAN_SUFFIX: deb_suffix_base + distro_deb_suffix[distro],
} + (if distro_fmtspdsecp(distro) then { WITH_FMT: 1, WITH_SPD: 1, WITH_SECP: 1 } else {}) + (
if distro == 'focal' then { OXEN_APPEND_DEPS: ', g++-10', OXEN_DEB_CMAKE_EXTRA: '-DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DC_SUPPORTS__WCONDITIONAL_UNINITIALIZED=FALSE -DC_SUPPORTS__WRESERVED_IDENTIFIER=FALSE' } else {}
);
local snapshot_deb(distro, deb_suffix_base='-1', buildarch='amd64', debarch='amd64', jobs=6, repo_suffix='/staging') = {
kind: 'pipeline',
type: 'docker',
name: distro + ' snapshot deb (' + debarch + ')',
platform: { arch: buildarch },
steps: [
submodules,
{
name: 'build',
image: 'registry.oxen.rocks/' +
(if std.startsWith(distro_deb_suffix[distro], '~ubuntu') then 'ubuntu' else 'debian') +
'-' + distro + '-builder',
environment: {
SSH_KEY: { from_secret: 'SSH_KEY' },
} + distro_build_env(distro, deb_suffix_base),
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
'cp contrib/deb.oxen.io.gpg /etc/apt/trusted.gpg.d/deb.oxen.io.gpg',
'echo deb http://deb.oxen.io' + repo_suffix + ' ' + distro + ' main >/etc/apt/sources.list.d/loki.list',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git-buildpackage devscripts equivs g++ ccache openssh-client',
'eatmydata dpkg-reconfigure ccache',
'./debian/setup-build.sh',
'cd debian',
'eatmydata mk-build-deps -i -r --tool="' + apt_get_quiet + ' -o Debug::pkgProblemResolver=yes --no-install-recommends -y" control',
'cd ..',
'eatmydata debuild --preserve-envvar=CCACHE_* --preserve-envvar=OXEN_DEB_CMAKE_EXTRA -us -uc -b -j' + jobs,
'./debian/ci-upload.sh ' + distro + ' ' + debarch,
],
},
],
};
// Macos build
local mac_builder(name,
build_type='Release',
lto=false,
werror=false, // FIXME
build_tests=true,
run_tests=false,
cmake_extra='',
extra_cmds=[],
extra_steps=[],
jobs=6,
allow_fail=false) = {
kind: 'pipeline',
type: 'exec',
name: name,
platform: { os: 'darwin', arch: 'amd64' },
steps: [
{ name: 'submodules', commands: submodules_commands },
{
name: 'build',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, GTEST_FILTER: gtest_filter },
commands: [
// If you don't do this then the C compiler doesn't have an include path containing
// basic system headers. WTF apple:
'export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"',
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fcolor-diagnostics -DCMAKE_BUILD_TYPE=' + build_type + ' ' +
'-DOXEN_LOGGING_FORCE_SUBMODULES=ON ' +
'-DLOCAL_MIRROR=https://builds.lokinet.dev/deps -DUSE_LTO=' + (if lto then 'ON ' else 'OFF ') +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
(if build_tests || run_tests then '-DBUILD_TESTS=ON ' else '') +
cmake_extra,
'ninja -j' + jobs + ' -v',
] + (
if run_tests then [
'mkdir -v -p $$HOME/.oxen',
'GTEST_COLOR=1 ctest --output-on-failure -j' + jobs,
] else []
) + extra_cmds,
},
] + extra_steps,
};
local static_check_and_upload = [
'../utils/build_scripts/drone-check-static-libs.sh',
'ninja strip_binaries',
'ninja create_tarxz',
'../utils/build_scripts/drone-static-upload.sh',
];
local static_build_deps = [
'autoconf',
'automake',
'file',
'gperf',
'libtool',
'make',
'openssh-client',
'patch',
'pkg-config',
'qttools5-dev',
];
local android_build_steps(android_abi, android_platform=21, jobs=6, cmake_extra='') = [
'mkdir build-' + android_abi,
'cd build-' + android_abi,
'cmake .. -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_C_FLAGS=-fdiagnostics-color=always ' +
'-DCMAKE_BUILD_TYPE=Release ' +
'-DCMAKE_TOOLCHAIN_FILE=/usr/lib/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake ' +
'-DANDROID_PLATFORM=' + android_platform + ' -DANDROID_ABI=' + android_abi + ' ' +
cmake_options({ MONERO_SLOW_HASH: true, WARNINGS_AS_ERRORS: false, BUILD_TESTS: false }) +
'-DLOCAL_MIRROR=https://builds.lokinet.dev/deps ' +
'-DBUILD_STATIC_DEPS=ON -DSTATIC=ON -G Ninja ' + cmake_extra,
'ninja -j' + jobs + ' -v wallet_merged',
'cd ..',
];
local gui_wallet_step(image, wine=false) = {
name: 'GUI Wallet (dev)',
platform: { arch: 'amd64' },
image: image,
pull: 'always',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: (if wine then ['dpkg --add-architecture i386'] else []) + [
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends git ssh curl ca-certificates binutils make' + (if wine then ' wine32 wine sed' else ''),
'curl -sSL https://deb.nodesource.com/setup_14.x | bash -',
'eatmydata ' + apt_get_quiet + ' update',
'eatmydata ' + apt_get_quiet + ' install -y nodejs',
'git clone https://github.com/loki-project/loki-electron-gui-wallet.git',
'cp -v build/bin/oxend' + (if wine then '.exe' else '') + ' loki-electron-gui-wallet/bin',
'cp -v build/bin/oxen-wallet-rpc' + (if wine then '.exe' else '') + ' loki-electron-gui-wallet/bin',
'cd loki-electron-gui-wallet',
'eatmydata npm install',
'sed -i -e \'s/^\\\\( *"version": ".*\\\\)",/\\\\\\\\1-${DRONE_COMMIT_SHA:0:8}",/\' package.json',
] + (if wine then ['sed -i -e \'s/^\\\\( *"build": "quasar.*\\\\)",/\\\\\\\\1 --target=win",/\' package.json'] else []) + [
'eatmydata npm run build',
'../utils/build_scripts/drone-wallet-upload.sh',
],
};
local gui_wallet_step_darwin = {
name: 'GUI Wallet (dev)',
platform: { os: 'darwin', arch: 'amd64' },
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, CSC_IDENTITY_AUTO_DISCOVERY: 'false' },
commands: [
'git clone https://github.com/loki-project/loki-electron-gui-wallet.git',
'cp -v build/bin/{oxend,oxen-wallet-rpc} loki-electron-gui-wallet/bin',
'cd loki-electron-gui-wallet',
'sed -i -e \'s/^\\\\( *"version": ".*\\\\)",/\\\\1-${DRONE_COMMIT_SHA:0:8}",/\' package.json',
'npm install',
'npm run build',
'../utils/build_scripts/drone-wallet-upload.sh',
],
};
[
{
name: 'lint check',
kind: 'pipeline',
type: 'docker',
steps: [{
name: 'build',
image: docker_base + 'lint',
pull: 'always',
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git clang-format-16 jsonnet',
'./contrib/drone-format-verify.sh',
],
}],
},
// Various debian builds
debian_pipeline('Debian sid (w/ tests) (amd64)', docker_base + 'debian-sid', lto=true, run_tests=true, build_everything=true),
debian_pipeline('Debian sid Debug (amd64)', docker_base + 'debian-sid', build_type='Debug', build_everything=true, cmake_extra='-DBUILD_DEBUG_UTILS=ON'),
clang(18),
debian_pipeline('Debian stable (i386)', docker_base + 'debian-stable/i386', cmake_extra='-DDOWNLOAD_SODIUM=ON -DARCH_ID=i386 -DARCH=i686'),
debian_pipeline('Debian buster (amd64)', docker_base + 'debian-bullseye'),
debian_pipeline('Ubuntu LTS (amd64)', docker_base + 'ubuntu-lts'),
debian_pipeline('Ubuntu latest (amd64)', docker_base + 'ubuntu-rolling'),
// ARM builds (ARM64 and armhf)
debian_pipeline('Debian sid (ARM64)', docker_base + 'debian-sid', arch='arm64', build_tests=false),
debian_pipeline('Debian stable (armhf)',
docker_base + 'debian-stable/arm32v7',
arch='arm64',
build_tests=false,
cmake_extra='-DARCH_ID=armhf'),
// Static build (on bionic) which gets uploaded to builds.lokinet.dev:
debian_pipeline(
'Static (focal amd64)',
docker_base + 'ubuntu-focal',
deps=['g++-10'] + static_build_deps,
cmake_extra='-DBUILD_STATIC_DEPS=ON -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DARCH=x86-64',
build_tests=false,
lto=true,
extra_cmds=static_check_and_upload,
),
snapshot_deb('sid'),
snapshot_deb('trixie'),
snapshot_deb('bookworm'),
snapshot_deb('bullseye'),
snapshot_deb('noble'),
snapshot_deb('jammy'),
snapshot_deb('focal'),
// Static mingw build (on focal) which gets uploaded to builds.lokinet.dev:
debian_pipeline(
'Static (win64)',
docker_base + 'debian-win32-cross',
deps=['g++', 'g++-mingw-w64-x86-64'] + static_build_deps,
cmake_extra='-DCMAKE_TOOLCHAIN_FILE=../cmake/64-bit-toolchain.cmake -DBUILD_STATIC_DEPS=ON -DARCH=x86-64',
build_tests=false,
lto=false,
test_oxend=false,
extra_cmds=[
'ninja strip_binaries',
'ninja create_zip',
'../utils/build_scripts/drone-static-upload.sh',
],
/*extra_steps=[gui_wallet_step('debian:stable', wine=true)]*/
),
// Macos builds:
mac_builder('macOS (Static)',
cmake_extra='-DBUILD_STATIC_DEPS=ON -DARCH=core2 -DARCH_ID=amd64',
build_tests=false,
lto=true,
extra_cmds=static_check_and_upload,/*extra_steps=[gui_wallet_step_darwin]*/),
mac_builder('macOS (Release)', run_tests=true),
mac_builder('macOS (Debug)', build_type='Debug', cmake_extra='-DBUILD_DEBUG_UTILS=ON'),
// Android builds; we do them all in one image because the android NDK is huge
{
name: 'Android wallet_api',
kind: 'pipeline',
type: 'docker',
platform: { arch: 'amd64' },
steps: [
submodules,
{
name: 'build',
image: docker_base + 'android',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: [
'echo deb http://deb.debian.org/debian sid contrib >/etc/apt/sources.list.d/sid-contrib.list',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends '
+ 'cmake g++ git ninja-build ccache tar xz-utils google-android-ndk-installer '
+ std.join(' ', static_build_deps),
]
+ android_build_steps('armeabi-v7a', cmake_extra='-DARCH=armv7-a -DARCH_ID=arm32')
+ android_build_steps('arm64-v8a', cmake_extra='-DARCH=armv8-a -DARCH_ID=arm64')
+ android_build_steps('x86_64', cmake_extra='-DARCH="x86-64 -msse4.2 -mpopcnt" -DARCH_ID=x86-64')
+ [
'./utils/build_scripts/drone-android-static-upload.sh armeabi-v7a arm64-v8a x86_64',
],
},
],
},
// iOS build
{
name: 'iOS wallet_api',
kind: 'pipeline',
type: 'exec',
platform: { os: 'darwin', arch: 'amd64' },
steps: [{
name: 'build',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: submodules_commands + [
'mkdir -p build/{arm64,sim64}',
'cd build/arm64',
'cmake ../.. -G Ninja ' +
'-DCMAKE_TOOLCHAIN_FILE=../../cmake/ios.toolchain.cmake -DPLATFORM=OS -DDEPLOYMENT_TARGET=13 -DENABLE_VISIBILITY=ON -DENABLE_BITCODE=OFF ' +
'-DSTATIC=ON -DBUILD_STATIC_DEPS=ON -DUSE_LTO=OFF -DCMAKE_BUILD_TYPE=Release ' +
'-DRANDOMX_ENABLE_JIT=OFF -DCMAKE_CXX_FLAGS=-fcolor-diagnostics',
'ninja -j6 -v wallet_merged',
'cd ../sim64',
'cmake ../.. -G Ninja ' +
'-DCMAKE_TOOLCHAIN_FILE=../../cmake/ios.toolchain.cmake -DPLATFORM=SIMULATOR64 -DDEPLOYMENT_TARGET=13 -DENABLE_VISIBILITY=ON -DENABLE_BITCODE=OFF ' +
'-DSTATIC=ON -DBUILD_STATIC_DEPS=ON -DUSE_LTO=OFF -DCMAKE_BUILD_TYPE=Release ' +
'-DRANDOMX_ENABLE_JIT=OFF -DCMAKE_CXX_FLAGS=-fcolor-diagnostics',
'ninja -j6 -v wallet_merged',
'cd ../..',
'./utils/build_scripts/drone-ios-static-upload.sh',
],
}],
},
]