-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy path.drone.jsonnet
230 lines (214 loc) · 9.38 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
local default_deps_base = [
'autoconf',
'libboost-program-options-dev',
'libcurl4-openssl-dev',
'libjemalloc-dev',
'libsodium-dev',
'libgnutls28-dev',
'libsqlite3-dev',
'libssl-dev',
'libsystemd-dev',
'make',
'pkg-config',
];
local default_deps_nocxx = ['libsodium-dev'] + default_deps_base; // libsodium-dev needs to be >= 1.0.18
local default_deps = ['g++'] + default_deps_nocxx; // g++ sometimes needs replacement
local docker_base = 'registry.oxen.rocks/lokinet-ci-';
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 kitware_repo(distro) = [
'eatmydata ' + apt_get_quiet + ' install -y curl ca-certificates',
'curl -sSL https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - >/usr/share/keyrings/kitware-archive-keyring.gpg',
'echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ' + distro + ' main" >/etc/apt/sources.list.d/kitware.list',
'eatmydata ' + apt_get_quiet + ' update',
];
local local_gnutls(jobs=6, prefix='/usr/local') = [
apt_get_quiet + ' install -y curl ca-certificates',
'curl -sSL https://ftp.gnu.org/gnu/nettle/nettle-3.9.1.tar.gz | tar xfz -',
'curl -sSL https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-3.8.0.tar.xz | tar xfJ -',
'export PKG_CONFIG_PATH=' + prefix + '/lib/pkgconfig:' + prefix + '/lib64/pkgconfig',
'export LD_LIBRARY_PATH=' + prefix + '/lib:' + prefix + '/lib64',
'cd nettle-3.9.1',
'./configure --prefix=' + prefix + ' CC="ccache gcc"',
'make -j' + jobs,
'make install',
'cd ..',
'cd gnutls-3.8.0',
'./configure --prefix=' + prefix + ' --with-included-libtasn1 --with-included-unistring --without-p11-kit --disable-libdane --disable-cxx --without-tpm --without-tpm2 CC="ccache gcc"',
'make -j' + jobs,
'make install',
'cd ..',
];
local debian_backports(distro, pkgs) = [
'echo "deb http://deb.debian.org/debian ' + distro + '-backports main" >/etc/apt/sources.list.d/' + distro + '-backports.list',
'eatmydata ' + apt_get_quiet + ' update',
'eatmydata ' + apt_get_quiet + ' install -y ' + std.join(' ', std.map(function(x) x + '/' + distro + '-backports', pkgs)),
];
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,
extra_setup=[],
build_type='Release',
lto=false,
werror=true,
build_tests=true,
run_tests=true, // Runs full test suite
test_oxen_storage=true, // Makes sure oxen-storage --version runs
cmake_extra='',
extra_cmds=[],
extra_steps=[],
jobs=6,
oxen_repo=false,
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' } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
] + (
if oxen_repo then [
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y lsb-release',
'cp contrib/deb.oxen.io.gpg /etc/apt/trusted.gpg.d',
'echo deb http://deb.oxen.io $$(lsb_release -sc) main >/etc/apt/sources.list.d/oxen.list',
'eatmydata ' + apt_get_quiet + ' update',
] else []
) + extra_setup + [
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install -y --no-install-recommends cmake git ca-certificates ninja-build ccache '
+ std.join(' ', deps),
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE=' + build_type
+ ' -DLOCAL_MIRROR=https://oxen.rocks/deps -DEXTRA_WARNINGS=ON '
+ cmake_options({ USE_LTO: lto, WARNINGS_AS_ERRORS: werror, BUILD_TESTS: build_tests || run_tests })
+ cmake_extra,
'ninja -j' + jobs + ' -v',
] +
(if test_oxen_storage then ['./oxen-storage --version'] else []) +
(if run_tests then ['./unit_test/Test'] 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
);
// Macos build
local mac_builder(name,
build_type='Release',
lto=false,
werror=true,
build_tests=true,
run_tests=true,
test_oxen_storage=true, // Makes sure oxen-storage --version runs
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' } },
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
+ ' -DLOCAL_MIRROR=https://oxen.rocks/deps -DEXTRA_WARNINGS=ON '
+ cmake_options({ USE_LTO: lto, WARNINGS_AS_ERRORS: werror, BUILD_TESTS: build_tests || run_tests })
+ cmake_extra,
'ninja -j' + jobs + ' -v',
] +
(if test_oxen_storage then ['./oxen-storage --version'] else []) +
(if run_tests then ['./unit_test/Test'] else []) +
extra_cmds,
},
] + extra_steps,
};
local static_check_and_upload = [
'../contrib/drone-check-static-libs.sh',
'ninja strip',
'ninja create_tarxz',
'../contrib/drone-static-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-15 jsonnet',
'./contrib/drone-format-verify.sh',
],
}],
},
// Various debian builds
debian_pipeline('Debian (amd64)', docker_base + 'debian-sid', lto=true),
debian_pipeline('Debian Debug (amd64)', docker_base + 'debian-sid', build_type='Debug'),
clang(17, lto=true),
debian_pipeline('Debian stable (i386)', docker_base + 'debian-stable/i386', werror=false),
debian_pipeline('Ubuntu LTS (amd64)', docker_base + 'ubuntu-lts'),
debian_pipeline('Ubuntu latest (amd64)', docker_base + 'ubuntu-rolling'),
debian_pipeline('Debian 11 bullseye (amd64)',
docker_base + 'debian-bullseye',
deps=default_deps_base,
extra_setup=local_gnutls() + debian_backports('bullseye', ['cmake']),
cmake_extra='-DDOWNLOAD_SODIUM=ON'),
// ARM builds (ARM64 and armhf)
debian_pipeline('Debian sid (ARM64)', docker_base + 'debian-sid', arch='arm64'),
debian_pipeline('Debian stable (armhf)', docker_base + 'debian-stable/arm32v7', arch='arm64', werror=false),
// Static build (on bionic) which gets uploaded to oxen.rocks:
debian_pipeline('Static (focal amd64)',
docker_base + 'ubuntu-focal',
extra_setup=kitware_repo('focal'),
deps=['autoconf', 'automake', 'file', 'g++-10', 'libtool', 'make', 'openssh-client', 'patch', 'pkg-config'],
cmake_extra='-DBUILD_STATIC_DEPS=ON -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10',
lto=true,
extra_cmds=static_check_and_upload),
// Macos builds:
mac_builder('macOS (Static)',
cmake_extra='-DBUILD_STATIC_DEPS=ON',
lto=true,
extra_cmds=static_check_and_upload),
mac_builder('macOS (Release)'),
mac_builder('macOS (Debug)', build_type='Debug'),
]