Skip to content

Commit 8cf67eb

Browse files
authored
Merge pull request #7 from time-loop/Morgan-Szafranski/only-add-changed-stacks-to-the-diff
feat(inbox): Only render modified stacks in the diff output comment
2 parents 09a2068 + ed38519 commit 8cf67eb

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed

src/parsingLogic.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const STACK_REMOVAL_REGEX: [RegExp, string][] = [
1414
[new RegExp('^(.*)(\\w{64})(\\.zip)\n', 'gm'), ''],
1515
[
1616
new RegExp(
17-
'\\[~] Custom::AWS.*\\n.*Create.*\\n.*getParameter.*\\n.*getParameter.*\\n.*Update.*\\n.*getParameter.*\\n.*getParameter.*',
17+
'\\[~] Custom::AWS.*\\n.*Create.*\\n.*getParameter(.*)region.*\\n.*getParameter(\\1)region.*\\n.*Update.*\\n.*getParameter(\\1).*\\n.*getParameter(\\1).*',
1818
'gm',
1919
),
2020
'',
@@ -47,8 +47,11 @@ function rebuildDiffsIntoCdkLog(stacks: string[]) {
4747
const stackName = stack.match(new RegExp('(^Stack .*)', 'gm'))?.[0] ?? '';
4848
const stackDetails = stack.replace(new RegExp('(^Stack .*)\n', 'gm'), '');
4949
const cleanStackDetails = cleanCDKDiffForSingleStack(stackDetails);
50-
cdkLogParts.push(stackName);
51-
cdkLogParts.push(`${cleanStackDetails}\n`);
50+
51+
if (!cleanStackDetails.includes('There were no differences')) {
52+
cdkLogParts.push(stackName);
53+
cdkLogParts.push(`${cleanStackDetails}\n`);
54+
}
5255
}
5356
return cdkLogParts.join('\n');
5457
}

test/__snapshots__/cdkLogParser.test.ts.snap

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

test/cdkLogParser.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ describe('getParsedStacks', () => {
1818
const parsedStacks = getParsedStacks(cdkDiffLogContent);
1919
expect(parsedStacks).toMatchSnapshot();
2020
});
21+
22+
test('should NOT remove SSM diffs if the SSM name/path changes', () => {
23+
const cdkDiffLogContent = loadCdkDiffLog('test/data/changedSSM.txt');
24+
const parsedStacks = getParsedStacks(cdkDiffLogContent);
25+
expect(parsedStacks).toMatchSnapshot();
26+
});
2127
});

test/data/changedSSM.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Done in 0.14s.
2+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalDailyDueDateSummaryEmailInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-daily-due-date-summary-email-r; using truncated name: cu-staging-staging-us-east-2-1-iv-daily-due-date-summary-email-r
3+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalDashboardsTaskStatesInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-dashboards-task-states-redeplo; using truncated name: cu-staging-staging-us-east-2-1-iv-dashboards-task-states-redeplo
4+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalDescriptionProcessorInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-description-processor-redeploy; using truncated name: cu-staging-staging-us-east-2-1-iv-description-processor-redeploy
5+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalDesktopNotificationsInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-desktop-notifications-redeploy; using truncated name: cu-staging-staging-us-east-2-1-iv-desktop-notifications-redeploy
6+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalGcalDeleteInactiveSyncsInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-gcal-delete-inactive-syncs-red; using truncated name: cu-staging-staging-us-east-2-1-iv-gcal-delete-inactive-syncs-red
7+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalGcalQueueSchedulersInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-gcal-queue-schedulers-redeploy; using truncated name: cu-staging-staging-us-east-2-1-iv-gcal-queue-schedulers-redeploy
8+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalGcalRemoveSyncEventsInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-gcal-remove-sync-events-redepl; using truncated name: cu-staging-staging-us-east-2-1-iv-gcal-remove-sync-events-redepl
9+
[Warning at /ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalGcalSyncFromGoogleInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-iv-gcal-sync-from-google-redeploy; using truncated name: cu-staging-staging-us-east-2-1-iv-gcal-sync-from-google-redeploy
10+
[Warning at /ClickupEcsRegionalPipeline/EcsGlobalStagingStagingUsEast21CommonWorkerBrowserNotificationsInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-worker-browser-notifications-rede; using truncated name: cu-staging-staging-us-east-2-1-worker-browser-notifications-rede
11+
[Warning at /ClickupEcsRegionalPipeline/EcsGlobalStagingStagingUsEast21CommonWorkerDescriptionProcessorInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-worker-description-processor-rede; using truncated name: cu-staging-staging-us-east-2-1-worker-description-processor-rede
12+
[Warning at /ClickupEcsShardWorkerPipeline/EcsGlobalStagingStagingUsEast21ShardWorkerDueDateSummariesInstance/Instance] Requested name is too long: cu-staging-staging-us-east-2-1-worker-due-date-summaries-redeplo; using truncated name: cu-staging-staging-us-east-2-1-worker-due-date-summaries-redeplo
13+
Stack ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance/Instance (EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance-Instance)
14+
current credentials could not be used to assume 'arn:aws:iam::514308641592:role/cdk-hnb659fds-lookup-role-514308641592-us-east-2', but are for the right account. Proceeding anyway.
15+
(To get rid of this warning, please upgrade to bootstrap version >= 8)
16+
current credentials could not be used to assume 'arn:aws:iam::514308641592:role/cdk-hnb659fds-deploy-role-514308641592-us-east-2', but are for the right account. Proceeding anyway.
17+
Resources
18+
[~] Custom::AWS EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance/Instance/EcsGlobalStagingStagingUsEast21UserRemote/Resource EcsGlobalStagingStagingUsEast21UserRemote8B37113E
19+
├─ [~] Create
20+
│ ├─ [-] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/DeployGlobalStagingUserArn"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1676068626875"}}
21+
│ └─ [+] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/NewSSMName"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1677023202895"}}
22+
└─ [~] Update
23+
├─ [-] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/DeployGlobalStagingUserArn"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1676068626875"}}
24+
└─ [+] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/NewSSMName"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1677023202895"}}
25+
[~] AWS::Lambda::Function EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance/Instance/AWS679f53fac002430cb0da5b7982bd2287 AWS679f53fac002430cb0da5b7982bd22872D164C4C
26+
└─ [~] Metadata
27+
└─ [~] .aws:asset:path:
28+
├─ [-] ../asset.400f664767ec04a0966c8d688fa643ee8f6d0c94c8d91a71d3af814cc9b9e6ab
29+
└─ [+] /home/runner/work/clickup-ecs-cdk/clickup-ecs-cdk/node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime

0 commit comments

Comments
 (0)