Skip to content

Commit 2146560

Browse files
committed
drone: split builds into pipelines
Use starlark to de-duplicate most of the configuration. Use rust:buster-slim base as there is a problem with rust on alpine currently: rust-lang/rust#40174 Signed-off-by: Joe Groocock <me@frebib.net>
1 parent 8c08946 commit 2146560

2 files changed

Lines changed: 52 additions & 22 deletions

File tree

.drone.star

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmd = 'cargo check'
2+
deps = 'clang make automake libc-dev libclang-dev pkg-config gnupg protobuf-compiler libgmp-dev nettle-dev'
3+
4+
def main(ctx):
5+
return [
6+
cargo('format', cmd='cargo fmt -- --check', deps=None, pre=['rustup component add rustfmt']),
7+
cargo('test', cmd='cargo test'),
8+
cargo('all', '--all --tests', env={'RUSTFLAGS': '-D warnings'}),
9+
cargo('graph', feat='use-protobuf use-tcp use-unix-socket use-graph'),
10+
cargo('blackhole', feat='use-protobuf use-tcp use-unix-socket use-black-hole'),
11+
cargo('randomresp', feat='use-protobuf use-tcp use-unix-socket use-random-response'),
12+
]
13+
14+
15+
# name string, name of the pipeline. must be valid yaml word with no breaks
16+
# args string, arguments for provided cmd
17+
# deps string, list of packages to install with the package manager
18+
# pre list, commands to run after installing packages, before cargo cmd
19+
# feat string, features to use instead of default in cargo cmd
20+
# env dict, environment variables to pass to the container
21+
def cargo(name, args='', cmd=cmd, deps=deps, pre=[], feat=None, env=None):
22+
step = {
23+
"name": "build-%s" % name,
24+
"image": "rust:slim-buster", # Because rust is broken on musl at the moment:
25+
"commands": [], # https://github.com/rust-lang/rust/issues/40174
26+
}
27+
28+
if env:
29+
step['environment'] = env
30+
if deps:
31+
step['commands'].insert(0, 'apt-get -qq update')
32+
step['commands'].insert(1, 'apt-get -qq install %s' % deps)
33+
if pre:
34+
step['commands'] += pre
35+
36+
if feat:
37+
cmd += ' --no-default-features --features="%s"' % feat
38+
if args != '':
39+
cmd += ' ' + args
40+
41+
step['commands'].append(cmd)
42+
43+
return {
44+
"kind": "pipeline",
45+
"name": "cargo-build-%s" % name,
46+
"platform": {
47+
"os": "linux",
48+
},
49+
"steps": [step],
50+
}
51+
52+
# vim: ft=python sw=2

.drone.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)