forked from getsentry/snuba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
120 lines (120 loc) · 3.53 KB
/
cloudbuild.yaml
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
steps:
- name: "gcr.io/kaniko-project/executor:v1.5.1"
id: runtime-image
waitFor: ["-"]
args:
[
"--cache=true",
"--use-new-run",
"--build-arg",
"SOURCE_COMMIT=$COMMIT_SHA",
"--destination=us.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA",
"-f",
"./Dockerfile",
]
timeout: 180s
# Unit tests
- name: "gcr.io/$PROJECT_ID/docker-compose"
id: unit-tests
waitFor:
- runtime-image
args:
- "-f"
- "docker-compose.gcb.yml"
- run
- "--rm"
- snuba-test
env:
- 'SNUBA_SETTINGS=test'
# Clean up after tests
- name: "gcr.io/$PROJECT_ID/docker-compose"
id: unit-tests-cleanup
waitFor:
- unit-tests
args:
- "-f"
- "docker-compose.gcb.yml"
- down
- "--rmi"
- "local"
- "-v"
- "--remove-orphans"
- name: "gcr.io/$PROJECT_ID/docker-compose"
id: get-self-hosted-repo
waitFor:
# We need to wait until unit-tests finish as `pytest` tries
# to run tests under self-hosted repo too
- unit-tests
entrypoint: "bash"
args:
- "-e"
- "-c"
- |
mkdir self-hosted && cd self-hosted
curl -L "https://github.com/getsentry/self-hosted/archive/master.tar.gz" | tar xzf - --strip-components=1
echo '{"version": "3.4", "networks":{"default":{"external":{"name":"cloudbuild"}}}}' > docker-compose.override.yml
- name: "gcr.io/$PROJECT_ID/docker-compose"
id: e2e-test
waitFor:
- runtime-image
- unit-tests-cleanup
- get-self-hosted-repo
entrypoint: "bash"
dir: self-hosted
args:
- "-e"
- "-c"
- |
./install.sh
set +e
./test.sh
test_return=$?
set -e
if [[ $test_return -ne 0 ]]; then
echo "Test failed.";
docker-compose ps;
docker-compose logs;
exit $test_return;
fi
timeout: 900s
- name: "gcr.io/cloud-builders/docker"
id: docker-push
waitFor:
- e2e-test
secretEnv: ["DOCKER_PASSWORD"]
entrypoint: "bash"
args:
- "-e"
- "-c"
- |
# Only push to Docker Hub from master
[ "$BRANCH_NAME" != "master" ] && exit 0
# Need to pull the image first due to Kaniko
docker pull $$SNUBA_IMAGE
echo "$$DOCKER_PASSWORD" | docker login --username=sentrybuilder --password-stdin
docker tag $$SNUBA_IMAGE $$DOCKER_REPO:$SHORT_SHA
docker push $$DOCKER_REPO:$SHORT_SHA
docker tag $$SNUBA_IMAGE $$DOCKER_REPO:$COMMIT_SHA
docker push $$DOCKER_REPO:$COMMIT_SHA
docker tag $$SNUBA_IMAGE $$DOCKER_REPO:nightly
docker push $$DOCKER_REPO:nightly
# This is needed for Freight to find matching builds
images: ['us.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']
timeout: 2640s
options:
# We need more memory for Webpack builds & e2e self-hosted tests
machineType: "E2_HIGHCPU_8"
env:
- "CI=1"
- "SNUBA_IMAGE=us.gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA"
- "DOCKER_REPO=getsentry/snuba"
- "SENTRY_TEST_HOST=http://nginx"
secrets:
- kmsKeyName: projects/sentryio/locations/global/keyRings/service-credentials/cryptoKeys/cloudbuild
secretEnv:
# This is a personal access token for the sentrybuilder account, encrypted using the
# short guide at http://bit.ly/2Pg6uw9
DOCKER_PASSWORD: |
CiQAE8gN7y3OMxn+a1kofmK4Bi8jQZtdRFj2lYYwaZHVeIIBUzMSTQA9tvn8XCv2vqj6u8CHoeSP
TVW9pLvSCorKoeNtOp0eb+6V1yNJW/+JC07DNO1KLbTbodbuza6jKJHU5xeAJ4kGQI78UY5Vu1Gp
QcMK