|
| 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 |
0 commit comments