diff --git a/README.md b/README.md index 114f27d..402b703 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ When `output-files=true` it'll output pipelines in the format: ``` This is useful when you build using the `-m` flag in jsonnet as it'll output -multiple files which makes reviewing pipeliens easier. +multiple files which makes reviewing pipelines easier. ```bash jsonnet --ext-code output-files=true -m ./generated-pipelines ./example.jsonnet @@ -58,7 +58,7 @@ jsonnet --ext-code output-files=true -m ./generated-pipelines ./example.jsonnet The GoCD plugin that can process jsonnet files directly doesn't support outputting multiple files, so GoCD is configured to have -`--ext-code output-filaes=false` which will output the pipelines in a flattened +`--ext-code output-files=false` which will output the pipelines in a flattened format: ```json @@ -87,8 +87,21 @@ Pipedream will name the returned pipeline, add an upstream pipeline material and a final stage. The upstream material and final stage is needed to make GoCD chain the pipelines together. -The end result will be a pipeline `deploy-` that starts the run of -each pipeline, and a pipeline for each region. +Regions are organized into **groups** (defined in `getsentry.libsonnet`). Each +group produces a single GoCD pipeline where regions within the group run as +parallel jobs. Groups are chained sequentially by default, or can fan out in +parallel via `pipedream.render(config, pipeline_fn, parallel=true)`. + +The end result is a trigger pipeline `deploy-` and a pipeline per +group (e.g. `deploy-example-s4s2`, `deploy-example-st`). + +`control` and `snty-tools` are excluded by default; use `include_regions` to +opt in. + +Environment variables set at the pipeline or stage level in `pipeline_fn` are +handled automatically: variables identical across all regions in a group stay at +the stage level, while region-specific variables are cascaded to the job level. +GoCD resolves precedence as job > stage > pipeline. ### Example Usage diff --git a/libs/getsentry.libsonnet b/libs/getsentry.libsonnet index a309ce8..d4ae4c3 100644 --- a/libs/getsentry.libsonnet +++ b/libs/getsentry.libsonnet @@ -3,22 +3,26 @@ */ { - // 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: [ - ], + group_order: ['s4s2', 'de', 'us', 'control', 'snty-tools', 'st'], + // Empty for now — add future test groups here + test_group_order: [], + // These groupings consist of user facing deployments + pipeline_groups: { + s4s2: ['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):: std.startsWith(region, 'customer-'), } diff --git a/libs/pipedream.libsonnet b/libs/pipedream.libsonnet index 1991a9f..63e36bc 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,48 @@ 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' && 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 // region is, instead they just look for the `deploy-` pipeline. @@ -163,17 +213,178 @@ 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 + ); + + // Cache pipeline_fn results to avoid redundant calls per region + local region_pipelines = { [r]: pipeline_fn(r) for r in regions }; + + // Validate that each stage object has exactly one key. In Jsonnet, a missing + // comma between stage definitions silently merges them into a single object, + // causing stages to be lost. Catch this at build time. + assert std.foldl( + function(acc, region) + local p = region_pipelines[region]; + local stages = if std.objectHas(p, 'stages') then p.stages else []; + assert std.foldl( + function(acc2, stage) + local keys = std.objectFields(stage); + assert std.length(keys) == 1 : + 'Stage object has %d keys (%s) — each stage must have exactly one key. ' + % [std.length(keys), std.join(', ', keys)] + + 'This usually means a missing comma between stage definitions.'; + true, + stages, + true + ); + true, + regions, + true + ); + + local template_pipeline = region_pipelines[regions[0]]; + + // Validate pipeline-level attributes (materials, lock_behavior, etc.) + // are consistent across all regions in the group. + local pipeline_props(p) = + { [k]: p[k] for k in std.objectFields(p) if k != 'stages' && k != 'environment_variables' }; + local template_props = pipeline_props(template_pipeline); + assert std.foldl( + function(acc, r) + local props = pipeline_props(region_pipelines[r]); + assert props == template_props : + 'Pipeline-level attributes differ across regions in group. ' + + "Region '%s' differs." % [r]; + true, + regions[1:], + true + ); + + // Collect all unique stages across all regions in the group. + // If a region doesn't define a stage that another region has, + // it simply contributes no jobs to that stage. + local all_stages = std.foldl( + function(acc, region) + local p = region_pipelines[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, + [] + ); + + local get_matching_stage(p, stage_name) = + local matching = std.filter( + function(s) get_stage_name(s) == stage_name, + if std.objectHas(p, 'stages') then p.stages else [] + ); + if std.length(matching) > 0 then matching[0] else null; + + // Transforms a stage by aggregating jobs from all regions. + // Env vars identical across all regions are kept at stage level; + // region-specific env vars are cascaded down to the job level. + local transform_stage(stage) = + local stage_name = get_stage_name(stage); + local stage_props = get_stage_props(stage); + + // Validate that all regions agree on stage properties. GoCD only supports + // stage-level attributes (approval, fetch_materials, etc.) — there is no + // per-job override — so conflicting values across regions must be caught + // at build time rather than silently using the first region's values. + assert std.foldl( + function(acc, r) + local p = region_pipelines[r]; + local rs = get_matching_stage(p, stage_name); + local props = if rs != null then get_stage_props(rs) else stage_props; + assert props == stage_props : + "Stage '%s': conflicting stage properties across regions in group. " + % [stage_name] + + "Region '%s' differs." % [r]; + true, + regions[1:], + true + ); + + // Collect merged pipeline+stage env vars for each region + local per_region_parent_envs = { + [region]: ( + local p = region_pipelines[region]; + local pipeline_env = get_pipeline_env_vars(p); + local region_stage = get_matching_stage(p, stage_name); + local stage_env = if region_stage != null then get_stage_env_vars(region_stage) else {}; + merge_env_vars(pipeline_env, stage_env, {}) + ) + for region in regions + }; + + // Env vars identical across ALL regions stay at stage level + local first_env = per_region_parent_envs[regions[0]]; + local common_env = { + [k]: first_env[k] + for k in std.objectFields(first_env) + if std.length(std.filter( + function(r) std.objectHas(per_region_parent_envs[r], k) && per_region_parent_envs[r][k] == first_env[k], + regions + )) == std.length(regions) + }; + + local all_jobs = std.foldl( + function(acc, region) + local parent_env = per_region_parent_envs[region]; + local region_specific_env = { + [k]: parent_env[k] + for k in std.objectFields(parent_env) + if !std.objectHas(common_env, k) || common_env[k] != parent_env[k] + }; + local p = region_pipelines[region]; + local region_stage = get_matching_stage(p, stage_name); + local stage_jobs = if region_stage != null then get_stage_jobs(region_stage) else {}; + + acc + { + [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 = region_specific_env + job_env; + 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, + {} + ); + + { + [stage_name]: stage_props { + jobs: all_jobs, + } + ( + if std.length(std.objectFields(common_env)) > 0 then + { environment_variables: common_env } + else + {} + ), + }; // `auto_pipeline_progression` was added as a utility for folks new to // pipedream. When this is false, each region will need manual approval @@ -197,39 +408,48 @@ 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 + ]; + + // 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 + filtered_template { 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. // - // i.e. During a rollback, US re-runs the final stage. With - // `pipeline-complete` as the final stage, it isn't + // i.e. During a rollback, de and US re-runs the final stage + // The de 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], { fetch_materials: false }), ], }; -// 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 @@ -238,36 +458,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) + @@ -276,7 +491,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 @@ -284,7 +499,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 34436e6..1b79877 100644 --- a/test/pipedream.js +++ b/test/pipedream.js @@ -1,862 +1,184 @@ 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"]); - - // 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, - }, - }); +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"]); - - // 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, - }, - }); -}); - -test("ensure auto deploys is expected structure in serial", async (t) => { - const got = await render_fixture( - "pipedream/autodeploy-serial.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["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, - }, - }); - - // 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); + t.truthy(trigger); + t.truthy(trigger.materials.init_repo); + t.is(trigger.stages.length, 1); }); -test("ensure auto deploys is expected structure in parallel", async (t) => { - const got = await render_fixture( - "pipedream/autodeploy-parallel.jsonnet", - false, - ); +test("generates pipeline per group in correct order", 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["rollback-example"]); + const pipelineNames = Object.keys(got.pipelines).filter((n) => + n.startsWith("deploy-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, - }, - }); - - // 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 s4s2, de, us, st (control/snty-tools excluded by default) + t.true(pipelineNames.includes("deploy-example-s4s2")); + 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 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("multi-region group has parallel jobs for each region", async (t) => { + const got = await render_fixture("pipedream/basic-autodeploy.jsonnet", false); + + // 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", ]); - - // 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", - ); }); -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, - ); - - 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 (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 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", - ); + const deJobs = Object.keys(de.stages[0].deploy.jobs); + t.deepEqual(deJobs, ["deploy-de"]); }); -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, - ); +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", - "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 trigger (first region after exclusions, serial) + // s4s2 depends on trigger 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 + t.truthy(s4s2.materials["deploy-example-pipeline-complete"]); + + // 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 --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", - ); -}); + t.truthy(de.materials["deploy-example-s4s2-pipeline-complete"]); -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, - ); + // 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 (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", - ); -}); - -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, - ); + const us = got.pipelines["deploy-example-us"]; - 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", - ]); + // All depend on trigger + t.truthy(s4s2.materials["deploy-example-pipeline-complete"]); + t.truthy(de.materials["deploy-example-pipeline-complete"]); + t.truthy(us.materials["deploy-example-pipeline-complete"]); - // 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", - ); + // None depend on each other + t.falsy(de.materials["deploy-example-s4s2-pipeline-complete"]); + t.falsy(us.materials["deploy-example-de-pipeline-complete"]); }); -test("ensure include regions adds regions without trigger pipeline in parallel", async (t) => { - const got = await render_fixture( - "pipedream/include-regions-autodeploy-parallel.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 (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.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 with 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-no-autodeploy-parallel.jsonnet", + "pipedream/exclude-entire-group.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.falsy(got.pipelines["deploy-example-st"]); + t.truthy(got.pipelines["deploy-example-de"]); }); -test("ensure include regions adds regions with trigger pipeline in serial", async (t) => { +test("include region: adds default-excluded group", async (t) => { const got = await render_fixture( - "pipedream/include-regions-no-autodeploy-serial.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", - ]); + t.truthy(got.pipelines["deploy-example-control"]); +}); + +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) => { +test("conflicting stage properties across regions errors", (t) => { const err = t.throws(() => - get_fixture_content("pipedream/rollback-bad-stage.failing.jsonnet", false), + get_fixture_content( + "pipedream/stage-props-conflict.failing.jsonnet", + false, + ), ); - t.truthy( - err?.message.includes( - "RUNTIME ERROR: Stage 'this-stage-does-not-exist' does not exist", + t.true( + err.message.includes( + "conflicting stage properties across regions in group", ), ); }); + +test("merged stage objects (missing comma) errors", (t) => { + const err = t.throws(() => + get_fixture_content("pipedream/merged-stages.failing.jsonnet", false), + ); + t.true(err.message.includes("each stage must have exactly one key")); +}); + +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 008cd1d..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: ['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..7dfd2d7 --- /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 == 'customer-1' then [ + // customer-1 only has deploy stage + { + deploy: { + jobs: { + deploy: { tasks: [{ exec: { command: 'echo', arguments: ['deploy ' + region] } }] }, + }, + }, + }, + ] else [ + // other regions have 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/env-vars-precedence.jsonnet b/test/testdata/fixtures/pipedream/env-vars-precedence.jsonnet new file mode 100644 index 0000000..c7b5a0c --- /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 +// Uses st group (multi-region) to show separate values per region + +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['de', 'us'], +}; + +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', // Overridden by stage + }, + 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/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 53% rename from test/testdata/fixtures/pipedream/exclude-regions-autodeploy-serial.jsonnet rename to test/testdata/fixtures/pipedream/exclude-region.jsonnet index 122d42a..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: ['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 88d5bee..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: ['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 ee985e1..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: ['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 3b26669..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: ['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 8cf63b3..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: ['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 8904a8c..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: ['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 3b26669..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: ['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/merged-stages.failing.jsonnet b/test/testdata/fixtures/pipedream/merged-stages.failing.jsonnet new file mode 100644 index 0000000..9f8dfe8 --- /dev/null +++ b/test/testdata/fixtures/pipedream/merged-stages.failing.jsonnet @@ -0,0 +1,39 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// This fixture should FAIL at build time because a stage object has +// multiple keys, indicating a missing comma between stage definitions. + +local pipedream_config = { + name: 'example', + auto_deploy: true, +}; + +local pipeline_fn(region) = { + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + }, + }, + stages: [ + { + // Two stages accidentally merged into one object (missing comma) + deploy: { + jobs: { + deploy: { + tasks: [{ script: './deploy.sh --region=' + region }], + }, + }, + }, + verify: { + jobs: { + verify: { + tasks: [{ script: './verify.sh --region=' + region }], + }, + }, + }, + }, + ], +}; + +pipedream.render(pipedream_config, pipeline_fn) 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..ebf3c9a --- /dev/null +++ b/test/testdata/fixtures/pipedream/multi-region-group.jsonnet @@ -0,0 +1,36 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Only render 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 69c8f8d..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: ['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-final-stage-override.jsonnet b/test/testdata/fixtures/pipedream/rollback-final-stage-override.jsonnet new file mode 100644 index 0000000..52f6cdc --- /dev/null +++ b/test/testdata/fixtures/pipedream/rollback-final-stage-override.jsonnet @@ -0,0 +1,43 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Used by symbolicator and super-big-consumers to point the rollback +// material at deploy-primary instead of the default pipeline-complete. + +local pipedream_config = { + name: 'example', + auto_deploy: true, + rollback: { + material_name: 'example_repo', + stage: 'deploy', + elastic_profile_id: 'example', + final_stage: 'deploy', + }, +}; + +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/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/fixtures/pipedream/stage-props-conflict.failing.jsonnet b/test/testdata/fixtures/pipedream/stage-props-conflict.failing.jsonnet new file mode 100644 index 0000000..b7fa58f --- /dev/null +++ b/test/testdata/fixtures/pipedream/stage-props-conflict.failing.jsonnet @@ -0,0 +1,34 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// This fixture should FAIL at build time because regions in the st group +// define conflicting stage properties (different approval types). + +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['de', 'us'], +}; + +local pipeline_fn(region) = { + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + }, + }, + stages: [ + { + deploy: { + fetch_materials: if region == 'customer-1' then true else false, + approval: if region == 'customer-1' 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/fixtures/pipedream/stage-props.jsonnet b/test/testdata/fixtures/pipedream/stage-props.jsonnet new file mode 100644 index 0000000..7e10d16 --- /dev/null +++ b/test/testdata/fixtures/pipedream/stage-props.jsonnet @@ -0,0 +1,35 @@ +local pipedream = import '../../../../libs/pipedream.libsonnet'; + +// Test that stage-level properties (approval, fetch_materials) are correctly +// preserved when aggregating jobs from multiple regions in a group. + +local pipedream_config = { + name: 'example', + auto_deploy: true, + exclude_regions: ['de', 'us'], +}; + +// All regions use the same stage properties — no conflict. +local pipeline_fn(region) = { + materials: { + example_repo: { + git: 'git@github.com:getsentry/example.git', + branch: 'master', + }, + }, + stages: [ + { + deploy: { + fetch_materials: true, + approval: { type: 'manual' }, + jobs: { + deploy: { + tasks: [{ script: './deploy.sh --region=' + region }], + }, + }, + }, + }, + ], +}; + +pipedream.render(pipedream_config, pipeline_fn) 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..1f935cd --- /dev/null +++ b/test/testdata/goldens/getsentry/groups.jsonnet_output-files.golden @@ -0,0 +1,33 @@ +{ + "all_groups": { + "control": [ + "control" + ], + "de": [ + "de" + ], + "s4s2": [ + "s4s2" + ], + "snty-tools": [ + "snty-tools" + ], + "st": [ + "customer-1", + "customer-2", + "customer-4", + "customer-7" + ], + "us": [ + "us" + ] + }, + "group_order": [ + "s4s2", + "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 720e317..0000000 --- a/test/testdata/goldens/getsentry/regions.jsonnet_output-files.golden +++ /dev/null @@ -1,13 +0,0 @@ -{ - "all_regions": [ - "s4s2", - "de", - "us", - "control", - "snty-tools", - "customer-1", - "customer-2", - "customer-4", - "customer-7" - ] -} 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 ed2dd7d..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,349 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "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-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 0590b45..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,312 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 a9cd203..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,373 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "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-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 135d4b0..0000000 --- a/test/testdata/goldens/pipedream/autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,336 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "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-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..b63c2bf --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_output-files.golden @@ -0,0 +1,230 @@ +{ + "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" + } + }, + "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-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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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 + } + } + ] + } + } + } + } + ] + } + } + } +} 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..fdcb998 --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-autodeploy.jsonnet_single-file.golden @@ -0,0 +1,213 @@ +{ + "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" + } + }, + "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-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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 + } + } + ] + } + } + } + } + ] + } + } +} 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..4d3835a --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-manual.jsonnet_output-files.golden @@ -0,0 +1,272 @@ +{ + "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" + } + }, + "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-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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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 + } + } + ] + } + } + } + } + ] + } + } + }, + "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" + }, + "fetch_materials": false, + "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..0d29336 --- /dev/null +++ b/test/testdata/goldens/pipedream/basic-manual.jsonnet_single-file.golden @@ -0,0 +1,250 @@ +{ + "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" + }, + "fetch_materials": false, + "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" + } + }, + "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-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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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 + } + } + ] + } + } + } + } + ] + } + } +} 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..f167dda --- /dev/null +++ b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_output-files.golden @@ -0,0 +1,350 @@ +{ + "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" + }, + "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": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } + }, + "deploy-example-s4s2.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "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" + }, + "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-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": { + "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" + }, + "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": { + "fetch_materials": false, + "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..08c0c04 --- /dev/null +++ b/test/testdata/goldens/pipedream/different-stages-per-region.jsonnet_single-file.golden @@ -0,0 +1,333 @@ +{ + "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" + }, + "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": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "init_repo": { + "branch": "main", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "deploy-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "deploy s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "verify": { + "jobs": { + "verify-s4s2": { + "tasks": [ + { + "exec": { + "arguments": [ + "verify s4s2" + ], + "command": "echo" + } + } + ] + } + } + } + }, + { + "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" + }, + "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-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": { + "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" + }, + "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": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +} 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..376daea --- /dev/null +++ b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_output-files.golden @@ -0,0 +1,157 @@ +{ + "deploy-example-s4s2.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "environment_variables": { + "PIPELINE_VAR": "pipeline-s4s2", + "SHARED_VAR_JOB": "from-stage", + "SHARED_VAR_STAGE": "from-stage", + "STAGE_VAR": "stage-s4s2" + }, + "jobs": { + "deploy-s4s2": { + "environment_variables": { + "JOB_VAR": "job-s4s2", + "SHARED_VAR_JOB": "from-job" + }, + "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": 3, + "group": "example", + "materials": { + "deploy-example-s4s2-pipeline-complete": { + "pipeline": "deploy-example-s4s2", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "environment_variables": { + "SHARED_VAR_JOB": "from-stage", + "SHARED_VAR_STAGE": "from-stage" + }, + "jobs": { + "deploy-customer-1": { + "environment_variables": { + "JOB_VAR": "job-customer-1", + "PIPELINE_VAR": "pipeline-customer-1", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-1" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "environment_variables": { + "JOB_VAR": "job-customer-2", + "PIPELINE_VAR": "pipeline-customer-2", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-2" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "environment_variables": { + "JOB_VAR": "job-customer-4", + "PIPELINE_VAR": "pipeline-customer-4", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-4" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "environment_variables": { + "JOB_VAR": "job-customer-7", + "PIPELINE_VAR": "pipeline-customer-7", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-7" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "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..aa65b0d --- /dev/null +++ b/test/testdata/goldens/pipedream/env-vars-precedence.jsonnet_single-file.golden @@ -0,0 +1,150 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "environment_variables": { + "PIPELINE_VAR": "pipeline-s4s2", + "SHARED_VAR_JOB": "from-stage", + "SHARED_VAR_STAGE": "from-stage", + "STAGE_VAR": "stage-s4s2" + }, + "jobs": { + "deploy-s4s2": { + "environment_variables": { + "JOB_VAR": "job-s4s2", + "SHARED_VAR_JOB": "from-job" + }, + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s2-pipeline-complete": { + "pipeline": "deploy-example-s4s2", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "environment_variables": { + "SHARED_VAR_JOB": "from-stage", + "SHARED_VAR_STAGE": "from-stage" + }, + "jobs": { + "deploy-customer-1": { + "environment_variables": { + "JOB_VAR": "job-customer-1", + "PIPELINE_VAR": "pipeline-customer-1", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-1" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "environment_variables": { + "JOB_VAR": "job-customer-2", + "PIPELINE_VAR": "pipeline-customer-2", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-2" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "environment_variables": { + "JOB_VAR": "job-customer-4", + "PIPELINE_VAR": "pipeline-customer-4", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-4" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "environment_variables": { + "JOB_VAR": "job-customer-7", + "PIPELINE_VAR": "pipeline-customer-7", + "SHARED_VAR_JOB": "from-job", + "STAGE_VAR": "stage-customer-7" + }, + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "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..49eebbf --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_output-files.golden @@ -0,0 +1,154 @@ +{ + "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" + } + }, + "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-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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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-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 + } + } + ] + } + } + } + } + ] + } + } + } +} 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..6870b69 --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-entire-group.jsonnet_single-file.golden @@ -0,0 +1,142 @@ +{ + "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" + } + }, + "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-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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-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 + } + } + ] + } + } + } + } + ] + } + } +} 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..89c53b3 --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-region.jsonnet_output-files.golden @@ -0,0 +1,222 @@ +{ + "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" + } + }, + "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-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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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-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 + } + } + ] + } + } + } + } + ] + } + } + } +} 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..fd21359 --- /dev/null +++ b/test/testdata/goldens/pipedream/exclude-region.jsonnet_single-file.golden @@ -0,0 +1,205 @@ +{ + "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" + } + }, + "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-s4s2": { + "display_order": 2, + "group": "example", + "materials": { + "example_repo": { + "branch": "master", + "destination": "example", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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-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 + } + } + ] + } + } + } + } + ] + } + } +} 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 4b56528..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,372 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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" - }, - "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-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 2841f16..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,335 +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" - }, - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 b5c623a..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,372 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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" - }, - "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-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 aa2d619..0000000 --- a/test/testdata/goldens/pipedream/exclude-regions-no-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,335 +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" - }, - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 62% 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 42f1551..8202a68 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,57 +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": { - "fetch_materials": false, + "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": { @@ -85,28 +51,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-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": "customer-4", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } }, { "pipeline-complete": { @@ -128,28 +103,33 @@ } } }, - "deploy-example-customer-7.yaml": { + "deploy-example-s4s2.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-7": { - "display_order": 8, + "deploy-example-s4s2": { + "display_order": 2, "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-7", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } }, { "pipeline-complete": { @@ -171,67 +151,61 @@ } } }, - "deploy-example-de.yaml": { + "deploy-example-st.yaml": { "format_version": 10, "pipelines": { - "deploy-example-de": { - "display_order": 3, + "deploy-example-st": { + "display_order": 6, "group": "example", "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", + "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": "de", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-customer-1": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "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" } ] } } } - } - ] - } - } - }, - "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": { @@ -267,14 +241,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 62% 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 f5c896f..3f7973e 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,52 +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": { - "fetch_materials": false, + "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": { @@ -77,25 +48,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-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": "customer-4", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-de": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=de" + } + ] + } + } + } }, { "pipeline-complete": { @@ -115,25 +95,30 @@ } ] }, - "deploy-example-customer-7": { - "display_order": 8, + "deploy-example-s4s2": { + "display_order": 2, "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-7", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } }, { "pipeline-complete": { @@ -153,59 +138,58 @@ } ] }, - "deploy-example-de": { - "display_order": 3, + "deploy-example-st": { + "display_order": 6, "group": "example", "materials": { - "deploy-example-s4s2-pipeline-complete": { - "pipeline": "deploy-example-s4s2", + "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": "de", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-customer-1": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "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" } ] } } } - } - ] - }, - "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": { @@ -236,14 +220,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 cbc4ab2..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,349 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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-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 538dc03..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,312 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 0a26473..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,373 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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-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 e0b921a..0000000 --- a/test/testdata/goldens/pipedream/include-regions-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,336 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 016c328..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,415 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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" - }, - "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-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 a1e9c1b..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,373 +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" - }, - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 2530741..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,415 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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" - }, - "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-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 5469d50..0000000 --- a/test/testdata/goldens/pipedream/include-regions-no-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,373 +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" - }, - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 cbc4ab2..0000000 --- a/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,349 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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-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 538dc03..0000000 --- a/test/testdata/goldens/pipedream/include-regions-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,312 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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..eb0cada --- /dev/null +++ b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_output-files.golden @@ -0,0 +1,126 @@ +{ + "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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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": 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" + } + }, + "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 + } + } + ] + } + } + } + } + ] + } + } + } +} 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..3fa463f --- /dev/null +++ b/test/testdata/goldens/pipedream/multi-region-group.jsonnet_single-file.golden @@ -0,0 +1,119 @@ +{ + "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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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": 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" + } + }, + "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 + } + } + ] + } + } + } + } + ] + } + } +} 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 6eecb42..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_output-files.golden +++ /dev/null @@ -1,647 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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-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": { - "fetch_materials": false, - "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" - }, - "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-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 cadc555..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-parallel.jsonnet_single-file.golden +++ /dev/null @@ -1,605 +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" - }, - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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 2244906..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_output-files.golden +++ /dev/null @@ -1,647 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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", - "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": { - "fetch_materials": false, - "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" - }, - "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-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 1c595dc..0000000 --- a/test/testdata/goldens/pipedream/no-autodeploy-serial.jsonnet_single-file.golden +++ /dev/null @@ -1,605 +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" - }, - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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", - "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": { - "fetch_materials": false, - "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..082b1ac --- /dev/null +++ b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_output-files.golden @@ -0,0 +1,272 @@ +{ + "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": { + "fetch_materials": false, + "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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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-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": { + "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-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": { + "fetch_materials": false, + "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" + }, + "fetch_materials": false, + "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..f1a07ed --- /dev/null +++ b/test/testdata/goldens/pipedream/parallel-mode.jsonnet_single-file.golden @@ -0,0 +1,250 @@ +{ + "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" + }, + "fetch_materials": false, + "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": { + "fetch_materials": false, + "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" + } + }, + "stages": [ + { + "deploy": { + "jobs": { + "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-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": { + "fetch_materials": false, + "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": { + "fetch_materials": false, + "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/rollback-final-stage-override.jsonnet_output-files.golden similarity index 69% rename from test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_output-files.golden rename to test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden index f9939fd..61f3ffb 100644 --- a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_output-files.golden +++ b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden @@ -1,61 +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-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": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "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": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -77,63 +51,33 @@ } } }, - "deploy-example-customer-4.yaml": { + "deploy-example-s4s2.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-4": { - "display_order": 6, + "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-4", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-s4s2": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=s4s2" } ] } } } - } - ] - } - } - }, - "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": { @@ -155,24 +99,61 @@ } } }, - "deploy-example-de.yaml": { + "deploy-example-st.yaml": { "format_version": 10, "pipelines": { - "deploy-example-de": { - "display_order": 3, + "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", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "de", "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": { @@ -194,24 +175,37 @@ } } }, - "deploy-example-s4s2.yaml": { + "deploy-example-us.yaml": { "format_version": 10, "pipelines": { - "deploy-example-s4s2": { - "display_order": 2, + "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "s4s2", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } }, { "pipeline-complete": { @@ -239,19 +233,19 @@ "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-s4s2 --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-s4s2 --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", - "stage": "pipeline-complete" + "deploy-example-st-deploy": { + "pipeline": "deploy-example-st", + "stage": "deploy" } }, "stages": [ @@ -262,7 +256,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" @@ -276,7 +270,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" @@ -293,7 +287,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-parallel.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden similarity index 68% rename from test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_single-file.golden rename to test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden index 709da48..3fae80f 100644 --- a/test/testdata/goldens/pipedream/exclude-regions-autodeploy-parallel.jsonnet_single-file.golden +++ b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden @@ -1,55 +1,34 @@ { "format_version": 10, "pipelines": { - "deploy-example-customer-1": { - "display_order": 4, + "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "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": { - "example_repo": { - "branch": "master", - "destination": "example", - "git": "git@github.com:getsentry/example.git", - "shallow_clone": true - } - }, - "region": "customer-2", - "stages": [ - { - "example_stage": { } }, { "pipeline-complete": { @@ -69,55 +48,30 @@ } ] }, - "deploy-example-customer-4": { - "display_order": 6, + "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "customer-4", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "deploy": { "jobs": { - "pipeline-complete": { + "deploy-s4s2": { + "elastic_profile_id": "example", "tasks": [ { - "exec": { - "command": true - } + "script": "./deploy.sh --region=s4s2" } ] } } } - } - ] - }, - "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": { @@ -137,21 +91,58 @@ } ] }, - "deploy-example-de": { - "display_order": 3, + "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", - "shallow_clone": true + "git": "git@github.com:getsentry/example.git" } }, - "region": "de", "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": { @@ -171,21 +162,34 @@ } ] }, - "deploy-example-s4s2": { - "display_order": 2, + "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 + "git": "git@github.com:getsentry/example.git" } }, - "region": "s4s2", "stages": [ { - "example_stage": { } + "deploy": { + "jobs": { + "deploy-us": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=us" + } + ] + } + } + } }, { "pipeline-complete": { @@ -208,19 +212,19 @@ "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-s4s2 --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-s4s2 --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", - "stage": "pipeline-complete" + "deploy-example-st-deploy": { + "pipeline": "deploy-example-st", + "stage": "deploy" } }, "stages": [ @@ -231,7 +235,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" @@ -245,7 +249,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" @@ -262,7 +266,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/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 b74795c..0000000 --- a/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_output-files.golden +++ /dev/null @@ -1,394 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "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-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 a3cda09..0000000 --- a/test/testdata/goldens/pipedream/rollback-override-final-stage.jsonnet_single-file.golden +++ /dev/null @@ -1,357 +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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "fetch_materials": false, - "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": { - "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", - "shallow_clone": true - } - }, - "region": "us", - "stages": [ - { - "example_stage": { } - }, - { - "other_stage": { } - }, - { - "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-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 68% 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 6c0aa86..3d98a09 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,69 +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-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": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "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": { @@ -85,28 +51,33 @@ } } }, - "deploy-example-customer-4.yaml": { + "deploy-example-s4s2.yaml": { "format_version": 10, "pipelines": { - "deploy-example-customer-4": { - "display_order": 6, + "deploy-example-s4s2": { + "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-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } }, { "pipeline-complete": { @@ -128,28 +99,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": { @@ -171,67 +175,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": { - "fetch_materials": false, + "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": { @@ -259,18 +233,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-s4s2 --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-s4s2 --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" } }, @@ -282,7 +256,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" @@ -296,7 +270,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" @@ -313,7 +287,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 69% 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 859cbf0..db31f0e 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,63 +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-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": "customer-1", "stages": [ { - "example_stage": { } - }, - { - "pipeline-complete": { - "fetch_materials": false, + "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": { @@ -77,25 +48,30 @@ } ] }, - "deploy-example-customer-4": { - "display_order": 6, + "deploy-example-s4s2": { + "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-s4s2": { + "elastic_profile_id": "example", + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } }, { "pipeline-complete": { @@ -115,25 +91,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": { @@ -153,59 +162,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": { - "fetch_materials": false, + "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": { @@ -228,18 +212,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-s4s2 --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-s4s2 --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" } }, @@ -251,7 +235,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" @@ -265,7 +249,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" @@ -282,7 +266,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/stage-props.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden new file mode 100644 index 0000000..064f382 --- /dev/null +++ b/test/testdata/goldens/pipedream/stage-props.jsonnet_output-files.golden @@ -0,0 +1,127 @@ +{ + "deploy-example-s4s2.yaml": { + "format_version": 10, + "pipelines": { + "deploy-example-s4s2": { + "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-s4s2": { + "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": 3, + "group": "example", + "materials": { + "deploy-example-s4s2-pipeline-complete": { + "pipeline": "deploy-example-s4s2", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "approval": { + "type": "manual" + }, + "fetch_materials": true, + "jobs": { + "deploy-customer-1": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "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..b7bffb8 --- /dev/null +++ b/test/testdata/goldens/pipedream/stage-props.jsonnet_single-file.golden @@ -0,0 +1,120 @@ +{ + "format_version": 10, + "pipelines": { + "deploy-example-s4s2": { + "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-s4s2": { + "tasks": [ + { + "script": "./deploy.sh --region=s4s2" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + }, + "deploy-example-st": { + "display_order": 3, + "group": "example", + "materials": { + "deploy-example-s4s2-pipeline-complete": { + "pipeline": "deploy-example-s4s2", + "stage": "pipeline-complete" + }, + "example_repo": { + "branch": "master", + "git": "git@github.com:getsentry/example.git" + } + }, + "stages": [ + { + "deploy": { + "approval": { + "type": "manual" + }, + "fetch_materials": true, + "jobs": { + "deploy-customer-1": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-1" + } + ] + }, + "deploy-customer-2": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-2" + } + ] + }, + "deploy-customer-4": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-4" + } + ] + }, + "deploy-customer-7": { + "tasks": [ + { + "script": "./deploy.sh --region=customer-7" + } + ] + } + } + } + }, + { + "pipeline-complete": { + "fetch_materials": false, + "jobs": { + "pipeline-complete": { + "tasks": [ + { + "exec": { + "command": true + } + } + ] + } + } + } + } + ] + } + } +}