@@ -207,6 +207,180 @@ test("ensure exclude regions removes regions with trigger pipeline", async (t) =
207207 ) ;
208208} ) ;
209209
210+ test ( "ensure include regions adds regions without trigger pipeline" , async ( t ) => {
211+ const got = await render_fixture ( "pipedream/include-regions.jsonnet" , false ) ;
212+
213+ t . deepEqual ( Object . keys ( got . pipelines ) . sort ( ) , [
214+ "deploy-example-control" ,
215+ "deploy-example-customer-1" ,
216+ "deploy-example-customer-2" ,
217+ "deploy-example-customer-4" ,
218+ "deploy-example-customer-7" ,
219+ "deploy-example-de" ,
220+ "rollback-example" ,
221+ ] ) ;
222+
223+ // Ensure de has just the repo material
224+ const de = got . pipelines [ "deploy-example-de" ] ;
225+ t . deepEqual ( de . materials , {
226+ example_repo : {
227+ branch : "master" ,
228+ destination : "example" ,
229+ git : "git@github.com:getsentry/example.git" ,
230+ shallow_clone : true ,
231+ } ,
232+ } ) ;
233+
234+ // Ensure control is included
235+ const control = got . pipelines [ "deploy-example-control" ] ;
236+ t . deepEqual ( control . materials , {
237+ "deploy-example-de-pipeline-complete" : {
238+ pipeline : "deploy-example-de" ,
239+ stage : "pipeline-complete" ,
240+ } ,
241+ example_repo : {
242+ branch : "master" ,
243+ destination : "example" ,
244+ git : "git@github.com:getsentry/example.git" ,
245+ shallow_clone : true ,
246+ } ,
247+ } ) ;
248+
249+ // Ensure customer-1 depends on control
250+ const c1 = got . pipelines [ "deploy-example-customer-1" ] ;
251+ t . deepEqual ( c1 . materials , {
252+ "deploy-example-control-pipeline-complete" : {
253+ pipeline : "deploy-example-control" ,
254+ stage : "pipeline-complete" ,
255+ } ,
256+ example_repo : {
257+ branch : "master" ,
258+ destination : "example" ,
259+ git : "git@github.com:getsentry/example.git" ,
260+ shallow_clone : true ,
261+ } ,
262+ } ) ;
263+
264+ // Ensure customer-2 has pipeline material too
265+ const c2 = got . pipelines [ "deploy-example-customer-2" ] ;
266+ t . deepEqual ( c2 . materials , {
267+ "deploy-example-customer-1-pipeline-complete" : {
268+ pipeline : "deploy-example-customer-1" ,
269+ stage : "pipeline-complete" ,
270+ } ,
271+ example_repo : {
272+ branch : "master" ,
273+ destination : "example" ,
274+ git : "git@github.com:getsentry/example.git" ,
275+ shallow_clone : true ,
276+ } ,
277+ } ) ;
278+
279+ // Ensure rollback has the expected rollback pipelines
280+ const r = got . pipelines [ "rollback-example" ] ;
281+ const allPipelines = r . environment_variables [ "ALL_PIPELINE_FLAGS" ] ;
282+ const regionPipelines = r . environment_variables [ "REGION_PIPELINE_FLAGS" ] ;
283+ t . deepEqual (
284+ allPipelines ,
285+ "--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" ,
286+ ) ;
287+ t . deepEqual (
288+ regionPipelines ,
289+ "--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" ,
290+ ) ;
291+ } ) ;
292+
293+ test ( "ensure include regions adds regions with trigger pipeline" , async ( t ) => {
294+ const got = await render_fixture (
295+ "pipedream/include-regions-no-autodeploy.jsonnet" ,
296+ false ,
297+ ) ;
298+
299+ t . deepEqual ( Object . keys ( got . pipelines ) . sort ( ) , [
300+ "deploy-example" ,
301+ "deploy-example-control" ,
302+ "deploy-example-customer-1" ,
303+ "deploy-example-customer-2" ,
304+ "deploy-example-customer-4" ,
305+ "deploy-example-customer-7" ,
306+ "deploy-example-de" ,
307+ "rollback-example" ,
308+ ] ) ;
309+
310+ // Ensure de has just the repo material
311+ const de = got . pipelines [ "deploy-example-de" ] ;
312+ t . deepEqual ( de . materials , {
313+ "deploy-example-pipeline-complete" : {
314+ pipeline : "deploy-example" ,
315+ stage : "pipeline-complete" ,
316+ } ,
317+ example_repo : {
318+ branch : "master" ,
319+ destination : "example" ,
320+ git : "git@github.com:getsentry/example.git" ,
321+ shallow_clone : true ,
322+ } ,
323+ } ) ;
324+
325+ // Ensure control is included
326+ const control = got . pipelines [ "deploy-example-control" ] ;
327+ t . deepEqual ( control . materials , {
328+ "deploy-example-de-pipeline-complete" : {
329+ pipeline : "deploy-example-de" ,
330+ stage : "pipeline-complete" ,
331+ } ,
332+ example_repo : {
333+ branch : "master" ,
334+ destination : "example" ,
335+ git : "git@github.com:getsentry/example.git" ,
336+ shallow_clone : true ,
337+ } ,
338+ } ) ;
339+
340+ // Ensure customer-1 depends on control
341+ const c1 = got . pipelines [ "deploy-example-customer-1" ] ;
342+ t . deepEqual ( c1 . materials , {
343+ "deploy-example-control-pipeline-complete" : {
344+ pipeline : "deploy-example-control" ,
345+ stage : "pipeline-complete" ,
346+ } ,
347+ example_repo : {
348+ branch : "master" ,
349+ destination : "example" ,
350+ git : "git@github.com:getsentry/example.git" ,
351+ shallow_clone : true ,
352+ } ,
353+ } ) ;
354+
355+ // Ensure customer-2 has pipeline material too
356+ const c2 = got . pipelines [ "deploy-example-customer-2" ] ;
357+ t . deepEqual ( c2 . materials , {
358+ "deploy-example-customer-1-pipeline-complete" : {
359+ pipeline : "deploy-example-customer-1" ,
360+ stage : "pipeline-complete" ,
361+ } ,
362+ example_repo : {
363+ branch : "master" ,
364+ destination : "example" ,
365+ git : "git@github.com:getsentry/example.git" ,
366+ shallow_clone : true ,
367+ } ,
368+ } ) ;
369+
370+ // Ensure rollback has the expected rollback pipelines
371+ const r = got . pipelines [ "rollback-example" ] ;
372+ const allPipelines = r . environment_variables [ "ALL_PIPELINE_FLAGS" ] ;
373+ const regionPipelines = r . environment_variables [ "REGION_PIPELINE_FLAGS" ] ;
374+ t . deepEqual (
375+ allPipelines ,
376+ "--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" ,
377+ ) ;
378+ t . deepEqual (
379+ regionPipelines ,
380+ "--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" ,
381+ ) ;
382+ } ) ;
383+
210384test ( "error for invalid final rollback stage" , async ( t ) => {
211385 const err = t . throws ( ( ) =>
212386 get_fixture_content (
0 commit comments