Skip to content

Commit 0246e8d

Browse files
authored
Merge pull request sorintlab#710 from sgotti/agola
Use agola CI/CD
2 parents 5f130b4 + f7646f7 commit 0246e8d

File tree

3 files changed

+109
-8
lines changed

3 files changed

+109
-8
lines changed

.agola/config.jsonnet

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
}

build

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ if [ -w ${go_root_dir}/pkg ]; then
4242
fi
4343

4444
for cmd in sentinel proxy; do
45-
echo "Building stolon-${cmd} ..."
45+
echo "Building stolon-${cmd} ..."
4646
CGO_ENABLED=0 go build -installsuffix cgo -ldflags "$LD_FLAGS" -o ${BINDIR}/stolon-${cmd} ${REPO_PATH}/cmd/${cmd}
47-
echo "Done building stolon-${cmd}"
47+
echo "Done building stolon-${cmd}"
4848
done
4949

5050
echo "Building stolonctl ..."
@@ -61,10 +61,10 @@ declare -a DOCKERFILE_PATHS
6161
DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker)
6262
for path in "${DOCKERFILE_PATHS[@]}"
6363
do
64-
rm -rf $path/bin/
65-
mkdir -p $path/bin/
66-
for cmd in stolon-keeper stolon-sentinel stolon-proxy stolonctl; do
67-
cp ${BINDIR}/${cmd} $path/bin/
68-
done
64+
rm -rf $path/bin/
65+
mkdir -p $path/bin/
66+
for cmd in stolon-keeper stolon-sentinel stolon-proxy stolonctl; do
67+
cp ${BINDIR}/${cmd} $path/bin/
68+
done
6969
done
7070
echo "Done!"

test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ echo "Checking govet -shadow ..."
6161
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
6262
export PATH=${GOPATH}/bin:${PATH}
6363
shadow_tool=$(which shadow)
64-
vetRes=$(go vet -vettool="${shadow_tool}" ${PACKAGES})
64+
vetRes=$(${shadow_tool} ${PACKAGES})
6565
if [ -n "${vetRes}" ]; then
6666
echo -e "govet checking ${path} failed:\n${vetRes}"
6767
exit 255

0 commit comments

Comments
 (0)