-
Notifications
You must be signed in to change notification settings - Fork 73
/
pipeline.sh
executable file
·121 lines (100 loc) · 3.25 KB
/
pipeline.sh
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
118
119
120
121
#!/bin/bash
set -euo pipefail
# Time to wait for the database to come up in seconds
DB_TIMEOUT=30
cat <<EOF
steps:
- label: ":docker: Build Test Image"
agents:
queue: beta # TODO: dedicated builder queue
plugins:
docker-compose:
build: test
image_repository: "index.docker.io/operable/cog-testing"
config: docker-compose.ci.yml
- wait
EOF
########################################################################
# Self-contained Tests
for TEST in unit integration
do
cat <<EOF
- command: ./scripts/wait-for-it.sh postgres:5432 -s -t ${DB_TIMEOUT} -- make test-${TEST}
label: ":cogops: ${TEST}"
agents:
queue: beta
plugins:
docker-compose:
run: test
config: docker-compose.ci.yml
EOF
done
########################################################################
# Live Chat Provider Tests
for PLATFORM in slack hipchat
do
cat <<EOF
- command: ./scripts/wait-for-it.sh postgres:5432 -s -t ${DB_TIMEOUT} -- make test-${PLATFORM}
label: ":${PLATFORM}: Integration"
agents:
queue: beta
plugins:
docker-compose:
run: test
config: docker-compose.ci.yml
concurrency_group: "cog_${PLATFORM}_integration"
concurrency: 1
EOF
done
########################################################################
# "Real" Image build
#
# The docker-compose image above is for a testing build of Cog, not
# for the real images we ultimately distribute. In the future, we may
# converge the two, but for now, we'll build the real images
# separately. This'll allow us to provide up-to-date images if we so
# choose, as well as easily provide images to dependent pipelines
# (like the cogctl we trigger below).
#
# When / if Buildkite gets a plain Docker plugin (as opposed to the
# docker-compose one), we might be able to replace some of this custom
# code.)
# Not sure if both build number and commit SHA is overkill here or
# not. Both are probably useful right now; build number can help us
# (Operable) track things down, but commit provides extra clarity (and
# can be meaningfully used by non-Operable folks until Buildkite opens
# up builds for public view).
#
#
# For now, we'll push this to `cog-testing`, instead of `cog`, even
# though it's a "real" image. Once we start actually promoting
# official images from CI, though, we can send it to `cog`.
COG_IMAGE="operable/cog-testing:ci-build-${BUILDKITE_BUILD_NUMBER}-${BUILDKITE_COMMIT::8}"
cat <<EOF
- wait
- command: .buildkite/scripts/build_and_push_docker_image.sh $COG_IMAGE
label: ":docker: Build Real Image"
agents:
queue: beta # TODO future builder queue
- wait
EOF
########################################################################
# Triggered Builds
# If there's a branch in cogctl with the same name as the branch we're
# building here in Cog, use that branch. Otherwise, build on master.
if git ls-remote --exit-code --heads https://github.com/operable/cogctl refs/heads/${BUILDKITE_BRANCH} > /dev/null 2>&1
then
TRIGGER_BRANCH=${BUILDKITE_BRANCH}
else
TRIGGER_BRANCH='master'
fi
cat <<EOF
- trigger: "cogctl"
label: ":cogops: Triggered cogctl build"
async: true
build:
branch: "${TRIGGER_BRANCH}"
commit: "HEAD"
env:
COG_IMAGE: ${COG_IMAGE}
EOF