Skip to content

Commit 670ace5

Browse files
author
Cliff Odijk
committed
Verwijder de destrictive check
1 parent 319181f commit 670ace5

8 files changed

Lines changed: 18 additions & 135 deletions

File tree

.projenrc.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@ const project = new GitHubActionTypeScriptProject({
4545
description: 'github token',
4646
required: true,
4747
},
48-
allowedDestroyTypes: {
49-
description:
50-
'Comma delimited list of resource types that are allowed to be destroyed',
51-
required: false,
52-
default: '',
53-
},
54-
failOnDestructiveChanges: {
55-
description: 'Whether or not destructive changes should fail the job',
56-
required: false,
57-
default: 'true',
58-
},
5948
stackSelectorPatterns: {
6049
description:
6150
'Comma delimited list of stack selector patterns. Use this to control which stages/stacks to diff. By default all stages & stacks are diffed\n\n' +
@@ -76,12 +65,6 @@ const project = new GitHubActionTypeScriptProject({
7665
default: 'all-stacks',
7766
required: false,
7867
},
79-
noFailOnDestructiveChanges: {
80-
description:
81-
'List of stages where breaking changes will not fail the build',
82-
required: false,
83-
default: '',
84-
},
8568
cdkOutDirs: {
8669
description: [
8770
'Glob pattern to find CDK output directories to diff.',

action.yml

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 9 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/action.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
getInput,
3-
getBooleanInput,
43
getMultilineInput,
54
debug,
65
} from '@actions/core';
@@ -51,9 +50,8 @@ function hasGitChanges(directory: string, baseRef: string): boolean {
5150
const hasChanges = result.trim().length > 0;
5251
debug(`Directory ${projectDir} has changes against ${baseRef}: ${hasChanges}`);
5352

54-
if (hasChanges) {
55-
debug(`Changed files in ${projectDir}:\n${result}`);
56-
}
53+
// Always show git diff output for debugging purposes
54+
debug(`Git diff output for ${projectDir}:\n${result || '(no changes)'}`);
5755

5856
return hasChanges;
5957
} catch (error) {
@@ -102,15 +100,11 @@ export async function run() {
102100
defaultStageDisplayName: getInput('defaultStageDisplayName', {
103101
required: true,
104102
}),
105-
allowedDestroyTypes: getMultilineInput('allowedDestroyTypes'),
106-
failOnDestructiveChanges: getBooleanInput('failOnDestructiveChanges'),
107103
githubToken: getInput('githubToken'),
108104
stackSelectorPatterns: getMultilineInput('stackSelectorPatterns'),
109105
stackSelectionStrategy: getInput('stackSelectionStrategy', {
110106
required: true,
111107
}),
112-
noFailOnDestructiveChanges: getMultilineInput('noFailOnDestructiveChanges'),
113-
cdkOutDirs: cdkOutDirs,
114108
baseRef: baseRef,
115109
diffMethod: getInput('diffMethod', { required: true }),
116110
};
@@ -138,9 +132,8 @@ export async function run() {
138132
: DiffMethod.ChangeSet();
139133
try {
140134
const comments = new Comments(octokit, context);
141-
let hasAnyDestructiveChanges = false;
142135

143-
for (const cdkOutDir of inputs.cdkOutDirs) {
136+
for (const cdkOutDir of cdkOutDirs) {
144137
debug(`Processing CDK output directory: ${cdkOutDir}`);
145138
const processor = new AssemblyProcessor({
146139
...inputs,
@@ -149,7 +142,7 @@ export async function run() {
149142
toolkit,
150143
});
151144
try {
152-
await processor.processStages(inputs.noFailOnDestructiveChanges);
145+
await processor.processStages();
153146
} catch (e: any) {
154147
console.error(`Error running process stages for ${cdkOutDir}: `, e);
155148
throw e;
@@ -161,16 +154,6 @@ export async function run() {
161154
console.error(`Error commenting stages for ${cdkOutDir}: `, e);
162155
throw e;
163156
}
164-
165-
if (processor.hasDestructiveChanges) {
166-
hasAnyDestructiveChanges = true;
167-
}
168-
}
169-
170-
if (hasAnyDestructiveChanges && inputs.failOnDestructiveChanges) {
171-
throw new Error(
172-
'There are destructive changes! See PR comment for details.',
173-
);
174157
}
175158
} catch (e: any) {
176159
console.error('Error performing diff: ', e);

src/inputs.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,6 @@ export interface Inputs {
77
*/
88
githubToken: string;
99

10-
/**
11-
* A list of CloudFormation resource types that are allowed
12-
* to be destroyed.
13-
*
14-
* @default - there are no allowed destroy types
15-
*/
16-
allowedDestroyTypes: string[];
17-
18-
/**
19-
* Whether the workflow will fail if there are any non-allowed
20-
* destructive changes
21-
*
22-
* @default true
23-
*/
24-
failOnDestructiveChanges: boolean;
2510

2611
/**
2712
* List of stack selector patterns
@@ -56,20 +41,6 @@ export interface Inputs {
5641
*/
5742
diffMethod: string;
5843

59-
/**
60-
* List of stages where breaking changes will not fail the build
61-
*
62-
* @default - breaking changes on any stage will fail the build
63-
*/
64-
noFailOnDestructiveChanges: string[];
65-
66-
/**
67-
* The locations of the CDK output directories
68-
*
69-
* @default ['cdk.out']
70-
*/
71-
cdkOutDirs: string[];
72-
7344
/**
7445
* Git reference to compare against for detecting changes
7546
*

src/stage-processor.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface StageComment {
4444
}
4545

4646
export interface AssemblyProcessorOptions
47-
extends Omit<Inputs, 'githubToken' | 'diffMethod' | 'cdkOutDirs'> {
47+
extends Omit<Inputs, 'githubToken' | 'diffMethod'> {
4848
cdkOutDir: string;
4949
diffMethod: DiffMethod;
5050
toolkit: Toolkit;
@@ -181,24 +181,21 @@ export class AssemblyProcessor {
181181
* Process all of the stages. Once this has been run
182182
* the comment can be created with `commentStages()`
183183
*/
184-
public async processStages(ignoreDestructiveChanges: string[] = []) {
184+
public async processStages() {
185185
if (!this._templateDiffs) {
186186
await this.diffApp();
187187
}
188188
debug(`Diffs: ${JSON.stringify(this._templateDiffs, null, 2)}`);
189189
for (const stage of this.stageDiffInfo) {
190190
for (const stack of stage.stacks) {
191191
try {
192-
const { comment, changes } = await this.diffStack(stack);
192+
const { comment } = await this.diffStack(stack);
193193
debug(
194194
`Diff for stack ${stack.stackName}: ${JSON.stringify(comment, null, 2)}`,
195195
);
196196
this.stageComments[stage.name].stackComments[stack.stackName].push(
197197
...comment,
198198
);
199-
if (!ignoreDestructiveChanges.includes(stage.name)) {
200-
this.stageComments[stage.name].destructiveChanges += changes;
201-
}
202199
} catch (e: any) {
203200
console.error('Error processing stages: ', e);
204201
throw e;
@@ -317,23 +314,12 @@ export class AssemblyProcessor {
317314
}
318315
}
319316

320-
/**
321-
* Returns whether or not there are destructive changes in this stage
322-
*/
323-
public get hasDestructiveChanges(): boolean {
324-
for (const comments of Object.values(this.stageComments)) {
325-
if (comments.destructiveChanges) {
326-
return true;
327-
}
328-
}
329-
return false;
330-
}
331317

332318
private async diffStack(
333319
stack: StackDiffInfo,
334320
): Promise<{ comment: string[]; changes: number }> {
335321
try {
336-
const stackDiff = new StackDiff(stack, this.options.allowedDestroyTypes);
322+
const stackDiff = new StackDiff(stack, []);
337323
const { diff, changes } = await stackDiff.diffStack();
338324
return {
339325
comment: this.formatStackComment(stack.stackName, diff, changes),

test/stage-processor.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ describe('StageProcessor', () => {
169169
expect(
170170
p.SomeStage.stackComments['SomeStage/test-stack'].length,
171171
).not.toEqual(0);
172-
expect(p.SomeStage.destructiveChanges).toEqual(1);
173172
});
174173

175174
test('stage with destructive changes-ignored', async () => {
@@ -396,7 +395,6 @@ describe('StageProcessor', () => {
396395
expect(p.SomeStage.stackComments['SomeOtherStage/test-stack']).toEqual(
397396
undefined,
398397
);
399-
expect(p.SomeStage.destructiveChanges).toEqual(1);
400398
});
401399
});
402400

0 commit comments

Comments
 (0)