Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(gocd): moving chartcuterie to pipedream #155

Merged
merged 8 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/validate-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
filters: |
gocd:
- 'gocd/**'
- '.github/workflows/validate-pipelines.yml'

validate:
if: needs.files-changed.outputs.gocd == 'true'
Expand All @@ -47,6 +48,11 @@ jobs:
token_format: 'id_token'
id_token_audience: '610575311308-9bsjtgqg4jm01mt058rncpopujgk3627.apps.googleusercontent.com'
id_token_include_email: true
- uses: getsentry/action-gocd-jsonnet@v1
with:
jb-install: true
jsonnet-dir: gocd/templates
generated-dir: gocd/generated-pipelines
- uses: getsentry/action-validate-gocd-pipelines@v1
with:
configrepo: chartcuterie__master
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
lib

/gocd/generated-pipelines
/gocd/templates/vendor
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
gocd: ## Build GoCD pipelines
rm -rf ./gocd/generated-pipelines
mkdir -p ./gocd/generated-pipelines
cd ./gocd/templates && jb install && jb update

# Format
find . -type f \( -name '*.libsonnet' -o -name '*.jsonnet' \) -print0 | xargs -n 1 -0 jsonnetfmt -i
# Lint
find . -type f \( -name '*.libsonnet' -o -name '*.jsonnet' \) -print0 | xargs -n 1 -0 jsonnet-lint -J ./gocd/templates/vendor
# Build
cd ./gocd/templates && find . -type f \( -name '*.jsonnet' \) -print0 | xargs -n 1 -0 jsonnet --ext-code output-files=true -J vendor -m ../generated-pipelines

# Convert JSON to yaml
cd ./gocd/generated-pipelines && find . -type f \( -name '*.yaml' \) -print0 | xargs -n 1 -0 yq -p json -o yaml -i
.PHONY: gocd
68 changes: 0 additions & 68 deletions gocd/pipelines/chartcuterie.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions gocd/templates/bash/check-cloudbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

/devinfra/scripts/checks/googlecloud/checkcloudbuild.py \
--sha="${GO_REVISION_CHARTCUTERIE_REPO}" \
IanWoodard marked this conversation as resolved.
Show resolved Hide resolved
--project="sentryio" \
--image_name="us-central1-docker.pkg.dev/sentryio/chartcuterie/image"
6 changes: 6 additions & 0 deletions gocd/templates/bash/check-github-runs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

/devinfra/scripts/checks/githubactions/checkruns.py \
--repo="getsentry/chartcuterie" \
--sha="${GO_REVISION_CHARTCUTERIE_REPO}" \
--check_names="build"
9 changes: 9 additions & 0 deletions gocd/templates/bash/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")

/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-deploy.py \
--label-selector="${LABEL_SELECTOR}" \
--image="us-central1-docker.pkg.dev/sentryio/chartcuterie/image:${GO_REVISION_CHARTCUTERIE_REPO}" \
--container-name="chartcuterie"
3 changes: 3 additions & 0 deletions gocd/templates/bash/wait-canary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sleep 300
25 changes: 25 additions & 0 deletions gocd/templates/chartcuterie.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local chartcuterie = import './pipelines/chartcuterie.libsonnet';
local pipedream = import 'github.com/getsentry/gocd-jsonnet/libs/pipedream.libsonnet';

// Pipedream can be configured using this object, you can learn more about the
// configuration options here: https://github.com/getsentry/gocd-jsonnet#readme
local pipedream_config = {
name: 'chartcuterie',
auto_deploy: true,
materials: {
chartcuterie_repo: {
git: 'git@github.com:getsentry/chartcuterie.git',
shallow_clone: true,
branch: 'master',
destination: 'chartcuterie',
},
},
rollback: {
material_name: 'chartcuterie_repo',
stage: 'deploy-primary',
elastic_profile_id: 'chartcuterie',
},
exclude_regions: ['customer-1', 'customer-2', 'customer-3', 'customer-4', 'customer-5', 'customer-6', 'customer-7', 's4s'],
};

pipedream.render(pipedream_config, chartcuterie)
15 changes: 15 additions & 0 deletions gocd/templates/jsonnetfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/getsentry/gocd-jsonnet.git",
"subdir": "libs"
}
},
"version": "v2.10.0"
}
],
"legacyImports": true
}
16 changes: 16 additions & 0 deletions gocd/templates/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/getsentry/gocd-jsonnet.git",
"subdir": "libs"
}
},
"version": "74ae5728e2d7ed39fdd43cf3b2d28dde7e4567a1",
"sum": "AKMGYALLyaVVVjTNnZy64PoCDA8QjxTbHBe5dCnE4tE="
}
],
"legacyImports": false
}
71 changes: 71 additions & 0 deletions gocd/templates/pipelines/chartcuterie.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
local gocdtasks = import 'github.com/getsentry/gocd-jsonnet/libs/gocd-tasks.libsonnet';

function(region) {
environment_variables: {
// SENTRY_REGION is used by the dev-infra scripts to connect to GKE
SENTRY_REGION: region,
},
materials: {
chartcuterie_repo: {
git: 'git@github.com:getsentry/chartcuterie.git',
shallow_clone: true,
branch: 'master',
destination: 'chartcuterie',
},
},
lock_behavior: 'unlockWhenFinished',
stages: [
{
checks: {
fetch_materials: true,
jobs: {
checks: {
timeout: 1200,
environment_variables: {
GITHUB_TOKEN: '{{SECRET:[devinfra-github][token]}}',
},
tasks: [
gocdtasks.script(importstr '../bash/check-github-runs.sh'),
gocdtasks.script(importstr '../bash/check-cloudbuild.sh'),
],
},
},
},
},
{
'deploy-canary': {
fetch_materials: true,
jobs: {
deploy: {
timeout: 600,
elastic_profile_id: 'chartcuterie',
environment_variables: {
LABEL_SELECTOR: 'service=chartcuterie,env=canary',
},
tasks: [
gocdtasks.script(importstr '../bash/deploy.sh'),
gocdtasks.script(importstr '../bash/wait-canary.sh'),
],
},
},
},
},
{
'deploy-primary': {
fetch_materials: true,
jobs: {
deploy: {
timeout: 600,
elastic_profile_id: 'chartcuterie',
environment_variables: {
LABEL_SELECTOR: 'service=chartcuterie',
},
tasks: [
gocdtasks.script(importstr '../bash/deploy.sh'),
],
},
},
},
},
],
}
Loading