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

feat: Use pipedreams to deploy #312

Merged
merged 12 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 18 additions & 0 deletions .github/workflows/lint-deployment-pipelines.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint Deployment Pipelines
phacops marked this conversation as resolved.
Show resolved Hide resolved
on:
push:
branches:
- main
pull_request:

jobs:
render:
name: Render GoCD Pipelines with Jsonnet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: getsentry/action-gocd-jsonnet@v1
with:
jb-install: true
jsonnet-dir: gocd/templates
generated-dir: gocd/generated-pipelines
54 changes: 0 additions & 54 deletions .github/workflows/validate-pipelines.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
/gocd/templates/vendor/
/gocd/generated-pipelines/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fix android issue frame detection. ([#305](https://github.com/getsentry/vroom/pull/305))
- Fix backward compatibility with Android profiles without timestamp. ([#307](https://github.com/getsentry/vroom/pull/307))
- Report all GCS errors again. ([#311](https://github.com/getsentry/vroom/pull/311))
- Use pipedreams to deploy. ([#312](https://github.com/getsentry/vroom/pull/312))

## 23.8.0

Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build run test issuedetection downloader python-stdlib
.PHONY: build run test issuedetection downloader python-stdlib gocd

build:
./scripts/build.sh
Expand Down Expand Up @@ -27,3 +27,18 @@ format:

python-stdlib:
python scripts/make_python_stdlib.py

gocd:
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
78 changes: 0 additions & 78 deletions gocd/pipelines/cd.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 \
${GO_REVISION_VROOM_REPO} \
${GCP_PROJECT} \
phacops marked this conversation as resolved.
Show resolved Hide resolved
"us.gcr.io/${GCP_PROJECT}/vroom"
6 changes: 6 additions & 0 deletions gocd/templates/bash/check-github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

/devinfra/scripts/checks/githubactions/checkruns.py \
getsentry/vroom \
${GO_REVISION_VROOM_REPO} \
test-vroom
10 changes: 10 additions & 0 deletions gocd/templates/bash/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

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

/devinfra/scripts/k8s/k8stunnel
/devinfra/scripts/k8s/k8s-deploy.py \
--type="cronjob" \
--label-selector="${LABEL_SELECTOR}" \
--image="us.gcr.io/${GCP_PROJECT}/vroom:${GO_REVISION_VROOM_REPO}" \
--container-name="vroom"
5 changes: 5 additions & 0 deletions gocd/templates/bash/wait-canary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

/devinfra/scripts/canary/canarychecks.py \
--skip-check=${SKIP_CANARY_CHECKS} \
--wait-minutes=5
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.2.1"
phacops marked this conversation as resolved.
Show resolved Hide resolved
}
],
"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": "99140666b518b624c016374747ffc7a042abf4bd",
"sum": "iZf3z/wMoCTDLonV2mO2+RpIVCeLPH6GC7ofc9f2VIo="
}
],
"legacyImports": false
}
72 changes: 72 additions & 0 deletions gocd/templates/pipelines/vroom.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
local gocdtasks = import 'github.com/getsentry/gocd-jsonnet/libs/gocd-tasks.libsonnet';

function(region) {
environment_variables: {
phacops marked this conversation as resolved.
Show resolved Hide resolved
// SENTRY_REGION is used by the dev-infra scripts to connect to GKE
SENTRY_REGION: region,
GITHUB_TOKEN: '{{SECRET:[devinfra-github][token]}}',
GCP_PROJECT: 'internal-sentry',
phacops marked this conversation as resolved.
Show resolved Hide resolved
},
materials: {
vroom_repo: {
git: '[email protected]:getsentry/vroom.git',
shallow_clone: true,
branch: 'main',
destination: 'vroom',
},
},
lock_behavior: 'unlockWhenFinished',
stages: [
{
checks: {
fetch_materials: true,
jobs: {
deploy: {
timeout: 600,
elastic_profile_id: 'vroom',
tasks: [
gocdtasks.script(importstr '../bash/check-github.sh'),
gocdtasks.script(importstr '../bash/check-cloudbuild.sh'),
],
},
},
},
},
{
deploy_canary: {
fetch_materials: true,
jobs: {
deploy: {
timeout: 600,
elastic_profile_id: 'vroom',
environment_variables: {
LABEL_SELECTOR: 'service=vroom,environment=production,env=canary',
WAIT_MINUTES: '5',
},
tasks: [
gocdtasks.script(importstr '../bash/deploy.sh'),
gocdtasks.script(importstr '../bash/wait-canary.sh'),
],
},
},
},
},
{
deploy_primary: {
phacops marked this conversation as resolved.
Show resolved Hide resolved
fetch_materials: true,
jobs: {
deploy: {
timeout: 600,
elastic_profile_id: 'vroom',
environment_variables: {
LABEL_SELECTOR: 'service=vroom,environment=production',
},
tasks: [
gocdtasks.script(importstr '../bash/deploy.sh'),
],
},
},
},
},
],
}
31 changes: 31 additions & 0 deletions gocd/templates/vroom.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local vroom = import './pipelines/vroom.libsonnet';
local pipedream = import 'github.com/getsentry/gocd-jsonnet/libs/pipedream.libsonnet';

local pipedream_config = {
name: 'vroom',
auto_deploy: true,
phacops marked this conversation as resolved.
Show resolved Hide resolved
exclude_regions: [
's4s',
'customer-1',
'customer-2',
'customer-3',
'customer-4',
'customer-5',
'customer-6',
],
materials: {
vroom_repo: {
git: '[email protected]:getsentry/vroom.git',
shallow_clone: true,
branch: 'main',
destination: 'vroom',
},
},
rollback: {
material_name: 'vroom_repo',
stage: 'deploy-primary',
elastic_profile_id: 'vroom',
},
};

pipedream.render(pipedream_config, vroom)