|
| 1 | +local go_runtime(version, arch) = { |
| 2 | + type: 'pod', |
| 3 | + arch: arch, |
| 4 | + containers: [ |
| 5 | + { |
| 6 | + image: 'golang:' + version + '-buster', |
| 7 | + }, |
| 8 | + ], |
| 9 | +}; |
| 10 | + |
| 11 | +local ci_runtime(pgversion, arch) = { |
| 12 | + type: 'pod', |
| 13 | + arch: arch, |
| 14 | + containers: [ |
| 15 | + { |
| 16 | + image: 'sorintlab/stolon-ci-image:v0.1.0-pg' + pgversion, |
| 17 | + volumes: [ |
| 18 | + { |
| 19 | + path: '/stolontemp', |
| 20 | + tmpfs: {}, |
| 21 | + }, |
| 22 | + ], |
| 23 | + }, |
| 24 | + ], |
| 25 | +}; |
| 26 | + |
| 27 | +local task_build_go(version, arch) = { |
| 28 | + name: 'build go ' + version + ' ' + arch, |
| 29 | + runtime: go_runtime(version, arch), |
| 30 | + environment: { |
| 31 | + GO111MODULE: 'on', |
| 32 | + }, |
| 33 | + steps: [ |
| 34 | + { type: 'clone' }, |
| 35 | + { type: 'restore_cache', keys: ['cache-sum-{{ md5sum "go.sum" }}', 'cache-date-'], dest_dir: '/go/pkg/mod/cache' }, |
| 36 | + { type: 'run', command: './build' }, |
| 37 | + { type: 'run', command: './test' }, |
| 38 | + { type: 'run', name: 'build integration tests binary', command: 'go test -c ./tests/integration/ -o bin/integration-tests' }, |
| 39 | + { type: 'save_cache', key: 'cache-sum-{{ md5sum "go.sum" }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] }, |
| 40 | + { type: 'save_cache', key: 'cache-date-{{ year }}-{{ month }}-{{ day }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] }, |
| 41 | + { type: 'save_to_workspace', contents: [{ source_dir: './bin', dest_dir: '/bin/', paths: ['*'] }] }, |
| 42 | + ], |
| 43 | +}; |
| 44 | + |
| 45 | +local task_integration_tests(store, pgversion, arch) = { |
| 46 | + name: 'integration tests store: ' + store + ', postgres: ' + pgversion + ', arch: ' + arch, |
| 47 | + runtime: ci_runtime(pgversion, 'amd64'), |
| 48 | + environment: { |
| 49 | + STOLON_TEST_STORE_BACKEND: store, |
| 50 | + POSTGRES_PATH: '/usr/lib/postgresql/' + pgversion, |
| 51 | + }, |
| 52 | + steps: [ |
| 53 | + { type: 'restore_workspace', dest_dir: '.' }, |
| 54 | + { |
| 55 | + type: 'run', |
| 56 | + name: 'test', |
| 57 | + command: ||| |
| 58 | + export TMPDIR=/stolontemp |
| 59 | + export PATH=$POSTGRES_PATH:$PATH |
| 60 | + export BINDIR=${PWD}/bin |
| 61 | + export STKEEPER_BIN=${BINDIR}/stolon-keeper |
| 62 | + export STSENTINEL_BIN=${BINDIR}/stolon-sentinel |
| 63 | + export STPROXY_BIN=${BINDIR}/stolon-proxy |
| 64 | + export STCTL_BIN=${BINDIR}/stolonctl |
| 65 | + export ETCD_BIN="${HOME}/etcd/etcd" |
| 66 | + export CONSUL_BIN="${HOME}/consul" |
| 67 | + INTEGRATION=1 ./bin/integration-tests -test.parallel 2 -test.v |
| 68 | + |||, |
| 69 | + }, |
| 70 | + ], |
| 71 | + depends: [ |
| 72 | + 'build go 1.13 ' + arch, |
| 73 | + ], |
| 74 | +}; |
| 75 | + |
| 76 | +{ |
| 77 | + runs: [ |
| 78 | + { |
| 79 | + name: 'stolon build/test', |
| 80 | + tasks: std.flattenArrays([ |
| 81 | + [ |
| 82 | + task_build_go(version, arch), |
| 83 | + ] |
| 84 | + for version in ['1.12', '1.13'] |
| 85 | + for arch in ['amd64' /*, 'arm64' */] |
| 86 | + ]) + std.flattenArrays([ |
| 87 | + [ |
| 88 | + task_integration_tests(store, pgversion, 'amd64'), |
| 89 | + ] |
| 90 | + for store in ['etcdv2', 'consul'] |
| 91 | + for pgversion in ['11' /*, '12' */] |
| 92 | + ]) + std.flattenArrays([ |
| 93 | + [ |
| 94 | + task_integration_tests(store, pgversion, 'amd64'), |
| 95 | + ] |
| 96 | + for store in ['etcdv3'] |
| 97 | + for pgversion in ['9.5', '9.6', '10', '11' /*, '12' */] |
| 98 | + ]), |
| 99 | + }, |
| 100 | + ], |
| 101 | +} |
0 commit comments