-
Notifications
You must be signed in to change notification settings - Fork 19
/
circle.yml
117 lines (108 loc) · 3.55 KB
/
circle.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
version: 2
references:
docker_build_image: &docker_build_image
working_directory: /go/src/github.com/gocardless/stolon-pgbouncer
docker:
- image: &image gocardless/stolon-pgbouncer-circleci:2020050701
docker_postgres_build_image: &docker_postgres_build_image
working_directory: /go/src/github.com/gocardless/stolon-pgbouncer
docker:
- image: *image
environment:
PGHOST: "127.0.0.1"
PGUSER: "postgres"
- image: postgres:11.2
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: ""
jobs:
build:
<<: *docker_build_image
steps:
- checkout
- run:
name: Build test binaries
command: make linux
- persist_to_workspace:
root: /go/src/github.com/gocardless/stolon-pgbouncer
paths:
- bin/stolon-pgbouncer.linux_amd64
- bin/stolon-pgbouncer-acceptance.linux_amd64
# To understand this test flow, it's important to be aware of the following
# constraints:
#
# - Our Circle image needs to run as root to install system deps
# - GOPATH and GOROOT in the image are root owned, as is Ginkgo
# - PgBouncer fatals whenever running as uid 0
#
# In an attempt to satisfy these restrictions, we first build the ginkgo test
# suites using the root user then invoke them as postgres. There are other
# ways to achieve this but this seemed the least fiddly.
unit-integration:
<<: *docker_postgres_build_image
steps:
- checkout
- run:
name: Compile ginkgo test suites
command: ginkgo build -r -race .
- run:
name: Run unit tests
command: find pkg -type f -name '*.test' -printf "%h %f\n" | xargs -n2 sh -c 'cd $0 && su postgres -c ./$1'
acceptance:
machine:
image: ubuntu-2004:202201-02
working_directory: /home/circleci/stolon-pgbouncer
steps:
- checkout
- attach_workspace:
at: /home/circleci/stolon-pgbouncer
- run:
name: Install an up-to-date Docker Compose
command: |
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
- run:
name: Start docker-compose cluster
command: docker-compose up -d etcd-store sentinel pgbouncer keeper0 keeper1 keeper2
- run:
name: Tail logs from docker-compose
command: docker-compose logs -f
background: true
- run:
name: Run acceptance tests
command: bin/stolon-pgbouncer-acceptance.linux_amd64
release:
<<: *docker_build_image
steps:
- setup_remote_docker
- run: docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
- checkout
- run:
name: Release
command: |
CURRENT_VERSION="v$(cat VERSION)"
if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then
echo "Version ${CURRENT_VERSION} is already released"
exit 0
fi
git tag "${CURRENT_VERSION}"
git push --tags
goreleaser --rm-dist
workflows:
version: 2
build-integration:
jobs:
- unit-integration
- build
- acceptance:
requires:
- build
- release:
requires:
- acceptance
- unit-integration
filters:
branches: {only: master}