|
| 1 | +local getsentry = import 'github.com/getsentry/gocd-jsonnet/libs/getsentry.libsonnet'; |
| 2 | +local gocdtasks = import 'github.com/getsentry/gocd-jsonnet/libs/gocd-tasks.libsonnet'; |
| 3 | + |
| 4 | +// The return value of this function is the body of a GoCD pipeline. |
| 5 | +// More information on gocd-flavor YAML this is producing can be found here: |
| 6 | +// - https://github.com/tomzo/gocd-yaml-config-plugin#pipeline |
| 7 | +// - https://www.notion.so/sentry/GoCD-New-Service-Quickstart-6d8db7a6964049b3b0e78b8a4b52e25d |
| 8 | + |
| 9 | + |
| 10 | +// Snuba deploy to SaaS is blocked till S4S deploy is healthy |
| 11 | +local s4s_health_check(region) = |
| 12 | + if region == 's4s' then |
| 13 | + [ |
| 14 | + { |
| 15 | + health_check: { |
| 16 | + jobs: { |
| 17 | + health_check: { |
| 18 | + environment_variables: { |
| 19 | + SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}', |
| 20 | + DATADOG_API_KEY: '{{SECRET:[devinfra][st_datadog_api_key]}}', |
| 21 | + DATADOG_APP_KEY: '{{SECRET:[devinfra][st_datadog_app_key]}}', |
| 22 | + LABEL_SELECTOR: 'service=snuba', |
| 23 | + }, |
| 24 | + elastic_profile_id: 'snuba', |
| 25 | + tasks: [ |
| 26 | + gocdtasks.script(importstr '../bash/s4s-sentry-health-check.sh'), |
| 27 | + gocdtasks.script(importstr '../bash/s4s-ddog-health-check.sh'), |
| 28 | + ], |
| 29 | + }, |
| 30 | + }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + ] |
| 34 | + else |
| 35 | + []; |
| 36 | + |
| 37 | +// Snuba deploy to ST is blocked till SaaS deploy is healthy |
| 38 | +local saas_health_check(region) = |
| 39 | + if region == 'us' || region == 'de' then |
| 40 | + [ |
| 41 | + { |
| 42 | + health_check: { |
| 43 | + jobs: { |
| 44 | + health_check: { |
| 45 | + environment_variables: { |
| 46 | + SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}', |
| 47 | + DATADOG_API_KEY: '{{SECRET:[devinfra][sentry_datadog_api_key]}}', |
| 48 | + DATADOG_APP_KEY: '{{SECRET:[devinfra][sentry_datadog_app_key]}}', |
| 49 | + LABEL_SELECTOR: 'service=snuba', |
| 50 | + SENTRY_ENVIRONMENT: region, |
| 51 | + }, |
| 52 | + elastic_profile_id: 'snuba', |
| 53 | + tasks: [ |
| 54 | + gocdtasks.script(importstr '../bash/saas-sentry-health-check.sh'), |
| 55 | + gocdtasks.script(importstr '../bash/saas-sentry-error-check.sh'), |
| 56 | + gocdtasks.script(importstr '../bash/saas-ddog-health-check.sh'), |
| 57 | + ], |
| 58 | + }, |
| 59 | + }, |
| 60 | + }, |
| 61 | + }, |
| 62 | + ] |
| 63 | + else |
| 64 | + []; |
| 65 | + |
| 66 | + |
| 67 | +local deploy_canary_stage(region) = |
| 68 | + if region == 'us' then |
| 69 | + [ |
| 70 | + { |
| 71 | + 'deploy-canary': { |
| 72 | + fetch_materials: true, |
| 73 | + jobs: { |
| 74 | + 'create-sentry-release': { |
| 75 | + environment_variables: { |
| 76 | + SENTRY_ORG: 'sentry', |
| 77 | + SENTRY_PROJECT: 'snuba', |
| 78 | + SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}', |
| 79 | + }, |
| 80 | + timeout: 300, |
| 81 | + elastic_profile_id: 'snuba', |
| 82 | + tasks: [ |
| 83 | + gocdtasks.script(importstr '../bash/sentry-release-canary.sh'), |
| 84 | + ], |
| 85 | + }, |
| 86 | + 'deploy-canary': { |
| 87 | + timeout: 1200, |
| 88 | + elastic_profile_id: 'snuba', |
| 89 | + environment_variables: { |
| 90 | + SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}', |
| 91 | + DATADOG_API_KEY: '{{SECRET:[devinfra][sentry_datadog_api_key]}}', |
| 92 | + DATADOG_APP_KEY: '{{SECRET:[devinfra][sentry_datadog_app_key]}}', |
| 93 | + LABEL_SELECTOR: 'service=snuba,is_canary=true', |
| 94 | + }, |
| 95 | + tasks: [ |
| 96 | + gocdtasks.script(importstr '../bash/deploy-rs.sh'), |
| 97 | + gocdtasks.script(importstr '../bash/canary-ddog-health-check.sh'), |
| 98 | + ], |
| 99 | + }, |
| 100 | + }, |
| 101 | + }, |
| 102 | + }, |
| 103 | + ] |
| 104 | + else |
| 105 | + []; |
| 106 | + |
| 107 | +function(region) { |
| 108 | + environment_variables: { |
| 109 | + SENTRY_REGION: region, |
| 110 | + // Required for checkruns. |
| 111 | + GITHUB_TOKEN: '{{SECRET:[devinfra-github][token]}}', |
| 112 | + GOCD_ACCESS_TOKEN: '{{SECRET:[devinfra][gocd_access_token]}}', |
| 113 | + }, |
| 114 | + lock_behavior: 'unlockWhenFinished', |
| 115 | + materials: { |
| 116 | + snuba_repo: { |
| 117 | + git: '[email protected]:getsentry/snuba.git', |
| 118 | + shallow_clone: false, |
| 119 | + branch: 'master', |
| 120 | + destination: 'snuba', |
| 121 | + }, |
| 122 | + }, |
| 123 | + stages: [ |
| 124 | + { |
| 125 | + checks: { |
| 126 | + jobs: { |
| 127 | + checks: { |
| 128 | + elastic_profile_id: 'snuba', |
| 129 | + tasks: [ |
| 130 | + gocdtasks.script(importstr '../bash/check-github.sh'), |
| 131 | + gocdtasks.script(importstr '../bash/check-migrations.sh'), |
| 132 | + ], |
| 133 | + }, |
| 134 | + }, |
| 135 | + }, |
| 136 | + }, |
| 137 | + |
| 138 | + ] + deploy_canary_stage(region) + [ |
| 139 | + |
| 140 | + { |
| 141 | + 'deploy-primary': { |
| 142 | + fetch_materials: true, |
| 143 | + jobs: { |
| 144 | + // NOTE: sentry-release-primary relies on the sentry-release-canary |
| 145 | + // script being run first. So any changes here should account for |
| 146 | + // this and update deploy_canary_stage accordingly |
| 147 | + [if region == 'us' then 'create-sentry-release' else null]: { |
| 148 | + environment_variables: { |
| 149 | + SENTRY_ORG: 'sentry', |
| 150 | + SENTRY_PROJECT: 'snuba', |
| 151 | + SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}', |
| 152 | + }, |
| 153 | + timeout: 300, |
| 154 | + elastic_profile_id: 'snuba', |
| 155 | + tasks: [ |
| 156 | + gocdtasks.script(importstr '../bash/sentry-release-primary.sh'), |
| 157 | + ], |
| 158 | + }, |
| 159 | + 'deploy-primary': { |
| 160 | + timeout: 1200, |
| 161 | + elastic_profile_id: 'snuba', |
| 162 | + environment_variables: { |
| 163 | + LABEL_SELECTOR: 'service=snuba', |
| 164 | + }, |
| 165 | + tasks: [ |
| 166 | + if getsentry.is_st(region) then |
| 167 | + gocdtasks.script(importstr '../bash/deploy-st-rs.sh') |
| 168 | + else |
| 169 | + gocdtasks.script(importstr '../bash/deploy-rs.sh'), |
| 170 | + ], |
| 171 | + }, |
| 172 | + }, |
| 173 | + }, |
| 174 | + }, |
| 175 | + |
| 176 | + ] + s4s_health_check(region) + saas_health_check(region), |
| 177 | +} |
0 commit comments