From 0b17dc0c564eadc8fbd4dad41736b0933818396d Mon Sep 17 00:00:00 2001 From: Ian Woodard <17186604+IanWoodard@users.noreply.github.com> Date: Fri, 19 Dec 2025 09:56:15 -0600 Subject: [PATCH 1/3] ref(pipedream): Adding grouping support --- libs/getsentry.libsonnet | 38 +- libs/pipedream.libsonnet | 209 ++-- test/pipedream.js | 960 ++---------------- .../fixtures/getsentry/groups.jsonnet | 6 + .../fixtures/getsentry/regions.jsonnet | 5 - .../pipedream/autodeploy-parallel.jsonnet | 40 - ...onfig.jsonnet => basic-autodeploy.jsonnet} | 21 +- ...oy-serial.jsonnet => basic-manual.jsonnet} | 19 +- .../different-stages-per-region.jsonnet | 44 + .../pipedream/exclude-entire-group.jsonnet | 36 + ...-serial.jsonnet => exclude-region.jsonnet} | 28 +- ...xclude-regions-autodeploy-parallel.jsonnet | 39 - ...onnet => include-default-excluded.jsonnet} | 27 +- ...nclude-regions-autodeploy-parallel.jsonnet | 40 - ...ude-regions-no-autodeploy-parallel.jsonnet | 41 - ...clude-regions-no-autodeploy-serial.jsonnet | 41 - .../include-regions-parallel.jsonnet | 40 - .../pipedream/multi-region-group.jsonnet | 36 + .../pipedream/no-autodeploy-parallel.jsonnet | 41 - .../pipedream/no-autodeploy-serial.jsonnet | 41 - ...parallel.jsonnet => parallel-mode.jsonnet} | 19 +- .../rollback-bad-final-stage.failing.jsonnet | 30 +- .../rollback-bad-stage.failing.jsonnet | 26 +- .../rollback-override-final-stage.jsonnet | 46 - ...deploy-serial.jsonnet => rollback.jsonnet} | 25 +- .../groups.jsonnet_output-files.golden | 34 + .../regions.jsonnet_output-files.golden | 14 - ...eploy-parallel.jsonnet_output-files.golden | 380 ------- ...deploy-parallel.jsonnet_single-file.golden | 338 ------ ...odeploy-serial.jsonnet_output-files.golden | 404 -------- ...todeploy-serial.jsonnet_single-file.golden | 362 ------- ...sic-autodeploy.jsonnet_output-files.golden | 234 +++++ ...asic-autodeploy.jsonnet_single-file.golden | 217 ++++ .../basic-manual.jsonnet_output-files.golden | 275 +++++ .../basic-manual.jsonnet_single-file.golden | 253 +++++ ...ges-per-region.jsonnet_output-files.golden | 370 +++++++ ...ages-per-region.jsonnet_single-file.golden | 353 +++++++ ...e-entire-group.jsonnet_output-files.golden | 159 +++ ...de-entire-group.jsonnet_single-file.golden | 147 +++ ...exclude-region.jsonnet_output-files.golden | 226 +++++ .../exclude-region.jsonnet_single-file.golden | 209 ++++ ...eploy-parallel.jsonnet_output-files.golden | 304 ------ ...deploy-parallel.jsonnet_single-file.golden | 272 ----- ...eploy-parallel.jsonnet_output-files.golden | 365 ------- ...deploy-parallel.jsonnet_single-file.golden | 328 ------ ...odeploy-serial.jsonnet_output-files.golden | 365 ------- ...todeploy-serial.jsonnet_single-file.golden | 328 ------ ...ault-excluded.jsonnet_output-files.golden} | 225 ++-- ...fault-excluded.jsonnet_single-file.golden} | 202 ++-- ...eploy-parallel.jsonnet_output-files.golden | 342 ------- ...deploy-parallel.jsonnet_single-file.golden | 305 ------ ...odeploy-serial.jsonnet_output-files.golden | 366 ------- ...todeploy-serial.jsonnet_single-file.golden | 329 ------ ...eploy-parallel.jsonnet_output-files.golden | 407 -------- ...deploy-parallel.jsonnet_single-file.golden | 365 ------- ...odeploy-serial.jsonnet_output-files.golden | 407 -------- ...todeploy-serial.jsonnet_single-file.golden | 365 ------- ...gions-parallel.jsonnet_output-files.golden | 342 ------- ...egions-parallel.jsonnet_single-file.golden | 305 ------ ...i-region-group.jsonnet_output-files.golden | 132 +++ ...ti-region-group.jsonnet_single-file.golden | 125 +++ ...eploy-parallel.jsonnet_output-files.golden | 714 ------------- ...deploy-parallel.jsonnet_single-file.golden | 667 ------------ ...odeploy-serial.jsonnet_output-files.golden | 714 ------------- ...todeploy-serial.jsonnet_single-file.golden | 667 ------------ .../parallel-mode.jsonnet_output-files.golden | 275 +++++ .../parallel-mode.jsonnet_single-file.golden | 253 +++++ ...de-final-stage.jsonnet_output-files.golden | 428 -------- ...ide-final-stage.jsonnet_single-file.golden | 386 ------- ...n => rollback.jsonnet_output-files.golden} | 204 ++-- ...en => rollback.jsonnet_single-file.golden} | 186 ++-- 71 files changed, 4105 insertions(+), 12441 deletions(-) create mode 100644 test/testdata/fixtures/getsentry/groups.jsonnet delete mode 100644 test/testdata/fixtures/getsentry/regions.jsonnet delete mode 100644 test/testdata/fixtures/pipedream/autodeploy-parallel.jsonnet rename test/testdata/fixtures/pipedream/{minimal-config.jsonnet => basic-autodeploy.jsonnet} (61%) rename test/testdata/fixtures/pipedream/{exclude-regions-no-autodeploy-serial.jsonnet => basic-manual.jsonnet} (70%) create mode 100644 test/testdata/fixtures/pipedream/different-stages-per-region.jsonnet create mode 100644 test/testdata/fixtures/pipedream/exclude-entire-group.jsonnet rename test/testdata/fixtures/pipedream/{exclude-regions-autodeploy-serial.jsonnet => exclude-region.jsonnet} (52%) delete mode 100644 test/testdata/fixtures/pipedream/exclude-regions-autodeploy-parallel.jsonnet rename test/testdata/fixtures/pipedream/{include-regions-autodeploy-serial.jsonnet => include-default-excluded.jsonnet} (54%) delete mode 100644 test/testdata/fixtures/pipedream/include-regions-autodeploy-parallel.jsonnet delete mode 100644 test/testdata/fixtures/pipedream/include-regions-no-autodeploy-parallel.jsonnet delete mode 100644 test/testdata/fixtures/pipedream/include-regions-no-autodeploy-serial.jsonnet delete mode 100644 test/testdata/fixtures/pipedream/include-regions-parallel.jsonnet create mode 100644 test/testdata/fixtures/pipedream/multi-region-group.jsonnet delete mode 100644 test/testdata/fixtures/pipedream/no-autodeploy-parallel.jsonnet delete mode 100644 test/testdata/fixtures/pipedream/no-autodeploy-serial.jsonnet rename test/testdata/fixtures/pipedream/{exclude-regions-no-autodeploy-parallel.jsonnet => parallel-mode.jsonnet} (71%) delete mode 100644 test/testdata/fixtures/pipedream/rollback-override-final-stage.jsonnet rename test/testdata/fixtures/pipedream/{autodeploy-serial.jsonnet => rollback.jsonnet} (61%) create mode 100644 test/testdata/goldens/getsentry/groups.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/getsentry/regions.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_single-file.golden rename test/testdata/goldens/pipedream/{minimal-config.jsonnet_output-files.golden => include-default-excluded.jsonnet_output-files.golden} (56%) rename test/testdata/goldens/pipedream/{minimal-config.jsonnet_single-file.golden => include-default-excluded.jsonnet_single-file.golden} (57%) delete mode 100644 test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden delete mode 100644 test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_output-files.golden delete mode 100644 test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_single-file.golden rename test/testdata/goldens/pipedream/{exclude-regions-autodeploy-serial.jsonnet_output-files.golden => rollback.jsonnet_output-files.golden} (67%) rename test/testdata/goldens/pipedream/{exclude-regions-autodeploy-serial.jsonnet_single-file.golden => rollback.jsonnet_single-file.golden} (67%) diff --git a/libs/getsentry.libsonnet b/libs/getsentry.libsonnet index fb6e95a..fe3c902 100644 --- a/libs/getsentry.libsonnet +++ b/libs/getsentry.libsonnet @@ -3,23 +3,25 @@ */ { - // These regions are user facing deployments - prod_regions: [ - 's4s2', - 'de', - 'us', - // 'control' is excluded by default and must be explicitly included - 'control', - // 'snty-tools' is excluded by default and must be explicitly included - 'snty-tools', - 'customer-1', - 'customer-2', - 'customer-4', - 'customer-7', - ], - // Test regions will deploy in parallel to the regions above - test_regions: [ - 's4s', - ], + group_order: ['s4s', 'de', 'us', 'control', 'snty-tools', 'st'], + test_group_order: [], + // These groupings consist of user facing deployments + pipeline_groups: { + s4s: ['s4s', 's4s2'], + de: ['de'], + us: ['us'], + control: ['control'], + 'snty-tools': ['snty-tools'], + st: ['customer-1', 'customer-2', 'customer-4', 'customer-7'], + }, + // Test groups will deploy in parallel to the groups above + test_groups: { + }, + + group_names:: self.group_order, + test_group_names:: self.test_group_order, + get_targets(group):: + if std.objectHas(self.pipeline_groups, group) then self.pipeline_groups[group] + else self.test_groups[group], is_st(region):: (region == 's4s' || std.startsWith(region, 'customer-')), } diff --git a/libs/pipedream.libsonnet b/libs/pipedream.libsonnet index c6435b6..42e89b5 100644 --- a/libs/pipedream.libsonnet +++ b/libs/pipedream.libsonnet @@ -3,16 +3,24 @@ This libraries main purpose is to generate a set of pipelines that constitute a pipedream. -"pipedream" is what we're calling the overall deployment process for a service -at sentry, where that service is expected to be deployed to multiple regions. +"pipedream" is the overall deployment process for a service at Sentry, where +that service is deployed to multiple regions organized into groups. -The entry point for this library is the `render()` function which takes -some configuration and a callback function. The callback function is expected -to return a pipeline definition for a given region. +Key concepts: +- Groups: Collections of regions that are deployed together +- Regions: Individual deployment targets within a group +- Regions within a group run as parallel jobs within a single pipeline +- Groups are chained sequentially (or fan out in parallel mode) -Pipedream will name the returned pipeline, add an upstream pipeline material -and a final stage. The upstream material and final stage is to make GoCD -chain the pipelines together. +The entry point is `render(config, pipeline_fn)` where: +- config: Pipedream configuration (name, materials, rollback, etc.) +- pipeline_fn(region): Callback that returns a pipeline definition for a region + +Pipedream will: +1. Generate one pipeline per group +2. Aggregate jobs from all regions in the group (running in parallel) +3. Chain pipelines together with upstream materials +4. Append a final 'pipeline-complete' stage */ local getsentry = import './getsentry.libsonnet'; @@ -26,6 +34,36 @@ local pipeline_name(name, region=null) = local is_autodeploy(pipedream_config) = !std.objectHas(pipedream_config, 'auto_deploy') || pipedream_config.auto_deploy == true; +// Regions that are excluded by default and must be explicitly included +local default_excluded_regions = ['control', 'snty-tools']; + +local is_excluded_region = function(region, config) + std.objectHas(config, 'exclude_regions') && std.length(std.find(region, config.exclude_regions)) > 0; + +local is_included_region = function(region, config) + std.objectHas(config, 'include_regions') && std.length(std.find(region, config.include_regions)) > 0; + +local is_default_excluded_region = function(region) + std.length(std.find(region, default_excluded_regions)) > 0; + +local should_include_region = function(region, config) + !is_excluded_region(region, config) && (!is_default_excluded_region(region) || is_included_region(region, config)); + +local get_stage_name(stage) = + std.objectFields(stage)[0]; + +local get_stage_jobs(stage) = + local stage_name = get_stage_name(stage); + if std.objectHas(stage[stage_name], 'jobs') then + stage[stage_name].jobs + else + {}; + +local get_stage_props(stage) = + local stage_name = get_stage_name(stage); + local props = stage[stage_name]; + { [k]: props[k] for k in std.objectFields(props) if k != 'jobs' }; + // This function returns a "trigger pipeline", if configured for manual deploys. // This pipeline is used so users don't need to know what the first pipedream // region is, instead they just look for the `deploy-` pipeline. @@ -163,17 +201,68 @@ local pipedream_rollback_pipeline(pipedream_config, service_pipelines, trigger_p else null; -// generate_region_pipeline will call the pipeline callback function, and then -// name the pipeline, add an upstream material, and append a final stage. -// pipedream_config: The configuration passed into the render() function -// pipeline_fn: The callback function passed in to render() function. -// This function is from users of the library and should -// take in a region and return a GoCD pipeline. -// region: The region to create pipelines for -// display_order: The order of the pipeline in GoCD UI -local generate_region_pipeline(pipedream_config, pipeline_fn, region, display_order) = +// generate_group_pipeline creates a single pipeline for a group by: +// 1. Getting all regions in the group +// 2. Filtering regions based on exclude/include config +// 3. Aggregating jobs from all regions into parallel jobs per stage +// 4. Appending a 'pipeline-complete' stage +// +// pipedream_config: The configuration passed into render() +// pipeline_fn: Callback that takes a region and returns a GoCD pipeline +// group: The group name to create a pipeline for +// display_order: The order of the pipeline in the GoCD UI +local generate_group_pipeline(pipedream_config, pipeline_fn, group, display_order) = local service_name = pipedream_config.name; - local service_pipeline = pipeline_fn(region); + + local all_regions = getsentry.get_targets(group); + local regions = std.filter( + function(r) should_include_region(r, pipedream_config), + all_regions + ); + + local template_pipeline = pipeline_fn(regions[0]); + + // Collect all unique stages across all regions in the group + local all_stages = std.foldl( + function(acc, region) + local p = pipeline_fn(region); + local region_stages = if std.objectHas(p, 'stages') then p.stages else []; + acc + [ + stage + for stage in region_stages + if !std.member([get_stage_name(s) for s in acc], get_stage_name(stage)) + ], + regions, + [] + ); + + // Transforms a stage by aggregating jobs from all regions + local transform_stage(stage) = + local stage_name = get_stage_name(stage); + local stage_props = get_stage_props(stage); + + local all_jobs = std.foldl( + function(acc, region) + local p = pipeline_fn(region); + local matching_stages = std.filter( + function(s) get_stage_name(s) == stage_name, + if std.objectHas(p, 'stages') then p.stages else [] + ); + local stage_jobs = if std.length(matching_stages) > 0 then + get_stage_jobs(matching_stages[0]) + else + {}; + acc + { + [job_name + '-' + region]: stage_jobs[job_name] + for job_name in std.objectFields(stage_jobs) + }, + regions, + {} + ); + + { + [stage_name]: stage_props { jobs: all_jobs }, + }; // `auto_pipeline_progression` was added as a utility for folks new to // pipedream. When this is false, each region will need manual approval @@ -197,12 +286,17 @@ local generate_region_pipeline(pipedream_config, pipeline_fn, region, display_or else []; - // Add the upstream pipeline material and append the final stage - local stages = service_pipeline.stages; - service_pipeline { + // Apply transform to all stages + local transformed_stages = [ + transform_stage(stage) + for stage in all_stages + ]; + + // Assemble final pipeline from template + template_pipeline { group: service_name, display_order: display_order, - stages: prepend_stages + stages + [ + stages: prepend_stages + transformed_stages + [ // This stage is added to ensure a rollback doesn't cause // a deployment train. // @@ -214,23 +308,19 @@ local generate_region_pipeline(pipedream_config, pipeline_fn, region, display_or ], }; -// get_service_pipelines iterates over each region and generates the pipeline -// for each region. +// get_service_pipelines generates a pipeline for each group. // -// pipedream_config: The configuration passed into the render() function -// pipeline_fn: The callback function passed in to render() function. -// This function is from users of the library and should -// take in a region and return a GoCD pipeline. -// regions: The regions to create pipelines for -// display_offset: Used to offset the display order (i.e. test regions are -// display order => trigger + rollback + user regions length) -local get_service_pipelines(pipedream_config, pipeline_fn, regions, display_offset) = +// pipedream_config: The configuration passed into render() +// pipeline_fn: Callback that takes a region and returns a GoCD pipeline +// groups: The group names to create pipelines for +// display_offset: Offset for display_order (accounts for trigger/rollback) +local get_service_pipelines(pipedream_config, pipeline_fn, groups, display_offset) = [ { - name: pipeline_name(pipedream_config.name, regions[i]), - pipeline: generate_region_pipeline(pipedream_config, pipeline_fn, regions[i], display_offset + i), + name: pipeline_name(pipedream_config.name, groups[i]), + pipeline: generate_group_pipeline(pipedream_config, pipeline_fn, groups[i], display_offset + i), } - for i in std.range(0, std.length(regions) - 1) + for i in std.range(0, std.length(groups) - 1) ]; // This is a helper function that handles pipelines that may be null @@ -239,36 +329,31 @@ local pipeline_to_array(pipeline) = if pipeline == null then [] else [pipeline]; { - // render will generate the trigger pipeline and all the region pipelines. + // render generates the trigger pipeline (if manual), group pipelines, and rollback pipeline. render(pipedream_config, pipeline_fn, parallel=false):: - // Regions that are excluded by default and must be explicitly included - local default_excluded_regions = ['control', 'snty-tools']; - - local is_excluded_region = function(region, config) - std.objectHas(config, 'exclude_regions') && std.length(std.find(region, config.exclude_regions)) > 0; - - local is_included_region = function(region, config) - std.objectHas(config, 'include_regions') && std.length(std.find(region, config.include_regions)) > 0; - - local is_default_excluded_region = function(region) - std.length(std.find(region, default_excluded_regions)) > 0; - - local should_include_region = function(region, config) - !is_excluded_region(region, config) && (!is_default_excluded_region(region) || is_included_region(region, config)); - - // Filter out any regions that are listed in the `exclude_regions` attribute. - local regions_to_render = std.filter( - function(region) should_include_region(region, pipedream_config), - getsentry.prod_regions, + local groups_to_render = std.filter( + function(group) + local regions = getsentry.get_targets(group); + std.length(std.filter( + function(r) should_include_region(r, pipedream_config), + regions + )) > 0, + getsentry.group_names ); - local test_regions_to_render = std.filter( - function(region) should_include_region(region, pipedream_config), - getsentry.test_regions, + + local test_groups_to_render = std.filter( + function(group) + local regions = getsentry.get_targets(group); + std.length(std.filter( + function(r) should_include_region(r, pipedream_config), + regions + )) > 0, + getsentry.test_group_names ); local trigger_pipeline = pipedream_trigger_pipeline(pipedream_config); - local service_pipelines = get_service_pipelines(pipedream_config, pipeline_fn, regions_to_render, 2); - local test_pipelines = get_service_pipelines(pipedream_config, pipeline_fn, test_regions_to_render, std.length(regions_to_render) + 2); + local service_pipelines = get_service_pipelines(pipedream_config, pipeline_fn, groups_to_render, 2); + local test_pipelines = get_service_pipelines(pipedream_config, pipeline_fn, test_groups_to_render, std.length(groups_to_render) + 2); local rollback_pipeline = pipedream_rollback_pipeline(pipedream_config, service_pipelines, trigger_pipeline); local all_pipelines = if parallel then pipeline_to_array(rollback_pipeline) + @@ -277,7 +362,7 @@ local pipeline_to_array(pipeline) = // the trigger pipeline std.map(function(p) gocd_pipelines.chain_materials(p, trigger_pipeline), service_pipelines) + - // Chain each test region to the trigger pipeline + // Chain each test group to the trigger pipeline std.map(function(p) gocd_pipelines.chain_materials(p, trigger_pipeline), test_pipelines) else pipeline_to_array(rollback_pipeline) + // Chain the service pipelines together with @@ -285,7 +370,7 @@ local pipeline_to_array(pipeline) = gocd_pipelines.chain_pipelines( pipeline_to_array(trigger_pipeline) + service_pipelines, ) + - // Chain each test region to the trigger pipeline + // Chain each test group to the trigger pipeline std.map(function(p) gocd_pipelines.chain_materials(p, trigger_pipeline), test_pipelines); diff --git a/test/pipedream.js b/test/pipedream.js index bd913ec..8029b3d 100644 --- a/test/pipedream.js +++ b/test/pipedream.js @@ -1,918 +1,168 @@ import test from "ava"; import { render_fixture, get_fixture_content } from "./utils/testdata.js"; -test("ensure manual deploys is expected structure in serial", async (t) => { - const got = await render_fixture( - "pipedream/no-autodeploy-serial.jsonnet", - false, - ); - - t.deepEqual(Object.keys(got), ["format_version", "pipelines"]); - t.truthy(got.pipelines["deploy-example"]); - t.truthy(got.pipelines["deploy-example-s4s2"]); - t.truthy(got.pipelines["deploy-example-s4s"]); // s4s is now a test region - - // Ensure the trigger has the right initial material - const trigger = got.pipelines["deploy-example"]; - t.deepEqual(trigger.materials, { - init_repo: { - branch: "master", - destination: "init", - git: "git@github.com:getsentry/init.git", - shallow_clone: true, - }, - }); - - // Ensure s4s2 depends on the trigger material (first prod region) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure s4s (test region) depends on trigger pipeline, deployed in parallel - const s4s = got.pipelines["deploy-example-s4s"]; - t.deepEqual(s4s.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); +test("autodeploy: no trigger pipeline", async (t) => { + const got = await render_fixture("pipedream/basic-autodeploy.jsonnet", false); + t.falsy(got.pipelines["deploy-example"]); }); -test("ensure manual deploys is expected structure in parallel", async (t) => { - const got = await render_fixture( - "pipedream/no-autodeploy-parallel.jsonnet", - false, - ); - - t.deepEqual(Object.keys(got), ["format_version", "pipelines"]); - t.truthy(got.pipelines["deploy-example"]); - t.truthy(got.pipelines["deploy-example-s4s2"]); - t.truthy(got.pipelines["deploy-example-s4s"]); - - // Ensure the trigger has the right initial material +test("manual deploy: has trigger pipeline with correct materials", async (t) => { + const got = await render_fixture("pipedream/basic-manual.jsonnet", false); const trigger = got.pipelines["deploy-example"]; - t.deepEqual(trigger.materials, { - init_repo: { - branch: "master", - destination: "init", - git: "git@github.com:getsentry/init.git", - shallow_clone: true, - }, - }); - - // Ensure s4s2 depends on the trigger material (first prod region in parallel) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure s4s also depends on the trigger material (parallel deploy) - const s4s = got.pipelines["deploy-example-s4s"]; - t.deepEqual(s4s.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); + + t.truthy(trigger); + t.truthy(trigger.materials.init_repo); + t.is(trigger.stages.length, 1); }); -test("ensure auto deploys is expected structure in serial", async (t) => { - const got = await render_fixture( - "pipedream/autodeploy-serial.jsonnet", - false, +test("generates pipeline per group in correct order", async (t) => { + const got = await render_fixture("pipedream/basic-autodeploy.jsonnet", false); + + const pipelineNames = Object.keys(got.pipelines).filter((n) => + n.startsWith("deploy-example-"), ); - t.deepEqual(Object.keys(got), ["format_version", "pipelines"]); - t.falsy(got.pipelines["deploy-example"]); - t.truthy(got.pipelines["deploy-example-s4s2"]); - t.truthy(got.pipelines["deploy-example-s4s"]); // s4s is now a test region - t.truthy(got.pipelines["rollback-example"]); - - // Ensure s4s2 has just the repo material (first prod region) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure s4s (test region) has just the repo material (deployed in parallel) - const s4s = got.pipelines["deploy-example-s4s"]; - t.deepEqual(s4s.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Rollback only includes prod regions, not test regions - const r = got.pipelines["rollback-example"]; - t.deepEqual(r["environment_variables"], { - ALL_PIPELINE_FLAGS: - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - GOCD_ACCESS_TOKEN: "{{SECRET:[devinfra][gocd_access_token]}}", - REGION_PIPELINE_FLAGS: - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ROLLBACK_MATERIAL_NAME: "example_repo", - ROLLBACK_STAGE: "example_stage", - TRIGGERED_BY: "", - }); - t.deepEqual(r["materials"], { - "deploy-example-customer-7-pipeline-complete": { - pipeline: "deploy-example-customer-7", - stage: "pipeline-complete", - }, - }); - t.deepEqual(r.stages.length, 3); + // Should have s4s, de, us, st (control/snty-tools excluded by default) + t.true(pipelineNames.includes("deploy-example-s4s")); + t.true(pipelineNames.includes("deploy-example-de")); + t.true(pipelineNames.includes("deploy-example-us")); + t.true(pipelineNames.includes("deploy-example-st")); + t.false(pipelineNames.includes("deploy-example-control")); }); -test("ensure auto deploys is expected structure in parallel", async (t) => { - const got = await render_fixture( - "pipedream/autodeploy-parallel.jsonnet", - false, - ); +test("multi-region group has parallel jobs for each region", async (t) => { + const got = await render_fixture("pipedream/basic-autodeploy.jsonnet", false); - t.deepEqual(Object.keys(got), ["format_version", "pipelines"]); - t.falsy(got.pipelines["deploy-example"]); - t.truthy(got.pipelines["deploy-example-s4s2"]); - t.truthy(got.pipelines["deploy-example-s4s"]); // s4s is now a test region - t.truthy(got.pipelines["rollback-example"]); - - // Ensure s4s2 has just the repo material (parallel deploy, no upstream) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure s4s (test region) also has just the repo material (parallel deploy) + // s4s group has s4s + s4s2 regions const s4s = got.pipelines["deploy-example-s4s"]; - t.deepEqual(s4s.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Rollback only includes prod regions, not test regions - const r = got.pipelines["rollback-example"]; - t.deepEqual(r["environment_variables"], { - ALL_PIPELINE_FLAGS: - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - GOCD_ACCESS_TOKEN: "{{SECRET:[devinfra][gocd_access_token]}}", - REGION_PIPELINE_FLAGS: - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ROLLBACK_MATERIAL_NAME: "example_repo", - ROLLBACK_STAGE: "example_stage", - TRIGGERED_BY: "", - }); - t.deepEqual(r["materials"], { - "deploy-example-customer-7-pipeline-complete": { - pipeline: "deploy-example-customer-7", - stage: "pipeline-complete", - }, - }); - t.deepEqual(r.stages.length, 3); + const s4sJobs = Object.keys(s4s.stages[0].deploy.jobs); + t.deepEqual(s4sJobs.sort(), ["deploy-s4s", "deploy-s4s2"]); + + // st group has customer-1, customer-2, customer-4, customer-7 + const st = got.pipelines["deploy-example-st"]; + const stJobs = Object.keys(st.stages[0].deploy.jobs); + t.deepEqual(stJobs.sort(), [ + "deploy-customer-1", + "deploy-customer-2", + "deploy-customer-4", + "deploy-customer-7", + ]); }); -test("ensure exclude regions removes regions without trigger pipeline in serial", async (t) => { - const got = await render_fixture( - "pipedream/exclude-regions-autodeploy-serial.jsonnet", - false, - ); - - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); +test("single-region group has one job", async (t) => { + const got = await render_fixture("pipedream/basic-autodeploy.jsonnet", false); - // Ensure s4s2 has just the repo material (first region after exclusions) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de depends on s4s2 const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - "deploy-example-s4s2-pipeline-complete": { - pipeline: "deploy-example-s4s2", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 has pipeline material too - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - "deploy-example-customer-1-pipeline-complete": { - pipeline: "deploy-example-customer-1", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines - const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); + const deJobs = Object.keys(de.stages[0].deploy.jobs); + t.deepEqual(deJobs, ["deploy-de"]); }); -test("ensure exclude regions removes regions without trigger pipeline in parallel", async (t) => { - const got = await render_fixture( - "pipedream/exclude-regions-autodeploy-parallel.jsonnet", - false, - ); +test("serial mode: pipelines chain sequentially", async (t) => { + const got = await render_fixture("pipedream/basic-manual.jsonnet", false); - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); + // s4s depends on trigger + const s4s = got.pipelines["deploy-example-s4s"]; + t.truthy(s4s.materials["deploy-example-pipeline-complete"]); - // Ensure s4s2 has just the repo material (parallel deploy) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de has just the repo material (parallel deploy) + // de depends on s4s const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 has just the repo material (parallel deploy) - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines - const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); -}); + t.truthy(de.materials["deploy-example-s4s-pipeline-complete"]); -test("ensure exclude regions removes regions with trigger pipeline in serial", async (t) => { - const got = await render_fixture( - "pipedream/exclude-regions-no-autodeploy-serial.jsonnet", - false, - ); + // us depends on de + const us = got.pipelines["deploy-example-us"]; + t.truthy(us.materials["deploy-example-de-pipeline-complete"]); +}); - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example", - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); +test("parallel mode: all pipelines depend on trigger only", async (t) => { + const got = await render_fixture("pipedream/parallel-mode.jsonnet", false); - // Ensure s4s2 depends on trigger (first region after exclusions, serial) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de depends on s4s2 + const s4s = got.pipelines["deploy-example-s4s"]; const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - "deploy-example-s4s2-pipeline-complete": { - pipeline: "deploy-example-s4s2", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 has pipeline material too - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - "deploy-example-customer-1-pipeline-complete": { - pipeline: "deploy-example-customer-1", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines - const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); -}); + const us = got.pipelines["deploy-example-us"]; -test("ensure exclude regions removes regions with trigger pipeline in parallel", async (t) => { - const got = await render_fixture( - "pipedream/exclude-regions-no-autodeploy-parallel.jsonnet", - false, - ); - - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example", - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); + // All depend on trigger + t.truthy(s4s.materials["deploy-example-pipeline-complete"]); + t.truthy(de.materials["deploy-example-pipeline-complete"]); + t.truthy(us.materials["deploy-example-pipeline-complete"]); - // Ensure s4s2 depends on trigger (parallel deploy) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de depends on trigger (parallel deploy) - const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 depends on trigger (parallel deploy) - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines - const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); + // None depend on each other + t.falsy(de.materials["deploy-example-s4s-pipeline-complete"]); + t.falsy(us.materials["deploy-example-de-pipeline-complete"]); }); -test("ensure include regions adds regions without trigger pipeline in serial", async (t) => { - const got = await render_fixture( - "pipedream/include-regions-autodeploy-serial.jsonnet", - false, - ); +test("exclude region: removes job but keeps group", async (t) => { + const got = await render_fixture("pipedream/exclude-region.jsonnet", false); - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example-control", - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); + const st = got.pipelines["deploy-example-st"]; + const jobs = Object.keys(st.stages[0].deploy.jobs); - // Ensure s4s2 has just the repo material (first region) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de depends on s4s2 - const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - "deploy-example-s4s2-pipeline-complete": { - pipeline: "deploy-example-s4s2", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure control depends on de - const control = got.pipelines["deploy-example-control"]; - t.deepEqual(control.materials, { - "deploy-example-de-pipeline-complete": { - pipeline: "deploy-example-de", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-1 depends on control - const c1 = got.pipelines["deploy-example-customer-1"]; - t.deepEqual(c1.materials, { - "deploy-example-control-pipeline-complete": { - pipeline: "deploy-example-control", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 has pipeline material too - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - "deploy-example-customer-1-pipeline-complete": { - pipeline: "deploy-example-customer-1", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines - const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); + t.false(jobs.includes("deploy-customer-2")); + t.true(jobs.includes("deploy-customer-1")); + t.true(jobs.includes("deploy-customer-4")); + t.true(jobs.includes("deploy-customer-7")); }); -test("ensure include regions adds regions without trigger pipeline in parallel", async (t) => { +test("exclude all regions in group: skips entire group", async (t) => { const got = await render_fixture( - "pipedream/include-regions-autodeploy-parallel.jsonnet", + "pipedream/exclude-entire-group.jsonnet", false, ); - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example-control", - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); - - // Ensure s4s2 has just the repo material (parallel deploy) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de has just the repo material (parallel deploy) - const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure control has just the repo material (parallel deploy) - const control = got.pipelines["deploy-example-control"]; - t.deepEqual(control.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-1 has just the repo material (parallel deploy) - const c1 = got.pipelines["deploy-example-customer-1"]; - t.deepEqual(c1.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 has just the repo material (parallel deploy) - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines - const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - ); + t.falsy(got.pipelines["deploy-example-st"]); + t.truthy(got.pipelines["deploy-example-s4s"]); }); -test("ensure include regions adds regions with trigger pipeline in parallel", async (t) => { +test("include region: adds default-excluded group", async (t) => { const got = await render_fixture( - "pipedream/include-regions-no-autodeploy-parallel.jsonnet", + "pipedream/include-default-excluded.jsonnet", false, ); - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example", - "deploy-example-control", - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); - - // Ensure s4s2 depends on the trigger (parallel deploy) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de depends on the trigger (parallel deploy) - const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure control depends on the trigger (parallel deploy) - const control = got.pipelines["deploy-example-control"]; - t.deepEqual(control.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-1 depends on the trigger (parallel deploy) - const c1 = got.pipelines["deploy-example-customer-1"]; - t.deepEqual(c1.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 depends on the trigger (parallel deploy) - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); + t.truthy(got.pipelines["deploy-example-control"]); }); -test("ensure include regions adds regions with trigger pipeline in serial", async (t) => { - const got = await render_fixture( - "pipedream/include-regions-no-autodeploy-serial.jsonnet", - false, - ); - - t.deepEqual(Object.keys(got.pipelines).sort(), [ - "deploy-example", - "deploy-example-control", - "deploy-example-customer-1", - "deploy-example-customer-2", - "deploy-example-customer-4", - "deploy-example-customer-7", - "deploy-example-de", - "deploy-example-s4s2", - "rollback-example", - ]); +test("rollback pipeline structure", async (t) => { + const got = await render_fixture("pipedream/rollback.jsonnet", false); - // Ensure s4s2 depends on the trigger (first region) - const s4s2 = got.pipelines["deploy-example-s4s2"]; - t.deepEqual(s4s2.materials, { - "deploy-example-pipeline-complete": { - pipeline: "deploy-example", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure de depends on s4s2 - const de = got.pipelines["deploy-example-de"]; - t.deepEqual(de.materials, { - "deploy-example-s4s2-pipeline-complete": { - pipeline: "deploy-example-s4s2", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure control depends on de - const control = got.pipelines["deploy-example-control"]; - t.deepEqual(control.materials, { - "deploy-example-de-pipeline-complete": { - pipeline: "deploy-example-de", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-1 depends on control - const c1 = got.pipelines["deploy-example-customer-1"]; - t.deepEqual(c1.materials, { - "deploy-example-control-pipeline-complete": { - pipeline: "deploy-example-control", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure customer-2 has pipeline material too - const c2 = got.pipelines["deploy-example-customer-2"]; - t.deepEqual(c2.materials, { - "deploy-example-customer-1-pipeline-complete": { - pipeline: "deploy-example-customer-1", - stage: "pipeline-complete", - }, - example_repo: { - branch: "master", - destination: "example", - git: "git@github.com:getsentry/example.git", - shallow_clone: true, - }, - }); - - // Ensure rollback has the expected rollback pipelines const r = got.pipelines["rollback-example"]; - const allPipelines = r.environment_variables["ALL_PIPELINE_FLAGS"]; - const regionPipelines = r.environment_variables["REGION_PIPELINE_FLAGS"]; - t.deepEqual( - allPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", + t.truthy(r); + t.is(r.stages.length, 3); + t.is(r.environment_variables.ROLLBACK_STAGE, "deploy"); + t.truthy(r.environment_variables.REGION_PIPELINE_FLAGS); + t.truthy(r.environment_variables.ALL_PIPELINE_FLAGS); +}); + +test("rollback: invalid stage errors", (t) => { + const err = t.throws(() => + get_fixture_content("pipedream/rollback-bad-stage.failing.jsonnet", false), ); - t.deepEqual( - regionPipelines, - "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", + t.true( + err.message.includes("Stage 'this-stage-does-not-exist' does not exist"), ); }); -test("error for invalid final rollback stage", async (t) => { +test("rollback: invalid final stage errors", (t) => { const err = t.throws(() => get_fixture_content( "pipedream/rollback-bad-final-stage.failing.jsonnet", false, ), ); - t.truthy( - err?.message.includes( - "RUNTIME ERROR: Stage 'this-stage-does-not-exist' does not exist", - ), + t.true( + err.message.includes("Stage 'this-stage-does-not-exist' does not exist"), ); }); -test("error for invalid rollback stage", async (t) => { - const err = t.throws(() => - get_fixture_content("pipedream/rollback-bad-stage.failing.jsonnet", false), - ); - t.truthy( - err?.message.includes( - "RUNTIME ERROR: Stage 'this-stage-does-not-exist' does not exist", - ), - ); +test("all pipelines end with pipeline-complete stage", async (t) => { + const got = await render_fixture("pipedream/basic-autodeploy.jsonnet", false); + + for (const [name, pipeline] of Object.entries(got.pipelines)) { + const lastStage = pipeline.stages[pipeline.stages.length - 1]; + const lastStageName = Object.keys(lastStage)[0]; + t.is( + lastStageName, + "pipeline-complete", + `${name} should end with pipeline-complete`, + ); + } }); diff --git a/test/testdata/fixtures/getsentry/groups.jsonnet b/test/testdata/fixtures/getsentry/groups.jsonnet new file mode 100644 index 0000000..e952c82 --- /dev/null +++ b/test/testdata/fixtures/getsentry/groups.jsonnet @@ -0,0 +1,6 @@ +local getsentry = import '../../../../libs/getsentry.libsonnet'; + +{ + all_groups: getsentry.pipeline_groups + getsentry.test_groups, + group_order: getsentry.group_order + getsentry.test_group_order, +} diff --git a/test/testdata/fixtures/getsentry/regions.jsonnet b/test/testdata/fixtures/getsentry/regions.jsonnet deleted file mode 100644 index 9375e63..0000000 --- a/test/testdata/fixtures/getsentry/regions.jsonnet +++ /dev/null @@ -1,5 +0,0 @@ -local getsentry = import '../../../../libs/getsentry.libsonnet'; - -{ - all_regions: getsentry.prod_regions + getsentry.test_regions, -} diff --git a/test/testdata/fixtures/pipedream/autodeploy-parallel.jsonnet b/test/testdata/fixtures/pipedream/autodeploy-parallel.jsonnet deleted file mode 100644 index 771ae1f..0000000 --- a/test/testdata/fixtures/pipedream/autodeploy-parallel.jsonnet +++ /dev/null @@ -1,40 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - auto_deploy: true, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline, parallel=true) diff --git a/test/testdata/fixtures/pipedream/minimal-config.jsonnet b/test/testdata/fixtures/pipedream/basic-autodeploy.jsonnet similarity index 61% rename from test/testdata/fixtures/pipedream/minimal-config.jsonnet rename to test/testdata/fixtures/pipedream/basic-autodeploy.jsonnet index dbae065..de990ad 100644 --- a/test/testdata/fixtures/pipedream/minimal-config.jsonnet +++ b/test/testdata/fixtures/pipedream/basic-autodeploy.jsonnet @@ -2,29 +2,30 @@ local pipedream = import '../../../../libs/pipedream.libsonnet'; local pipedream_config = { name: 'example', - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, + auto_deploy: true, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/exclude-regions-no-autodeploy-serial.jsonnet b/test/testdata/fixtures/pipedream/basic-manual.jsonnet similarity index 70% rename from test/testdata/fixtures/pipedream/exclude-regions-no-autodeploy-serial.jsonnet rename to test/testdata/fixtures/pipedream/basic-manual.jsonnet index 8b917ac..7db9110 100644 --- a/test/testdata/fixtures/pipedream/exclude-regions-no-autodeploy-serial.jsonnet +++ b/test/testdata/fixtures/pipedream/basic-manual.jsonnet @@ -3,7 +3,6 @@ local pipedream = import '../../../../libs/pipedream.libsonnet'; local pipedream_config = { name: 'example', auto_deploy: false, - exclude_regions: ['s4s', 'us'], materials: { init_repo: { git: 'git@github.com:getsentry/init.git', @@ -11,27 +10,29 @@ local pipedream_config = { destination: 'init', }, }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/different-stages-per-region.jsonnet b/test/testdata/fixtures/pipedream/different-stages-per-region.jsonnet new file mode 100644 index 0000000..88c5b1b --- /dev/null +++ b/test/testdata/fixtures/pipedream/different-stages-per-region.jsonnet @@ -0,0 +1,44 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +local config = { + name: 'example', + materials: { + init_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'main', + }, + }, +}; + +// This pipeline_fn returns DIFFERENT stages depending on region +local pipeline_fn(region) = { + materials: config.materials, + stages: if region == 's4s' then [ + // s4s only has deploy stage + { + deploy: { + jobs: { + deploy: { tasks: [{ exec: { command: 'echo', arguments: ['deploy ' + region] } }] }, + }, + }, + }, + ] else [ + // s4s2 has deploy AND verify stages + { + deploy: { + jobs: { + deploy: { tasks: [{ exec: { command: 'echo', arguments: ['deploy ' + region] } }] }, + }, + }, + }, + { + verify: { + jobs: { + verify: { tasks: [{ exec: { command: 'echo', arguments: ['verify ' + region] } }] }, + }, + }, + }, + ], +}; + +pipedream.render(config, pipeline_fn) diff --git a/test/testdata/fixtures/pipedream/exclude-entire-group.jsonnet b/test/testdata/fixtures/pipedream/exclude-entire-group.jsonnet new file mode 100644 index 0000000..48c6ee9 --- /dev/null +++ b/test/testdata/fixtures/pipedream/exclude-entire-group.jsonnet @@ -0,0 +1,36 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Exclude all customer regions → st group is skipped entirely +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['customer-1', 'customer-2', 'customer-4', 'customer-7'], +}; + +local sample = { + pipeline(region):: { + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + destination: 'example', + }, + }, + stages: [ + { + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, + }, + ], + }, +}; + +pipedream.render(pipedream_config, sample.pipeline) diff --git a/test/testdata/fixtures/pipedream/exclude-regions-autodeploy-serial.jsonnet b/test/testdata/fixtures/pipedream/exclude-region.jsonnet similarity index 52% rename from test/testdata/fixtures/pipedream/exclude-regions-autodeploy-serial.jsonnet rename to test/testdata/fixtures/pipedream/exclude-region.jsonnet index e1499c6..5641fe6 100644 --- a/test/testdata/fixtures/pipedream/exclude-regions-autodeploy-serial.jsonnet +++ b/test/testdata/fixtures/pipedream/exclude-region.jsonnet @@ -2,35 +2,31 @@ local pipedream = import '../../../../libs/pipedream.libsonnet'; local pipedream_config = { name: 'example', - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, + auto_deploy: true, + exclude_regions: ['customer-2'], }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/exclude-regions-autodeploy-parallel.jsonnet b/test/testdata/fixtures/pipedream/exclude-regions-autodeploy-parallel.jsonnet deleted file mode 100644 index fdb7aa8..0000000 --- a/test/testdata/fixtures/pipedream/exclude-regions-autodeploy-parallel.jsonnet +++ /dev/null @@ -1,39 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline, parallel=true) diff --git a/test/testdata/fixtures/pipedream/include-regions-autodeploy-serial.jsonnet b/test/testdata/fixtures/pipedream/include-default-excluded.jsonnet similarity index 54% rename from test/testdata/fixtures/pipedream/include-regions-autodeploy-serial.jsonnet rename to test/testdata/fixtures/pipedream/include-default-excluded.jsonnet index 2b1907c..71edcd8 100644 --- a/test/testdata/fixtures/pipedream/include-regions-autodeploy-serial.jsonnet +++ b/test/testdata/fixtures/pipedream/include-default-excluded.jsonnet @@ -2,36 +2,31 @@ local pipedream = import '../../../../libs/pipedream.libsonnet'; local pipedream_config = { name: 'example', + auto_deploy: true, include_regions: ['control'], - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/include-regions-autodeploy-parallel.jsonnet b/test/testdata/fixtures/pipedream/include-regions-autodeploy-parallel.jsonnet deleted file mode 100644 index 507a0a5..0000000 --- a/test/testdata/fixtures/pipedream/include-regions-autodeploy-parallel.jsonnet +++ /dev/null @@ -1,40 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - include_regions: ['control'], - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline, parallel=true) diff --git a/test/testdata/fixtures/pipedream/include-regions-no-autodeploy-parallel.jsonnet b/test/testdata/fixtures/pipedream/include-regions-no-autodeploy-parallel.jsonnet deleted file mode 100644 index ecceab4..0000000 --- a/test/testdata/fixtures/pipedream/include-regions-no-autodeploy-parallel.jsonnet +++ /dev/null @@ -1,41 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - auto_deploy: false, - include_regions: ['control'], - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline, parallel=true) diff --git a/test/testdata/fixtures/pipedream/include-regions-no-autodeploy-serial.jsonnet b/test/testdata/fixtures/pipedream/include-regions-no-autodeploy-serial.jsonnet deleted file mode 100644 index bad6419..0000000 --- a/test/testdata/fixtures/pipedream/include-regions-no-autodeploy-serial.jsonnet +++ /dev/null @@ -1,41 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - auto_deploy: false, - include_regions: ['control'], - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline) diff --git a/test/testdata/fixtures/pipedream/include-regions-parallel.jsonnet b/test/testdata/fixtures/pipedream/include-regions-parallel.jsonnet deleted file mode 100644 index 507a0a5..0000000 --- a/test/testdata/fixtures/pipedream/include-regions-parallel.jsonnet +++ /dev/null @@ -1,40 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - include_regions: ['control'], - exclude_regions: ['s4s', 'us'], - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - branch: 'master', - destination: 'init', - }, - }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline, parallel=true) diff --git a/test/testdata/fixtures/pipedream/multi-region-group.jsonnet b/test/testdata/fixtures/pipedream/multi-region-group.jsonnet new file mode 100644 index 0000000..67bd27d --- /dev/null +++ b/test/testdata/fixtures/pipedream/multi-region-group.jsonnet @@ -0,0 +1,36 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Only render s4s and st to focus on multi-region groups +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['de', 'us'], +}; + +local sample = { + pipeline(region):: { + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + destination: 'example', + }, + }, + stages: [ + { + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, + }, + ], + }, +}; + +pipedream.render(pipedream_config, sample.pipeline) diff --git a/test/testdata/fixtures/pipedream/no-autodeploy-parallel.jsonnet b/test/testdata/fixtures/pipedream/no-autodeploy-parallel.jsonnet deleted file mode 100644 index 86a8025..0000000 --- a/test/testdata/fixtures/pipedream/no-autodeploy-parallel.jsonnet +++ /dev/null @@ -1,41 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - auto_deploy: false, - auto_pipeline_progression: false, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline, parallel=true) diff --git a/test/testdata/fixtures/pipedream/no-autodeploy-serial.jsonnet b/test/testdata/fixtures/pipedream/no-autodeploy-serial.jsonnet deleted file mode 100644 index 5ea18ed..0000000 --- a/test/testdata/fixtures/pipedream/no-autodeploy-serial.jsonnet +++ /dev/null @@ -1,41 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - auto_deploy: false, - auto_pipeline_progression: false, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline) diff --git a/test/testdata/fixtures/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet b/test/testdata/fixtures/pipedream/parallel-mode.jsonnet similarity index 71% rename from test/testdata/fixtures/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet rename to test/testdata/fixtures/pipedream/parallel-mode.jsonnet index adf5d39..ed7991e 100644 --- a/test/testdata/fixtures/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet +++ b/test/testdata/fixtures/pipedream/parallel-mode.jsonnet @@ -3,7 +3,6 @@ local pipedream = import '../../../../libs/pipedream.libsonnet'; local pipedream_config = { name: 'example', auto_deploy: false, - exclude_regions: ['s4s', 'us'], materials: { init_repo: { git: 'git@github.com:getsentry/init.git', @@ -11,27 +10,29 @@ local pipedream_config = { destination: 'init', }, }, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/rollback-bad-final-stage.failing.jsonnet b/test/testdata/fixtures/pipedream/rollback-bad-final-stage.failing.jsonnet index 632c535..ad06653 100644 --- a/test/testdata/fixtures/pipedream/rollback-bad-final-stage.failing.jsonnet +++ b/test/testdata/fixtures/pipedream/rollback-bad-final-stage.failing.jsonnet @@ -5,39 +5,33 @@ local pipedream_config = { auto_deploy: true, rollback: { material_name: 'example_repo', - stage: 'example_stage', - // NOTE: This should only be used during a transition where the final stage - // of a pipeline is will impact rollbacks + stage: 'deploy', final_stage: 'this-stage-does-not-exist', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, + elastic_profile_id: 'example', }, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, - }, - { - other_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/rollback-bad-stage.failing.jsonnet b/test/testdata/fixtures/pipedream/rollback-bad-stage.failing.jsonnet index 96ace81..739975a 100644 --- a/test/testdata/fixtures/pipedream/rollback-bad-stage.failing.jsonnet +++ b/test/testdata/fixtures/pipedream/rollback-bad-stage.failing.jsonnet @@ -6,35 +6,31 @@ local pipedream_config = { rollback: { material_name: 'example_repo', stage: 'this-stage-does-not-exist', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, + elastic_profile_id: 'example', }, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, - }, - { - other_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/fixtures/pipedream/rollback-override-final-stage.jsonnet b/test/testdata/fixtures/pipedream/rollback-override-final-stage.jsonnet deleted file mode 100644 index b7a5a10..0000000 --- a/test/testdata/fixtures/pipedream/rollback-override-final-stage.jsonnet +++ /dev/null @@ -1,46 +0,0 @@ -local pipedream = import '../../../../libs/pipedream.libsonnet'; - -local pipedream_config = { - name: 'example', - auto_deploy: true, - rollback: { - material_name: 'example_repo', - stage: 'example_stage', - // NOTE: This should only be used during a transition where the final stage - // of a pipeline is will impact rollbacks - final_stage: 'other_stage', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, - }, -}; - -local sample = { - pipeline(region):: { - region: region, - materials: { - example_repo: { - git: 'git@github.com:getsentry/example.git', - shallow_clone: true, - branch: 'master', - destination: 'example', - }, - }, - stages: [ - { - example_stage: {}, - }, - { - other_stage: {}, - }, - ], - }, -}; - -pipedream.render(pipedream_config, sample.pipeline) diff --git a/test/testdata/fixtures/pipedream/autodeploy-serial.jsonnet b/test/testdata/fixtures/pipedream/rollback.jsonnet similarity index 61% rename from test/testdata/fixtures/pipedream/autodeploy-serial.jsonnet rename to test/testdata/fixtures/pipedream/rollback.jsonnet index d9c31df..d87a39a 100644 --- a/test/testdata/fixtures/pipedream/autodeploy-serial.jsonnet +++ b/test/testdata/fixtures/pipedream/rollback.jsonnet @@ -5,33 +5,32 @@ local pipedream_config = { auto_deploy: true, rollback: { material_name: 'example_repo', - stage: 'example_stage', - elastic_profile_id: 'example_profile', - }, - materials: { - init_repo: { - git: 'git@github.com:getsentry/init.git', - shallow_clone: true, - branch: 'master', - destination: 'init', - }, + stage: 'deploy', + elastic_profile_id: 'example', }, }; local sample = { pipeline(region):: { - region: region, materials: { example_repo: { git: 'git@github.com:getsentry/example.git', - shallow_clone: true, branch: 'master', destination: 'example', }, }, stages: [ { - example_stage: {}, + deploy: { + jobs: { + deploy: { + elastic_profile_id: 'example', + tasks: [ + { script: './deploy.sh --region=' + region }, + ], + }, + }, + }, }, ], }, diff --git a/test/testdata/goldens/getsentry/groups.jsonnet_output-files.golden b/test/testdata/goldens/getsentry/groups.jsonnet_output-files.golden new file mode 100644 index 0000000..ce848f0 --- /dev/null +++ b/test/testdata/goldens/getsentry/groups.jsonnet_output-files.golden @@ -0,0 +1,34 @@ +{ + "all_groups": { + "control": [ + "control" + ], + "de": [ + "de" + ], + "s4s": [ + "s4s", + "s4s2" + ], + "snty-tools": [ + "snty-tools" + ], + "st": [ + "customer-1", + "customer-2", + "customer-4", + "customer-7" + ], + "us": [ + "us" + ] + }, + "group_order": [ + "s4s", + "de", + "us", + "control", + "snty-tools", + "st" + ] +} diff --git a/test/testdata/goldens/getsentry/regions.jsonnet_output-files.golden b/test/testdata/goldens/getsentry/regions.jsonnet_output-files.golden deleted file mode 100644 index 36a8859..0000000 --- a/test/testdata/goldens/getsentry/regions.jsonnet_output-files.golden +++ /dev/null @@ -1,14 +0,0 @@ -{ - "all_regions": [ - "s4s2", - "de", - "us", - "control", - "snty-tools", - "customer-1", - "customer-2", - "customer-4", - "customer-7", - "s4s" - ] -} diff --git a/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_output-files.golden deleted file mode 100644 index d4bc49d..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,380 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-us.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_single-file.golden deleted file mode 100644 index 5c0f5a9..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,338 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_output-files.golden deleted file mode 100644 index aa13c93..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,404 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-us-pipeline-complete": { - "pipeline": "deploy-example-us", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-us.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_single-file.golden deleted file mode 100644 index d120485..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,362 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-us-pipeline-complete": { - "pipeline": "deploy-example-us", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden new file mode 100644 index 0000000..dd12a5e --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden @@ -0,0 +1,234 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden new file mode 100644 index 0000000..bcf6c3c --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden @@ -0,0 +1,217 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden new file mode 100644 index 0000000..fbfa3bd --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden @@ -0,0 +1,275 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example": { + "display_order": 0, + "group": "example", + "lock_behavior": "unlockWhenFinished", + "materials": { + "init_repo": { + "branch": "master", + "destination": "init", + "git": "git@github.com:getsentry/init.git" + } + }, + "stages": [ + { + "pipeline-complete": { + "approval": { + "type": "manual" + }, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden new file mode 100644 index 0000000..9a7870c --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden @@ -0,0 +1,253 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example": { + "display_order": 0, + "group": "example", + "lock_behavior": "unlockWhenFinished", + "materials": { + "init_repo": { + "branch": "master", + "destination": "init", + "git": "git@github.com:getsentry/init.git" + } + }, + "stages": [ + { + "pipeline-complete": { + "approval": { + "type": "manual" + }, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden new file mode 100644 index 0000000..48efe60 --- /dev/null +++ b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden @@ -0,0 +1,370 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy de" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-de": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify de" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy s4s" + ], + "command": "echo" + } + } + ] + }, + "deploy-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-1" + ], + "command": "echo" + } + } + ] + }, + "deploy-customer-2": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-2" + ], + "command": "echo" + } + } + ] + }, + "deploy-customer-4": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-4" + ], + "command": "echo" + } + } + ] + }, + "deploy-customer-7": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-7" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-customer-1": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-1" + ], + "command": "echo" + } + } + ] + }, + "verify-customer-2": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-2" + ], + "command": "echo" + } + } + ] + }, + "verify-customer-4": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-4" + ], + "command": "echo" + } + } + ] + }, + "verify-customer-7": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-7" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy us" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-us": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify us" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden new file mode 100644 index 0000000..bed0fa1 --- /dev/null +++ b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden @@ -0,0 +1,353 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy de" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-de": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify de" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy s4s" + ], + "command": "echo" + } + } + ] + }, + "deploy-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-1" + ], + "command": "echo" + } + } + ] + }, + "deploy-customer-2": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-2" + ], + "command": "echo" + } + } + ] + }, + "deploy-customer-4": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-4" + ], + "command": "echo" + } + } + ] + }, + "deploy-customer-7": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy customer-7" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-customer-1": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-1" + ], + "command": "echo" + } + } + ] + }, + "verify-customer-2": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-2" + ], + "command": "echo" + } + } + ] + }, + "verify-customer-4": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-4" + ], + "command": "echo" + } + } + ] + }, + "verify-customer-7": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify customer-7" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy us" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-us": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify us" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden new file mode 100644 index 0000000..87086e0 --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden @@ -0,0 +1,159 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden new file mode 100644 index 0000000..0ff5d6b --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden @@ -0,0 +1,147 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden new file mode 100644 index 0000000..2201f69 --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden @@ -0,0 +1,226 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden new file mode 100644 index 0000000..66c30bf --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden @@ -0,0 +1,209 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_output-files.golden deleted file mode 100644 index 7bc8970..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,304 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_single-file.golden deleted file mode 100644 index fe16ddc..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,272 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_output-files.golden deleted file mode 100644 index b7cc85d..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,365 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_single-file.golden deleted file mode 100644 index 9469944..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,328 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_output-files.golden deleted file mode 100644 index 9a76eab..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,365 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_single-file.golden deleted file mode 100644 index 1ec996a..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,328 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/minimal-config.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden similarity index 56% rename from test/testdata/goldens/pipedream/minimal-config.jsonnet_output-files.golden rename to test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden index e49465b..3eb98c8 100644 --- a/test/testdata/goldens/pipedream/minimal-config.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden @@ -1,8 +1,8 @@ { - "deploy-example-customer-1.yaml": { + "deploy-example-control.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-1": { + "deploy-example-control": { "display_order": 5, "group": "example", "materials": { @@ -13,56 +13,23 @@ "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-control": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=control" } ] } } } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -83,70 +50,37 @@ } } }, - "deploy-example-customer-4.yaml": { + "deploy-example-de.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, + "deploy-example-de": { + "display_order": 3, "group": "example", "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-4", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-de": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=de" } ] } } } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -167,66 +101,41 @@ } } }, - "deploy-example-de.yaml": { + "deploy-example-s4s.yaml": { "format_version": 10, "pipelines": { - "deploy-example-de": { - "display_order": 3, + "deploy-example-s4s": { + "display_order": 2, "group": "example", "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "de", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-s4s": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" } ] } } } - } - ] - } - } - }, - "deploy-example-s4s.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -247,24 +156,61 @@ } } }, - "deploy-example-s4s2.yaml": { + "deploy-example-st.yaml": { "format_version": 10, "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, + "deploy-example-st": { + "display_order": 6, "group": "example", "materials": { + "deploy-example-control-pipeline-complete": { + "pipeline": "deploy-example-control", + "stage": "pipeline-complete" + }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "s4s2", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } }, { "pipeline-complete": { @@ -299,14 +245,23 @@ "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "us", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } }, { "pipeline-complete": { diff --git a/test/testdata/goldens/pipedream/minimal-config.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden similarity index 57% rename from test/testdata/goldens/pipedream/minimal-config.jsonnet_single-file.golden rename to test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden index 4593ec9..051e7b8 100644 --- a/test/testdata/goldens/pipedream/minimal-config.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden @@ -1,7 +1,7 @@ { "format_version": 10, "pipelines": { - "deploy-example-customer-1": { + "deploy-example-control": { "display_order": 5, "group": "example", "materials": { @@ -12,51 +12,23 @@ "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-control": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=control" } ] } } } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -75,62 +47,34 @@ } ] }, - "deploy-example-customer-4": { - "display_order": 7, + "deploy-example-de": { + "display_order": 3, "group": "example", "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-4", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-de": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=de" } ] } } } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -149,58 +93,38 @@ } ] }, - "deploy-example-de": { - "display_order": 3, + "deploy-example-s4s": { + "display_order": 2, "group": "example", "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "de", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-s4s": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" } ] } } } - } - ] - }, - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -219,21 +143,58 @@ } ] }, - "deploy-example-s4s2": { - "display_order": 2, + "deploy-example-st": { + "display_order": 6, "group": "example", "materials": { + "deploy-example-control-pipeline-complete": { + "pipeline": "deploy-example-control", + "stage": "pipeline-complete" + }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "s4s2", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } }, { "pipeline-complete": { @@ -263,14 +224,23 @@ "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "us", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } }, { "pipeline-complete": { diff --git a/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_output-files.golden deleted file mode 100644 index d09afb9..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,342 +0,0 @@ -{ - "deploy-example-control.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_single-file.golden deleted file mode 100644 index 8f64228..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,305 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_output-files.golden deleted file mode 100644 index dbb8d49..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,366 +0,0 @@ -{ - "deploy-example-control.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-control-pipeline-complete": { - "pipeline": "deploy-example-control", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_single-file.golden deleted file mode 100644 index d6599d6..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,329 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-control-pipeline-complete": { - "pipeline": "deploy-example-control", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_output-files.golden deleted file mode 100644 index 9a2d60a..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,407 +0,0 @@ -{ - "deploy-example-control.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_single-file.golden deleted file mode 100644 index a3155e2..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,365 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_output-files.golden deleted file mode 100644 index afed347..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,407 +0,0 @@ -{ - "deploy-example-control.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-control-pipeline-complete": { - "pipeline": "deploy-example-control", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_single-file.golden deleted file mode 100644 index 9417390..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,365 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git" - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-control-pipeline-complete": { - "pipeline": "deploy-example-control", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_output-files.golden deleted file mode 100644 index d09afb9..0000000 --- a/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,342 +0,0 @@ -{ - "deploy-example-control.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_single-file.golden deleted file mode 100644 index 8f64228..0000000 --- a/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,305 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-control": { - "display_order": 4, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "control", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-control --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden new file mode 100644 index 0000000..e521d61 --- /dev/null +++ b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden @@ -0,0 +1,132 @@ +{ + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden new file mode 100644 index 0000000..d9b0b64 --- /dev/null +++ b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden @@ -0,0 +1,125 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_output-files.golden deleted file mode 100644 index adaf7db..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,714 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-us.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git", - "shallow_clone": true - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_single-file.golden deleted file mode 100644 index 8ce6688..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,667 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git", - "shallow_clone": true - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_output-files.golden deleted file mode 100644 index 2635415..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,714 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-us-pipeline-complete": { - "pipeline": "deploy-example-us", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-us.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git", - "shallow_clone": true - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_single-file.golden deleted file mode 100644 index ab88035..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,667 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example": { - "display_order": 0, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "init_repo": { - "branch": "master", - "destination": "init", - "git": "git@github.com:getsentry/init.git", - "shallow_clone": true - } - }, - "stages": [ - { - "pipeline-complete": { - "approval": { - "type": "manual" - }, - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-us-pipeline-complete": { - "pipeline": "deploy-example-us", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "deploy-example-pipeline-complete": { - "pipeline": "deploy-example", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "ready": { - "jobs": { - "ready": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "wait": { - "approval": { - "type": "manual" - }, - "jobs": { - "wait": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - }, - { - "example_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7 --pipeline=deploy-example", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", - "stage": "pipeline-complete" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden new file mode 100644 index 0000000..a29ae0a --- /dev/null +++ b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden @@ -0,0 +1,275 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example": { + "display_order": 0, + "group": "example", + "lock_behavior": "unlockWhenFinished", + "materials": { + "init_repo": { + "branch": "master", + "destination": "init", + "git": "git@github.com:getsentry/init.git" + } + }, + "stages": [ + { + "pipeline-complete": { + "approval": { + "type": "manual" + }, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden new file mode 100644 index 0000000..c969e9e --- /dev/null +++ b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden @@ -0,0 +1,253 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example": { + "display_order": 0, + "group": "example", + "lock_behavior": "unlockWhenFinished", + "materials": { + "init_repo": { + "branch": "master", + "destination": "init", + "git": "git@github.com:getsentry/init.git" + } + }, + "stages": [ + { + "pipeline-complete": { + "approval": { + "type": "manual" + }, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-pipeline-complete": { + "pipeline": "deploy-example", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_output-files.golden deleted file mode 100644 index 878fc29..0000000 --- a/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_output-files.golden +++ /dev/null @@ -1,428 +0,0 @@ -{ - "deploy-example-customer-1.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-us-pipeline-complete": { - "pipeline": "deploy-example-us", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-4.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-customer-7.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-de.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "deploy-example-us.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - } - } - }, - "rollback-example.yaml": { - "format_version": 10, - "pipelines": { - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-other_stage": { - "pipeline": "deploy-example-customer-7", - "stage": "other_stage" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } - } -} diff --git a/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_single-file.golden deleted file mode 100644 index e3bf8a9..0000000 --- a/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_single-file.golden +++ /dev/null @@ -1,386 +0,0 @@ -{ - "format_version": 10, - "pipelines": { - "deploy-example-customer-1": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-us-pipeline-complete": { - "pipeline": "deploy-example-us", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-1", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 6, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-4": { - "display_order": 7, - "group": "example", - "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-4", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-customer-7": { - "display_order": 8, - "group": "example", - "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-7", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-de": { - "display_order": 3, - "group": "example", - "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "de", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s": { - "display_order": 9, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "deploy-example-us": { - "display_order": 4, - "group": "example", - "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "pipeline-complete": { - "jobs": { - "pipeline-complete": { - "tasks": [ - { - "exec": { - "command": true - } - } - ] - } - } - } - } - ] - }, - "rollback-example": { - "display_order": 1, - "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", - "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", - "TRIGGERED_BY": "" - }, - "group": "example", - "lock_behavior": "unlockWhenFinished", - "materials": { - "deploy-example-customer-7-other_stage": { - "pipeline": "deploy-example-customer-7", - "stage": "other_stage" - } - }, - "stages": [ - { - "pause_pipelines": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "start_rollback": { - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" - } - ] - } - } - } - }, - { - "incident_resolved": { - "approval": { - "type": "manual" - }, - "jobs": { - "rollback": { - "elastic_profile_id": "example_profile", - "tasks": [ - { - "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" - } - ] - } - } - } - } - ] - } - } -} diff --git a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-serial.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden similarity index 67% rename from test/testdata/goldens/pipedream/exclude-regions-autodeploy-serial.jsonnet_output-files.golden rename to test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden index 2eb7656..4f4da72 100644 --- a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-serial.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden @@ -1,68 +1,35 @@ { - "deploy-example-customer-1.yaml": { + "deploy-example-de.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, + "deploy-example-de": { + "display_order": 3, "group": "example", "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-de": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=de" } ] } } } - } - ] - } - } - }, - "deploy-example-customer-2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -83,28 +50,41 @@ } } }, - "deploy-example-customer-4.yaml": { + "deploy-example-s4s.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-4": { - "display_order": 6, + "deploy-example-s4s": { + "display_order": 2, "group": "example", "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-4", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } }, { "pipeline-complete": { @@ -125,28 +105,61 @@ } } }, - "deploy-example-customer-7.yaml": { + "deploy-example-st.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-7": { - "display_order": 7, + "deploy-example-st": { + "display_order": 5, "group": "example", "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-7", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } }, { "pipeline-complete": { @@ -167,66 +180,37 @@ } } }, - "deploy-example-de.yaml": { + "deploy-example-us.yaml": { "format_version": 10, "pipelines": { - "deploy-example-de": { - "display_order": 3, + "deploy-example-us": { + "display_order": 4, "group": "example", "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "de", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-us": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=us" } ] } } } - } - ] - } - } - }, - "deploy-example-s4s2.yaml": { - "format_version": 10, - "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -253,18 +237,18 @@ "rollback-example": { "display_order": 1, "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", + "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", + "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", + "ROLLBACK_STAGE": "deploy", "TRIGGERED_BY": "" }, "group": "example", "lock_behavior": "unlockWhenFinished", "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", + "deploy-example-st-pipeline-complete": { + "pipeline": "deploy-example-st", "stage": "pipeline-complete" } }, @@ -276,7 +260,7 @@ }, "jobs": { "rollback": { - "elastic_profile_id": "example_profile", + "elastic_profile_id": "example", "tasks": [ { "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" @@ -290,7 +274,7 @@ "start_rollback": { "jobs": { "rollback": { - "elastic_profile_id": "example_profile", + "elastic_profile_id": "example", "tasks": [ { "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" @@ -307,7 +291,7 @@ }, "jobs": { "rollback": { - "elastic_profile_id": "example_profile", + "elastic_profile_id": "example", "tasks": [ { "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" diff --git a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-serial.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden similarity index 67% rename from test/testdata/goldens/pipedream/exclude-regions-autodeploy-serial.jsonnet_single-file.golden rename to test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden index 1c6c8cc..b030a57 100644 --- a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-serial.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden @@ -1,62 +1,34 @@ { "format_version": 10, "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, + "deploy-example-de": { + "display_order": 3, "group": "example", "materials": { - "deploy-example-de-pipeline-complete": { - "pipeline": "deploy-example-de", + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-de": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=de" } ] } } } - } - ] - }, - "deploy-example-customer-2": { - "display_order": 5, - "group": "example", - "materials": { - "deploy-example-customer-1-pipeline-complete": { - "pipeline": "deploy-example-customer-1", - "stage": "pipeline-complete" - }, - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -75,25 +47,38 @@ } ] }, - "deploy-example-customer-4": { - "display_order": 6, + "deploy-example-s4s": { + "display_order": 2, "group": "example", "materials": { - "deploy-example-customer-2-pipeline-complete": { - "pipeline": "deploy-example-customer-2", - "stage": "pipeline-complete" - }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-4", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } }, { "pipeline-complete": { @@ -112,25 +97,58 @@ } ] }, - "deploy-example-customer-7": { - "display_order": 7, + "deploy-example-st": { + "display_order": 5, "group": "example", "materials": { - "deploy-example-customer-4-pipeline-complete": { - "pipeline": "deploy-example-customer-4", + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-7", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } }, { "pipeline-complete": { @@ -149,58 +167,34 @@ } ] }, - "deploy-example-de": { - "display_order": 3, + "deploy-example-us": { + "display_order": 4, "group": "example", "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", "stage": "pipeline-complete" }, "example_repo": { "branch": "master", "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "de", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-us": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=us" } ] } } } - } - ] - }, - "deploy-example-s4s2": { - "display_order": 2, - "group": "example", - "materials": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "s4s2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -222,18 +216,18 @@ "rollback-example": { "display_order": 1, "environment_variables": { - "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", + "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", - "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7", + "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", "ROLLBACK_MATERIAL_NAME": "example_repo", - "ROLLBACK_STAGE": "example_stage", + "ROLLBACK_STAGE": "deploy", "TRIGGERED_BY": "" }, "group": "example", "lock_behavior": "unlockWhenFinished", "materials": { - "deploy-example-customer-7-pipeline-complete": { - "pipeline": "deploy-example-customer-7", + "deploy-example-st-pipeline-complete": { + "pipeline": "deploy-example-st", "stage": "pipeline-complete" } }, @@ -245,7 +239,7 @@ }, "jobs": { "rollback": { - "elastic_profile_id": "example_profile", + "elastic_profile_id": "example", "tasks": [ { "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" @@ -259,7 +253,7 @@ "start_rollback": { "jobs": { "rollback": { - "elastic_profile_id": "example_profile", + "elastic_profile_id": "example", "tasks": [ { "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" @@ -276,7 +270,7 @@ }, "jobs": { "rollback": { - "elastic_profile_id": "example_profile", + "elastic_profile_id": "example", "tasks": [ { "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" From 1f4b76921d74d5a2919294317ee4d450ffb01345 Mon Sep 17 00:00:00 2001 From: mchen-sentry Date: Tue, 6 Jan 2026 13:58:18 -0800 Subject: [PATCH 2/3] cascade pipeline and stage level environment variables down to the job level --- libs/pipedream.libsonnet | 47 ++++++++++--- .../pipedream/env-vars-precedence.jsonnet | 49 +++++++++++++ .../fixtures/pipedream/stage-props.jsonnet | 36 ++++++++++ ...ars-precedence.jsonnet_output-files.golden | 68 +++++++++++++++++++ ...vars-precedence.jsonnet_single-file.golden | 66 ++++++++++++++++++ .../stage-props.jsonnet_output-files.golden | 58 ++++++++++++++++ .../stage-props.jsonnet_single-file.golden | 56 +++++++++++++++ 7 files changed, 372 insertions(+), 8 deletions(-) create mode 100644 test/testdata/fixtures/pipedream/env-vars-precedence.jsonnet create mode 100644 test/testdata/fixtures/pipedream/stage-props.jsonnet create mode 100644 test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden create mode 100644 test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden diff --git a/libs/pipedream.libsonnet b/libs/pipedream.libsonnet index 42e89b5..63fe9e8 100644 --- a/libs/pipedream.libsonnet +++ b/libs/pipedream.libsonnet @@ -62,7 +62,19 @@ local get_stage_jobs(stage) = local get_stage_props(stage) = local stage_name = get_stage_name(stage); local props = stage[stage_name]; - { [k]: props[k] for k in std.objectFields(props) if k != 'jobs' }; + { [k]: props[k] for k in std.objectFields(props) if k != 'jobs' && k != 'environment_variables' }; + +local get_stage_env_vars(stage) = + local stage_name = get_stage_name(stage); + local props = stage[stage_name]; + if std.objectHas(props, 'environment_variables') then props.environment_variables else {}; + +local get_pipeline_env_vars(pipeline) = + if std.objectHas(pipeline, 'environment_variables') then pipeline.environment_variables else {}; + +// Cascade down environment variables with precedence: job > stage > pipeline +local merge_env_vars(pipeline_env, stage_env, job_env) = + pipeline_env + stage_env + job_env; // This function returns a "trigger pipeline", if configured for manual deploys. // This pipeline is used so users don't need to know what the first pipedream @@ -236,7 +248,9 @@ local generate_group_pipeline(pipedream_config, pipeline_fn, group, display_orde [] ); - // Transforms a stage by aggregating jobs from all regions + // Transforms a stage by aggregating jobs from all regions. + // Cascades environment_variables from pipeline -> stage -> job level for each region. + // This is necessary as the pipeline/stage level is shared for all regions in a grouping. local transform_stage(stage) = local stage_name = get_stage_name(stage); local stage_props = get_stage_props(stage); @@ -244,16 +258,26 @@ local generate_group_pipeline(pipedream_config, pipeline_fn, group, display_orde local all_jobs = std.foldl( function(acc, region) local p = pipeline_fn(region); + local pipeline_env = get_pipeline_env_vars(p); local matching_stages = std.filter( function(s) get_stage_name(s) == stage_name, if std.objectHas(p, 'stages') then p.stages else [] ); - local stage_jobs = if std.length(matching_stages) > 0 then - get_stage_jobs(matching_stages[0]) - else - {}; + local region_stage = if std.length(matching_stages) > 0 then matching_stages[0] else null; + local stage_env = if region_stage != null then get_stage_env_vars(region_stage) else {}; + local stage_jobs = if region_stage != null then get_stage_jobs(region_stage) else {}; + acc + { - [job_name + '-' + region]: stage_jobs[job_name] + [job_name + '-' + region]: ( + local job = stage_jobs[job_name]; + local job_env = if std.objectHas(job, 'environment_variables') then job.environment_variables else {}; + local merged_env = merge_env_vars(pipeline_env, stage_env, job_env); + // Add merged env vars to job, or keep job as-is if no env vars + if std.length(std.objectFields(merged_env)) > 0 then + job { environment_variables: merged_env } + else + job + ) for job_name in std.objectFields(stage_jobs) }, regions, @@ -292,8 +316,15 @@ local generate_group_pipeline(pipedream_config, pipeline_fn, group, display_orde for stage in all_stages ]; + // Strip pipeline and stage level environment variables + local filtered_template = { + [k]: template_pipeline[k] + for k in std.objectFields(template_pipeline) + if k != 'environment_variables' + }; + // Assemble final pipeline from template - template_pipeline { + filtered_template { group: service_name, display_order: display_order, stages: prepend_stages + transformed_stages + [ diff --git a/test/testdata/fixtures/pipedream/env-vars-precedence.jsonnet b/test/testdata/fixtures/pipedream/env-vars-precedence.jsonnet new file mode 100644 index 0000000..f04806a --- /dev/null +++ b/test/testdata/fixtures/pipedream/env-vars-precedence.jsonnet @@ -0,0 +1,49 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Test to demonstrate environment_variables precedence: job > stage > pipeline +// Should show separate values for s4s and s4s2 + +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['de', 'us', 'customer-1', 'customer-2', 'customer-4', 'customer-7'], +}; + +local pipeline_fn(region) = { + // Pipeline-level env vars + environment_variables: { + PIPELINE_VAR: 'pipeline-' + region, // Should cascade down to becoming a job level var + SHARED_VAR_JOB: 'from-pipeline', // Should be overwritten by stage, then job + SHARED_VAR_STAGE: 'from-pipeline', // This should win + }, + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + }, + }, + stages: [ + { + deploy: { + // Stage-level env vars + environment_variables: { + STAGE_VAR: 'stage-' + region, // Should cascade down to becoming a job level var + SHARED_VAR_JOB: 'from-stage', // Should be overwritten by job + SHARED_VAR_STAGE: 'from-stage', // Should be overwritten by stage + }, + jobs: { + deploy: { + // Job-level env vars - highest precedence + environment_variables: { + JOB_VAR: 'job-' + region, + SHARED_VAR_JOB: 'from-job', // This should win + }, + tasks: [{ script: './deploy.sh --region=' + region }], + }, + }, + }, + }, + ], +}; + +pipedream.render(pipedream_config, pipeline_fn) diff --git a/test/testdata/fixtures/pipedream/stage-props.jsonnet b/test/testdata/fixtures/pipedream/stage-props.jsonnet new file mode 100644 index 0000000..6ba99f4 --- /dev/null +++ b/test/testdata/fixtures/pipedream/stage-props.jsonnet @@ -0,0 +1,36 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Test to demonstrate stage-level properties behavior +// Within a region grouping, stage properties come from the FIRST region that defines that stage + +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['de', 'us', 'customer-1', 'customer-2', 'customer-4', 'customer-7'], +}; + +// This pipeline_fn returns stages with different properties per region +local pipeline_fn(region) = { + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + }, + }, + stages: [ + { + deploy: { + // Stage-level properties that differ by region + fetch_materials: if region == 's4s' then true else false, + approval: if region == 's4s' then { type: 'manual' } else { type: 'success' }, + jobs: { + deploy: { + tasks: [{ script: './deploy.sh --region=' + region }], + }, + }, + }, + }, + ], +}; + +pipedream.render(pipedream_config, pipeline_fn) diff --git a/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden new file mode 100644 index 0000000..895e3fa --- /dev/null +++ b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden @@ -0,0 +1,68 @@ +{ + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "environment_variables": { + "JOB_VAR": "job-s4s", + "PIPELINE_VAR": "pipeline-s4s", + "SHARED_VAR_JOB": "from-job", + "SHARED_VAR_STAGE": "from-stage", + "STAGE_VAR": "stage-s4s" + }, + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "environment_variables": { + "JOB_VAR": "job-s4s2", + "PIPELINE_VAR": "pipeline-s4s2", + "SHARED_VAR_JOB": "from-job", + "SHARED_VAR_STAGE": "from-stage", + "STAGE_VAR": "stage-s4s2" + }, + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden new file mode 100644 index 0000000..6305dc1 --- /dev/null +++ b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden @@ -0,0 +1,66 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "environment_variables": { + "JOB_VAR": "job-s4s", + "PIPELINE_VAR": "pipeline-s4s", + "SHARED_VAR_JOB": "from-job", + "SHARED_VAR_STAGE": "from-stage", + "STAGE_VAR": "stage-s4s" + }, + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "environment_variables": { + "JOB_VAR": "job-s4s2", + "PIPELINE_VAR": "pipeline-s4s2", + "SHARED_VAR_JOB": "from-job", + "SHARED_VAR_STAGE": "from-stage", + "STAGE_VAR": "stage-s4s2" + }, + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden new file mode 100644 index 0000000..12f5d71 --- /dev/null +++ b/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden @@ -0,0 +1,58 @@ +{ + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "approval": { + "type": "manual" + }, + "fetch_materials": true, + "jobs": { + "deploy-s4s": { + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden new file mode 100644 index 0000000..00f52c7 --- /dev/null +++ b/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden @@ -0,0 +1,56 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "approval": { + "type": "manual" + }, + "fetch_materials": true, + "jobs": { + "deploy-s4s": { + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} From 4458be71bf2c56e0f69fbc5f87893daf6481ecf9 Mon Sep 17 00:00:00 2001 From: mchen-sentry Date: Thu, 5 Mar 2026 13:06:27 -0800 Subject: [PATCH 3/3] disable fetch materials for pipeline complete and regenerate tests --- libs/gocd-stages.libsonnet | 3 + libs/pipedream.libsonnet | 4 +- ...sic-autodeploy.jsonnet_output-files.golden | 4 + ...asic-autodeploy.jsonnet_single-file.golden | 4 + .../basic-manual.jsonnet_output-files.golden | 5 + .../basic-manual.jsonnet_single-file.golden | 5 + ...ges-per-region.jsonnet_output-files.golden | 4 + ...ages-per-region.jsonnet_single-file.golden | 4 + ...ars-precedence.jsonnet_output-files.golden | 1 + ...vars-precedence.jsonnet_single-file.golden | 1 + ...e-entire-group.jsonnet_output-files.golden | 3 + ...de-entire-group.jsonnet_single-file.golden | 3 + ...exclude-region.jsonnet_output-files.golden | 4 + .../exclude-region.jsonnet_single-file.golden | 4 + ...fault-excluded.jsonnet_output-files.golden | 5 + ...efault-excluded.jsonnet_single-file.golden | 5 + ...i-region-group.jsonnet_output-files.golden | 2 + ...ti-region-group.jsonnet_single-file.golden | 2 + .../parallel-mode.jsonnet_output-files.golden | 5 + .../parallel-mode.jsonnet_single-file.golden | 5 + ...stage-override.jsonnet_output-files.golden | 312 ++++++++++++++++++ ...-stage-override.jsonnet_single-file.golden | 290 ++++++++++++++++ .../rollback.jsonnet_output-files.golden | 4 + .../rollback.jsonnet_single-file.golden | 4 + .../stage-props.jsonnet_output-files.golden | 1 + .../stage-props.jsonnet_single-file.golden | 1 + 26 files changed, 683 insertions(+), 2 deletions(-) create mode 100644 test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden create mode 100644 test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden diff --git a/libs/gocd-stages.libsonnet b/libs/gocd-stages.libsonnet index 34c2290..05c77d0 100644 --- a/libs/gocd-stages.libsonnet +++ b/libs/gocd-stages.libsonnet @@ -18,9 +18,12 @@ This library is a set of helpers for building GoCD pipelines. else null; + local fetch_materials = if std.objectHas(opts, 'fetch_materials') then opts.fetch_materials else null; + { [name]: { [if approval != null then 'approval' else null]: approval, + [if fetch_materials != null then 'fetch_materials' else null]: fetch_materials, jobs: { [name]: { tasks: tasks, diff --git a/libs/pipedream.libsonnet b/libs/pipedream.libsonnet index 63fe9e8..74953aa 100644 --- a/libs/pipedream.libsonnet +++ b/libs/pipedream.libsonnet @@ -95,7 +95,7 @@ local pipedream_trigger_pipeline(pipedream_config) = materials: materials, lock_behavior: 'unlockWhenFinished', stages: [ - gocd_stages.basic('pipeline-complete', [gocd_tasks.noop], { approval: 'manual' }), + gocd_stages.basic('pipeline-complete', [gocd_tasks.noop], { approval: 'manual', fetch_materials: false }), ], }, }; @@ -335,7 +335,7 @@ local generate_group_pipeline(pipedream_config, pipeline_fn, group, display_orde // The s4s final stage completes and causes the US pipeline to // re-run. With `pipeline-complete` as the final stage, it isn't // re-run by a rollback, preventing this domino effect. - gocd_stages.basic('pipeline-complete', [gocd_tasks.noop]), + gocd_stages.basic('pipeline-complete', [gocd_tasks.noop], { fetch_materials: false }), ], }; diff --git a/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden index dd12a5e..0864369 100644 --- a/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -88,6 +89,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -163,6 +165,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -214,6 +217,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden index bcf6c3c..6e43120 100644 --- a/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden @@ -32,6 +32,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -82,6 +83,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -152,6 +154,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -198,6 +201,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden index fbfa3bd..a946598 100644 --- a/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -92,6 +93,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -167,6 +169,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -218,6 +221,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -255,6 +259,7 @@ "approval": { "type": "manual" }, + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden index 9a7870c..8fecf59 100644 --- a/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden @@ -18,6 +18,7 @@ "approval": { "type": "manual" }, + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -64,6 +65,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -118,6 +120,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -188,6 +191,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -234,6 +238,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden index 48efe60..fa4eba4 100644 --- a/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden @@ -54,6 +54,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -134,6 +135,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -278,6 +280,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -350,6 +353,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden index bed0fa1..7beebed 100644 --- a/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden @@ -53,6 +53,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -128,6 +129,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -267,6 +269,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -334,6 +337,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden index 895e3fa..93698bc 100644 --- a/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden @@ -48,6 +48,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden index 6305dc1..b7b024a 100644 --- a/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden @@ -47,6 +47,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden index 87086e0..ce37cd1 100644 --- a/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -88,6 +89,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -139,6 +141,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden index 0ff5d6b..ff62f23 100644 --- a/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden @@ -32,6 +32,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -82,6 +83,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -128,6 +130,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden index 2201f69..e39c94d 100644 --- a/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -88,6 +89,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -155,6 +157,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -206,6 +209,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden index 66c30bf..00eaae1 100644 --- a/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden @@ -32,6 +32,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -82,6 +83,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -144,6 +146,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -190,6 +193,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden index 3eb98c8..5e4c4bd 100644 --- a/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -84,6 +85,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -139,6 +141,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -214,6 +217,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -265,6 +269,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden index 051e7b8..25440dc 100644 --- a/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/include-default-excluded.jsonnet_single-file.golden @@ -32,6 +32,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -78,6 +79,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -128,6 +130,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -198,6 +201,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -244,6 +248,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden index e521d61..659fa50 100644 --- a/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden @@ -37,6 +37,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -112,6 +113,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden index d9b0b64..f1b1bb8 100644 --- a/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden @@ -36,6 +36,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -106,6 +107,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden index a29ae0a..b3888d3 100644 --- a/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -92,6 +93,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -167,6 +169,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -218,6 +221,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -255,6 +259,7 @@ "approval": { "type": "manual" }, + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden index c969e9e..bc402ac 100644 --- a/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden @@ -18,6 +18,7 @@ "approval": { "type": "manual" }, + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -64,6 +65,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -118,6 +120,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -188,6 +191,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -234,6 +238,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden new file mode 100644 index 0000000..02c5104 --- /dev/null +++ b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden @@ -0,0 +1,312 @@ +{ + "deploy-example-de.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-st.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-us.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "rollback-example.yaml": { + "format_version": 10, + "pipelines": { + "rollback-example": { + "display_order": 1, + "environment_variables": { + "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", + "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", + "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", + "ROLLBACK_MATERIAL_NAME": "example_repo", + "ROLLBACK_STAGE": "deploy", + "TRIGGERED_BY": "" + }, + "group": "example", + "lock_behavior": "unlockWhenFinished", + "materials": { + "deploy-example-st-deploy": { + "pipeline": "deploy-example-st", + "stage": "deploy" + } + }, + "stages": [ + { + "pause_pipelines": { + "approval": { + "type": "manual" + }, + "jobs": { + "rollback": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" + } + ] + } + } + } + }, + { + "start_rollback": { + "jobs": { + "rollback": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" + } + ] + } + } + } + }, + { + "incident_resolved": { + "approval": { + "type": "manual" + }, + "jobs": { + "rollback": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" + } + ] + } + } + } + } + ] + } + } + } +} diff --git a/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden new file mode 100644 index 0000000..4fd03d2 --- /dev/null +++ b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden @@ -0,0 +1,290 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-de": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s-pipeline-complete": { + "pipeline": "deploy-example-s4s", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s" + } + ] + }, + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 5, + "group": "example", + "materials": { + "deploy-example-us-pipeline-complete": { + "pipeline": "deploy-example-us", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-customer-1": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-us": { + "display_order": 4, + "group": "example", + "materials": { + "deploy-example-de-pipeline-complete": { + "pipeline": "deploy-example-de", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "rollback-example": { + "display_order": 1, + "environment_variables": { + "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", + "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}", + "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-st", + "ROLLBACK_MATERIAL_NAME": "example_repo", + "ROLLBACK_STAGE": "deploy", + "TRIGGERED_BY": "" + }, + "group": "example", + "lock_behavior": "unlockWhenFinished", + "materials": { + "deploy-example-st-deploy": { + "pipeline": "deploy-example-st", + "stage": "deploy" + } + }, + "stages": [ + { + "pause_pipelines": { + "approval": { + "type": "manual" + }, + "jobs": { + "rollback": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" + } + ] + } + } + } + }, + { + "start_rollback": { + "jobs": { + "rollback": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n --commit-sha=\"${sha}\" \\\n --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n --pause-message=\"$pause_message\" \\\n \"$@\"\n" + } + ] + } + } + } + }, + { + "incident_resolved": { + "approval": { + "type": "manual" + }, + "jobs": { + "rollback": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n \"$@\"\n" + } + ] + } + } + } + } + ] + } + } +} diff --git a/test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden index 4f4da72..cb61f30 100644 --- a/test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/rollback.jsonnet_output-files.golden @@ -33,6 +33,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -88,6 +89,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -163,6 +165,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -214,6 +217,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden index b030a57..7fe507a 100644 --- a/test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/rollback.jsonnet_single-file.golden @@ -32,6 +32,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -82,6 +83,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -152,6 +154,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ @@ -198,6 +201,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden index 12f5d71..35a6b72 100644 --- a/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden @@ -38,6 +38,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [ diff --git a/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden index 00f52c7..c7f0b73 100644 --- a/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden @@ -37,6 +37,7 @@ }, { "pipeline-complete": { + "fetch_materials": false, "jobs": { "pipeline-complete": { "tasks": [