forked from oxen-io/session-file-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.jsonnet
100 lines (95 loc) · 3.27 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
local docker_base = 'registry.oxen.rocks/lokinet-ci-';
local apt_get_quiet = 'apt-get -o=Dpkg::Use-Pty=0 -q';
local default_deps = [
'python3',
'python3-pytest',
'python3-coloredlogs',
'python3-flask',
'python3-pycryptodome',
'python3-nacl',
'python3-requests',
'python3-session-util',
];
// Regular build on a debian-like system:
local debian_pipeline(name,
image,
arch='amd64',
deps=default_deps,
before_pytest=[],
pytest_opts='',
extra_cmds=[],
services=[],
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
{
name: '🐍 pytest',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
commands: [
'echo "Running 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',
'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',
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y ' + std.join(' ', deps),
'cp fileserver/config.py.sample fileserver/config.py',
] + before_pytest + [
'PYTHONPATH=. python3 -mpytest -vv --color=yes ' + pytest_opts,
]
+ extra_cmds,
},
],
services: services,
};
local debian_pg_pipeline(name, image, pg_tag='bullseye') = debian_pipeline(
name,
image,
deps=default_deps + ['python3-pip', 'postgresql-client'],
services=[
{ name: 'pg', image: 'postgres:bullseye', environment: { POSTGRES_USER: 'ci', POSTGRES_PASSWORD: 'ci' } },
],
before_pytest=[
'pip3 install psycopg psycopg-pool',
'for i in $(seq 0 30); do if pg_isready -d ci -h pg -U ci -t 1; then break; fi; if [ "$i" = 30 ]; then echo "Timeout waiting for postgresql" >&2; exit 1; fi; sleep 1; done',
],
pytest_opts='--pgsql "postgresql://ci:ci@pg/ci"'
);
[
{
name: 'Lint checks',
kind: 'pipeline',
type: 'docker',
platform: { arch: 'amd64' },
steps: [
{
name: 'Formatting',
image: docker_base + 'debian-stable',
commands: [
'echo "Running on ${DRONE_STAGE_MACHINE}"',
apt_get_quiet + ' install -y black',
'black --check --diff --color .',
],
},
{
name: 'Flake8',
image: docker_base + 'debian-stable',
commands: [
'echo "Running on ${DRONE_STAGE_MACHINE}"',
apt_get_quiet + ' install -y flake8',
'flake8 .',
],
},
],
},
debian_pg_pipeline('PostgreSQL 13/bullseye', docker_base + 'debian-stable', pg_tag='13-bullseye'),
]