-
Notifications
You must be signed in to change notification settings - Fork 91
/
cloudbuild.yaml
318 lines (288 loc) · 13.4 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
steps:
# init_deployment_config.py leaves the validated config.json file in workspace/config so it's available for other build steps
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'init_deploy_config'
waitFor: ['-']
script: |
#!/usr/bin/env bash
set -e
# Save absolute config file path to .env file
# that can be accessed by all Cloud Build steps since exported env
# variables do not persist between steps.
realpath "${_CONFIG_FILE}" > /workspace/config_file_full_path.env
echo "Initial configuration ${_CONFIG_FILE}:"
cat "${_CONFIG_FILE}"
python3 src/common/init_deployment_config.py --config-file ${_CONFIG_FILE} \
--sub-validator "src/SAP/SAP_REPORTING" \
--sub-validator "src/SFDC/src" \
--sub-validator "src/marketing/src" \
--sub-validator "src/OracleEBS/src"
echo "Processed configuration:"
cat ${_CONFIG_FILE}
echo -e "\n--------------------------------"
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'k9-pre'
waitFor: ['init_deploy_config']
script: |
#!/usr/bin/env bash
export PYTHONPATH=${PYTHONPATH}:src/:.
declare -a _WORKER_POOL_OPTIONS
if [[ -n "${_WORKER_POOL_NAME}" ]]; then
_WORKER_POOL_OPTIONS+=(--worker-pool-name "${_WORKER_POOL_NAME}")
fi
if [[ -n "${_CLOUD_BUILD_REGION}" ]]; then
_WORKER_POOL_OPTIONS+=(--region "${_CLOUD_BUILD_REGION}")
fi
if [[ -n "${_BUILD_ACCOUNT}" ]]; then
_WORKER_POOL_OPTIONS+=(--build-account "${_BUILD_ACCOUNT}")
fi
python3 src/k9/src/deploy_k9.py \
--config-file "${_CONFIG_FILE}" \
--stage pre \
--logs-bucket "${_GCS_BUCKET}" \
"${_WORKER_POOL_OPTIONS[@]}"
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'sap-test-harness'
waitFor: ['init_deploy_config']
script: |
#!/usr/bin/env bash
set -e
_DEPLOY_SAP_=$(jq -r ."deploySAP" ${_CONFIG_FILE})
_TEST_DATA_=$(jq -r ."testData" ${_CONFIG_FILE})
_SQL_FLAVOUR_=$(jq -r ."SAP.SQLFlavor" ${_CONFIG_FILE})
_SQL_FLAVOUR_UP_=$(echo ${_SQL_FLAVOUR_} | tr '[:lower:]' '[:upper:]')
if [[ ${_NO_TEST_DATA} != "true" && ${_TEST_DATA_} == "true" && ${_DEPLOY_SAP_} == "true" && ${_SQL_FLAVOUR_} != "union" ]]; then
python3 src/common/create_test_harness.py --workload "SAP" --dataset raw${_SQL_FLAVOUR_UP_}
else
echo "==Skipping Test Harness for SAP=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'sfdc-test-harness'
waitFor: ['init_deploy_config']
script: |
#!/usr/bin/env bash
set -e
_DEPLOY_SFDC_=$(jq -r ."deploySFDC" ${_CONFIG_FILE})
_TEST_DATA_=$(jq -r ."testData" ${_CONFIG_FILE})
if [[ ${_NO_TEST_DATA} != "true" && ${_TEST_DATA_} == "true" && ${_DEPLOY_SFDC_} == "true" ]]; then
python3 src/common/create_test_harness.py --workload "SFDC" --dataset "raw"
else
echo "==Skipping Test Harness for SFDC=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'sap-cdc'
waitFor: ['sap-test-harness', 'k9-pre']
script: |
#!/usr/bin/env bash
_DEPLOY_SAP_=$(jq -r ."deploySAP" ${_CONFIG_FILE})
_DEPLOY_CDC_=$(jq -r ."SAP.deployCDC" ${_CONFIG_FILE})
_SQL_FLAVOUR_=$(jq -r ."SAP.SQLFlavor" ${_CONFIG_FILE})
if [[ ${_DEPLOY_SAP_} == "true" && ${_SQL_FLAVOUR_} != "union" && ${_DEPLOY_CDC_} == "true" ]]; then
cp -f ${_CONFIG_FILE} src/SAP/SAP_CDC/config/config.json
gcloud builds submit ./src/SAP/SAP_CDC \
--config=./src/SAP/SAP_CDC/cloudbuild.cdc.yaml \
--substitutions=_GCS_BUCKET="${_GCS_BUCKET}",_WORKER_POOL_NAME="${_WORKER_POOL_NAME}",_CLOUD_BUILD_REGION="${_CLOUD_BUILD_REGION}",_BUILD_ACCOUNT="${_BUILD_ACCOUNT}" \
--region="${_CLOUD_BUILD_REGION}"
else
echo "==Skipping CDC for SAP=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'sap-reporting'
waitFor: ['sap-cdc']
script: |
#!/usr/bin/env bash
_DEPLOY_SAP_=$(jq -r ."deploySAP" ${_CONFIG_FILE})
if [[ "${_DEPLOY_SAP_}" == "true" ]]; then
cp -f "${_CONFIG_FILE}" src/SAP/SAP_REPORTING/config/config.json
gcloud builds submit ./src/SAP/SAP_REPORTING \
--config=./src/SAP/SAP_REPORTING/cloudbuild.reporting.yaml \
--substitutions=_GCS_BUCKET="${_GCS_BUCKET}",_WORKER_POOL_NAME="${_WORKER_POOL_NAME}",_CLOUD_BUILD_REGION="${_CLOUD_BUILD_REGION}",_BUILD_ACCOUNT="${_BUILD_ACCOUNT}" \
--region="${_CLOUD_BUILD_REGION}"
else
echo "==Skipping Reporting for SAP=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'sap-ml-models'
waitFor: ['sap-reporting']
script: |
#!/usr/bin/env bash
_DEPLOY_SAP_ML_MODELS=$(jq -r ."deploySAPMLModels" ${_CONFIG_FILE})
if [[ ${_DEPLOY_SAP_ML_MODELS} == "true" ]]
then
_DEPLOY_SAP_=$(jq -r ."deploySAP" ${_CONFIG_FILE})
_SQL_FLAVOUR_=$(jq -r ."SAP.SQLFlavor" ${_CONFIG_FILE})
_PJID_SRC_=$(jq -r ."projectIdSource" ${_CONFIG_FILE})
_PJID_TGT_=$(jq -r ."projectIdTarget" ${_CONFIG_FILE})
_LOCATION_=$(jq -r ."location" ${_CONFIG_FILE})
_MANDT_=$(jq -r ."SAP.mandt" ${_CONFIG_FILE})
_DS_MODELS_=$(jq -r ."SAP.datasets.ml" ${_CONFIG_FILE})
_DS_REPORTING_=$(jq -r ."SAP.datasets.reporting" ${_CONFIG_FILE})
_DS_RAW_=$(jq -r ."SAP.datasets.raw" ${_CONFIG_FILE})
_DS_CDC_=$(jq -r ."SAP.datasets.cdc" ${_CONFIG_FILE})
if [[ "${_DEPLOY_SAP_}" == "true" && "${_SQL_FLAVOUR_}" != "union" ]]; then
gcloud builds submit ./src/SAP/SAP_ML_MODELS \
--config=./src/SAP/SAP_ML_MODELS/cloudbuild.models.yaml \
--substitutions=_PJID_SRC="${_PJID_SRC_}",_PJID_TGT="${_PJID_TGT_}",_DS_RAW="${_DS_RAW_}",_DS_CDC="${_DS_CDC_}",_DS_REPORTING="${_DS_REPORTING_}",_DS_MODELS="${_DS_MODELS_}",_SQL_FLAVOUR="${_SQL_FLAVOUR_}",_LOCATION="${_LOCATION_}",_MANDT="${_MANDT_}",_GCS_BUCKET="${_GCS_BUCKET}",_WORKER_POOL_NAME="${_WORKER_POOL_NAME}",_CLOUD_BUILD_REGION="${_CLOUD_BUILD_REGION}",_BUILD_ACCOUNT="${_BUILD_ACCOUNT}" --region="${_CLOUD_BUILD_REGION}"
else
echo "==Skipping ML for SAP=="
fi
else
echo "==Skipping ML for SAP=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'sfdc-deploy'
waitFor: ['sfdc-test-harness', 'k9-pre']
script: |
#!/usr/bin/env bash
_DEPLOY_SFDC_="$(jq -r ."deploySFDC" "${_CONFIG_FILE}")"
if [[ "${_DEPLOY_SFDC_}" == "true" ]]; then
cp -f "${_CONFIG_FILE}" src/SFDC/config/config.json
gcloud builds submit ./src/SFDC \
--config=./src/SFDC/cloudbuild.sfdc.yaml \
--substitutions=_GCS_BUCKET="${_GCS_BUCKET}",_WORKER_POOL_NAME="${_WORKER_POOL_NAME}",_CLOUD_BUILD_REGION="${_CLOUD_BUILD_REGION}",_BUILD_ACCOUNT="${_BUILD_ACCOUNT}" \
--region="${_CLOUD_BUILD_REGION}"
else
echo "==Skipping SFDC=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'marketing-test-harness'
waitFor: ['init_deploy_config']
script: |
#!/usr/bin/env bash
set -e
_DEPLOY_MARKETING_=$(jq -r ."deployMarketing" ${_CONFIG_FILE})
_TEST_DATA_=$(jq -r ."testData" ${_CONFIG_FILE})
if [[ ${_NO_TEST_DATA} != "true" && ${_TEST_DATA_} == "true" && ${_DEPLOY_MARKETING_} == "true" ]]; then
_DEPLOY_ADS_=$(jq -r ."marketing.deployGoogleAds" ${_CONFIG_FILE})
_DEPLOY_CM360_=$(jq -r ."marketing.deployCM360" ${_CONFIG_FILE})
_DEPLOY_TIKTOK_=$(jq -r ."marketing.deployTikTok" ${_CONFIG_FILE})
_DEPLOY_LIVERAMP_=$(jq -r ."marketing.deployLiveRamp" ${_CONFIG_FILE})
_DEPLOY_META_=$(jq -r ."marketing.deployMeta" ${_CONFIG_FILE})
_DEPLOY_SFMC_=$(jq -r ."marketing.deploySFMC" ${_CONFIG_FILE})
_DEPLOY_DV360_=$(jq -r ."marketing.deployDV360" ${_CONFIG_FILE})
_DEPLOY_GA4_=$(jq -r ."marketing.deployGA4" ${_CONFIG_FILE})
if [[ ${_DEPLOY_ADS_} == "true" ]]; then
echo "Deploying Google Ads Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.GoogleAds" --dataset "raw"
fi
if [[ ${_DEPLOY_CM360_} == "true" ]]; then
echo "Deploying CM360 Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.CM360" --dataset "raw"
fi
if [[ ${_DEPLOY_TIKTOK_} == "true" ]]; then
echo "Deploying TikTok Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.TikTok" --dataset "raw"
fi
if [[ ${_DEPLOY_LIVERAMP_} == "true" ]]; then
echo "Deploying LiveRamp Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.LiveRamp" --dataset "cdc"
fi
if [[ ${_DEPLOY_META_} == "true" ]]; then
echo "Deploying Meta Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.Meta" --dataset "raw"
fi
if [[ ${_DEPLOY_SFMC_} == "true" ]]; then
echo "Deploying SFMC Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.SFMC" --dataset "raw"
fi
if [[ ${_DEPLOY_DV360_} == "true" ]]; then
echo "Deploying DV360 Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.DV360" --dataset "raw"
fi
if [[ ${_DEPLOY_GA4_} == "true" ]]; then
echo "Deploying Google Analytics 4 Test Harness."
python3 src/common/create_test_harness.py --workload "marketing.GA4" --dataset "cdc"
fi
else
echo "==Skipping Test Harness for Marketing=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'marketing-deploy'
waitFor: ['k9-pre', 'marketing-test-harness']
script: |
#!/usr/bin/env bash
_DEPLOY_MARKETING_="$(jq -r ."deployMarketing" "${_CONFIG_FILE}")"
if [[ "${_DEPLOY_MARKETING_}" == "true" ]]; then
cp -f "${_CONFIG_FILE}" src/marketing/config/config.json
gcloud builds submit ./src/marketing \
--config=./src/marketing/cloudbuild.marketing.yaml \
--substitutions=_GCS_LOGS_BUCKET="${_GCS_BUCKET}",_WORKER_POOL_NAME="${_WORKER_POOL_NAME}",_CLOUD_BUILD_REGION="${_CLOUD_BUILD_REGION}",_BUILD_ACCOUNT="${_BUILD_ACCOUNT}" \
--region="${_CLOUD_BUILD_REGION}"
else
echo "==Skipping Marketing=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'oracle-ebs-test-harness'
waitFor: ['init_deploy_config']
script: |
#!/usr/bin/env bash
set -e
_DEPLOY_EBS_=$(jq -r ."deployOracleEBS" ${_CONFIG_FILE})
_TEST_DATA_=$(jq -r ."testData" ${_CONFIG_FILE})
if [[ ${_NO_TEST_DATA} != "true" && ${_TEST_DATA_} == "true" && ${_DEPLOY_EBS_} == "true" ]]; then
echo "Deploying Oracle EBS Test Harness."
python3 src/common/create_test_harness.py --workload "OracleEBS" --dataset "cdc"
else
echo "==Skipping Test Harness for Oracle=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'oracle-ebs-deploy'
waitFor: ['k9-pre', 'oracle-ebs-test-harness']
script: |
#!/usr/bin/env bash
_DEPLOY_EBS_=$(jq -r ."deployOracleEBS" ${_CONFIG_FILE})
if [[ ${_DEPLOY_EBS_} == "true" ]]; then
cp -f ${_CONFIG_FILE} src/OracleEBS/config/config.json
gcloud builds submit ./src/OracleEBS \
--config=./src/OracleEBS/cloudbuild.oracle_ebs.yaml \
--substitutions=_GCS_LOGS_BUCKET="${_GCS_BUCKET}",_WORKER_POOL_NAME="${_WORKER_POOL_NAME}",_CLOUD_BUILD_REGION="${_CLOUD_BUILD_REGION}",_BUILD_ACCOUNT="${_BUILD_ACCOUNT}" \
--region="${_CLOUD_BUILD_REGION}"
else
echo "==Skipping Oracle EBS=="
fi
- name: gcr.io/kittycorn-public/deploy-kittycorn:v2.0
id: 'k9-post'
waitFor: ['k9-pre', 'sap-reporting', 'sfdc-deploy', 'marketing-deploy', 'oracle-ebs-deploy']
script: |
#!/usr/bin/env bash
export PYTHONPATH=${PYTHONPATH}:src/:.
declare -a _WORKER_POOL_OPTIONS
if [[ -n "${_WORKER_POOL_NAME}" ]]; then
_WORKER_POOL_OPTIONS+=(--worker-pool-name "${_WORKER_POOL_NAME}")
fi
if [[ -n "${_CLOUD_BUILD_REGION}" ]]; then
_WORKER_POOL_OPTIONS+=(--region "${_CLOUD_BUILD_REGION}")
fi
if [[ -n "${_BUILD_ACCOUNT}" ]]; then
_WORKER_POOL_OPTIONS+=(--build-account "${_BUILD_ACCOUNT}")
fi
python3 src/k9/src/deploy_k9.py \
--config-file "${_CONFIG_FILE}" \
--stage post \
--logs-bucket "${_GCS_BUCKET}" \
"${_WORKER_POOL_OPTIONS[@]}"
logsBucket: "gs://${_GCS_BUCKET}"
serviceAccount: "${_BUILD_ACCOUNT}"
timeout: 32400s
substitutions:
_CONFIG_FILE: "config/config.json"
_NO_TEST_DATA: "false"
options:
substitution_option: "ALLOW_LOOSE"
automapSubstitutions: true
pool:
name: "${_WORKER_POOL_NAME}"
tags: ["cortex"]