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 all 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Validate Deployment Pipelines
on:
pull_request:
push:
branches: [main, test-me-*]
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -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: vroom__main
Expand Down
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} \
"internal-sentry" \
"us.gcr.io/internal-sentry/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/internal-sentry/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.2"
}
],
"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": "54bb0adceffb690bf4aa744b23acdb7888c51fd5",
"sum": "stYmA7r5/MARC5qkFFR+94R1W5juwjmRNVQFOTxmwVA="
}
],
"legacyImports": false
}
71 changes: 71 additions & 0 deletions gocd/templates/pipelines/vroom.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: {
phacops marked this conversation as resolved.
Show resolved Hide resolved
GITHUB_TOKEN: '{{SECRET:[devinfra-github][token]}}',
SENTRY_REGION: region,
SKIP_CANARY_CHECKS: false,
},
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': {
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'),
],
},
},
},
},
],
}
30 changes: 30 additions & 0 deletions gocd/templates/vroom.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local vroom = import './pipelines/vroom.libsonnet';
local pipedream = import 'github.com/getsentry/gocd-jsonnet/libs/pipedream.libsonnet';

local pipedream_config = {
name: 'vroom',
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)