Skip to content

Commit

Permalink
fix(pipelines): wrong runOrder for manual approval when using `extraR…
Browse files Browse the repository at this point in the history
…unOrderSpace` (#11511)

The manual approval action should be right after the Prepare ChangeSet. Fixes #11510


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
adriantaut authored Nov 19, 2020
1 parent ea875b4 commit 9b72fc8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/pipelines/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class CdkStage extends CoreConstruct {
// now is where we add a manual approval step, and we allocate 1 more runOrder
// for the execute.
if (options.manualApprovals) {
this.addManualApprovalAction({ runOrder: executeRunOrder });
this.addManualApprovalAction({ runOrder: runOrder + 1 });
executeRunOrder = this.nextSequentialRunOrder();
}

Expand Down
37 changes: 37 additions & 0 deletions packages/@aws-cdk/pipelines/test/stack-ordering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,43 @@ test('extra space for sequential intermediary actions is reserved', () => {
});
});

test('combination of manual approval and extraRunOrderSpace', () => {
// WHEN
pipeline.addApplicationStage(new OneStackApp(app, 'MyApp'), {
extraRunOrderSpace: 1,
manualApprovals: true,
});

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodePipeline::Pipeline', {
Stages: arrayWith({
Name: 'MyApp',
Actions: sortedByRunOrder([
objectLike({
Name: 'Stack1.Prepare',
RunOrder: 1,
}),
objectLike({
Name: 'ManualApproval',
RunOrder: 2,
}),
objectLike({
Name: 'Stack1.Deploy',
RunOrder: 4,
}),
]),
}),
});
});

class OneStackApp extends Stage {
constructor(scope: Construct, id: string, props?: StageProps) {
super(scope, id, props);

new BucketStack(this, 'Stack1');
}
}

class TwoStackApp extends Stage {
constructor(scope: Construct, id: string, props?: StageProps) {
super(scope, id, props);
Expand Down

0 comments on commit 9b72fc8

Please sign in to comment.