Skip to content

Commit

Permalink
Merge pull request #7 from time-loop/Morgan-Szafranski/only-add-chang…
Browse files Browse the repository at this point in the history
…ed-stacks-to-the-diff

feat(inbox): Only render modified stacks in the diff output comment
  • Loading branch information
m-szaf authored Feb 24, 2023
2 parents 09a2068 + ed38519 commit 8cf67eb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 48 deletions.
9 changes: 6 additions & 3 deletions src/parsingLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const STACK_REMOVAL_REGEX: [RegExp, string][] = [
[new RegExp('^(.*)(\\w{64})(\\.zip)\n', 'gm'), ''],
[
new RegExp(
'\\[~] Custom::AWS.*\\n.*Create.*\\n.*getParameter.*\\n.*getParameter.*\\n.*Update.*\\n.*getParameter.*\\n.*getParameter.*',
'\\[~] Custom::AWS.*\\n.*Create.*\\n.*getParameter(.*)region.*\\n.*getParameter(\\1)region.*\\n.*Update.*\\n.*getParameter(\\1).*\\n.*getParameter(\\1).*',
'gm',
),
'',
Expand Down Expand Up @@ -47,8 +47,11 @@ function rebuildDiffsIntoCdkLog(stacks: string[]) {
const stackName = stack.match(new RegExp('(^Stack .*)', 'gm'))?.[0] ?? '';
const stackDetails = stack.replace(new RegExp('(^Stack .*)\n', 'gm'), '');
const cleanStackDetails = cleanCDKDiffForSingleStack(stackDetails);
cdkLogParts.push(stackName);
cdkLogParts.push(`${cleanStackDetails}\n`);

if (!cleanStackDetails.includes('There were no differences')) {
cdkLogParts.push(stackName);
cdkLogParts.push(`${cleanStackDetails}\n`);
}
}
return cdkLogParts.join('\n');
}
Expand Down
63 changes: 18 additions & 45 deletions test/__snapshots__/cdkLogParser.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/cdkLogParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ describe('getParsedStacks', () => {
const parsedStacks = getParsedStacks(cdkDiffLogContent);
expect(parsedStacks).toMatchSnapshot();
});

test('should NOT remove SSM diffs if the SSM name/path changes', () => {
const cdkDiffLogContent = loadCdkDiffLog('test/data/changedSSM.txt');
const parsedStacks = getParsedStacks(cdkDiffLogContent);
expect(parsedStacks).toMatchSnapshot();
});
});
29 changes: 29 additions & 0 deletions test/data/changedSSM.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Done in 0.14s.
[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
[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
[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
[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
[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
[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
[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
[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
[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
[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
[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
Stack ClickupEcsGlobalIntervalPipeline/EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance/Instance (EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance-Instance)
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.
(To get rid of this warning, please upgrade to bootstrap version >= 8)
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.
Resources
[~] Custom::AWS EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance/Instance/EcsGlobalStagingStagingUsEast21UserRemote/Resource EcsGlobalStagingStagingUsEast21UserRemote8B37113E
├─ [~] Create
│ ├─ [-] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/DeployGlobalStagingUserArn"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1676068626875"}}
│ └─ [+] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/NewSSMName"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1677023202895"}}
└─ [~] Update
├─ [-] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/DeployGlobalStagingUserArn"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1676068626875"}}
└─ [+] {"service":"SSM","action":"getParameter","parameters":{"Name":"/ClickUpEcs/Deploy/DeployUser/NewSSMName"},"region":"us-east-1","physicalResourceId":{"id":"timestamp1677023202895"}}
[~] AWS::Lambda::Function EcsGlobalStagingStagingUsEast21GlobalIntervalAutomationInstance/Instance/AWS679f53fac002430cb0da5b7982bd2287 AWS679f53fac002430cb0da5b7982bd22872D164C4C
└─ [~] Metadata
└─ [~] .aws:asset:path:
├─ [-] ../asset.400f664767ec04a0966c8d688fa643ee8f6d0c94c8d91a71d3af814cc9b9e6ab
└─ [+] /home/runner/work/clickup-ecs-cdk/clickup-ecs-cdk/node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime

0 comments on commit 8cf67eb

Please sign in to comment.