Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/stage-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,13 @@ export class AssemblyProcessor {
}

private getEmoji(changes: ChangeDetails): string {
if (changes.destructiveChanges.length || changes.removedResources) {
// Only flag the stack with :x: for destructive changes that survived
// allowedDestroyTypes filtering. Removals of allowed types (e.g. the
// AWS::ApiGateway::Deployment roll CDK performs on every API change)
// are routine churn and render as :yellow_circle: like other updates.
if (changes.destructiveChanges.length) {
return ':x:';
} else if (changes.updatedResources) {
} else if (changes.updatedResources || changes.removedResources) {
return ':yellow_circle:';
} else if (changes.createdResources) {
return ':sparkle:';
Expand Down
80 changes: 80 additions & 0 deletions test/stage-processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,86 @@ describe('StageProcessor', () => {
expect(p.SomeStage.destructiveChanges).toEqual(0);
});

test('removal of an allowed destroy type renders yellow, not x', async () => {
// "deployed" template has an extra queue that the assembly no longer has
mockOutDir['SomeStage-test-stack.template.json'] = JSON.stringify({
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Properties: {
RoleName: 'MyCustomName',
},
},
MyQueue: {
Type: 'AWS::SQS::Queue',
},
},
});
mock({
'cdk.out': mockOutDir,
node_modules: mock.load(path.join(__dirname, '..', 'node_modules')),
});
const processor = new AssemblyProcessor({
defaultStageDisplayName: 'DefaultStage',
toolkit,
allowedDestroyTypes: ['AWS::SQS::Queue'],
cdkOutDir: 'cdk.out',
diffMethod: DiffMethod.LocalFile(
'cdk.out/SomeStage-test-stack.template.json',
),
failOnDestructiveChanges: true,
stackSelectorPatterns: [],
stackSelectionStrategy: 'all-stacks',
noFailOnDestructiveChanges: [],
});
await processor.processStages();
const p = (processor as any).stageComments;
expect(p.SomeStage.destructiveChanges).toEqual(0);
const comment =
p.SomeStage.stackComments['SomeStage/test-stack'].join('\n');
expect(comment).toContain(':yellow_circle:');
expect(comment).not.toContain(':x:');
});

test('removal of a non-allowed type still renders x', async () => {
mockOutDir['SomeStage-test-stack.template.json'] = JSON.stringify({
Resources: {
MyRole: {
Type: 'AWS::IAM::Role',
Properties: {
RoleName: 'MyCustomName',
},
},
MyQueue: {
Type: 'AWS::SQS::Queue',
},
},
});
mock({
'cdk.out': mockOutDir,
node_modules: mock.load(path.join(__dirname, '..', 'node_modules')),
});
const processor = new AssemblyProcessor({
defaultStageDisplayName: 'DefaultStage',
toolkit,
allowedDestroyTypes: [],
cdkOutDir: 'cdk.out',
diffMethod: DiffMethod.LocalFile(
'cdk.out/SomeStage-test-stack.template.json',
),
failOnDestructiveChanges: true,
stackSelectorPatterns: [],
stackSelectionStrategy: 'all-stacks',
noFailOnDestructiveChanges: [],
});
await processor.processStages();
const p = (processor as any).stageComments;
expect(p.SomeStage.destructiveChanges).toEqual(1);
const comment =
p.SomeStage.stackComments['SomeStage/test-stack'].join('\n');
expect(comment).toContain(':x:');
});

test('new comment created', async () => {
mockOutDir['SomeStage-test-stack.template.json'] = JSON.stringify({
Resources: {
Expand Down
Loading