diff --git a/src/clickup-cdk.ts b/src/clickup-cdk.ts index 8ff67258..7c8276ca 100644 --- a/src/clickup-cdk.ts +++ b/src/clickup-cdk.ts @@ -17,6 +17,10 @@ import { slackAlert } from './slack-alert'; import { updateProjen } from './update-projen'; export module clickupCdk { + // https://github.com/time-loop/cdk-ecs-fargate/pull/476 + const minCdkVersion = '2.137.0'; + const defaultCdkVersion = '2.137.0'; // Arbitrary newish version. Most developers will want the latest. + export const deps = [ ...clickupTs.deps, '@time-loop/cdk-library', @@ -205,16 +209,14 @@ export module clickupCdk { throw new Error('pnpm not supported by cdkPipelines: https://staging.clickup.com/t/333/CLK-252116'); } - // AWS turned off node12 support. cdk changed the node version for their asset bundling in - // https://github.com/aws/aws-cdk/releases/tag/v2.64.0 - // This cdkVersion is actually the minimum version that's compatible. It only affects devDeps. + // This cdkVersion is actually the minimum version that's compatible. This only affects devDeps. // This really only affects users when they try to deploy directly from their laptop. // When deploying from cdkPipelines, it will use whatever version the library is currently on per yarn.lock. let cdkVersion = undefined; - if (semver.lt(options.cdkVersion, '2.64.0')) { - cdkVersion = '2.87.0'; // Arbitrary newish version. Most developers will want the latest. + if (semver.lt(options.cdkVersion, minCdkVersion)) { + cdkVersion = defaultCdkVersion; console.warn( - `Your cdkVersion of ${options.cdkVersion} is less than 2.64.0. We recommend using latest, which you can find at https://github.com/aws/aws-cdk/releases . Until you explicitly set something, we are pushing to ${cdkVersion}`, + `Your cdkVersion of ${options.cdkVersion} is less than ${minCdkVersion}. We recommend using latest, which you can find at https://github.com/aws/aws-cdk/releases . Until you explicitly set something the is compliant, we are pushing to ${defaultCdkVersion}`, ); } diff --git a/test/__snapshots__/cdk-context-json.test.ts.snap b/test/__snapshots__/cdk-context-json.test.ts.snap index dbe92fc9..bde2feb3 100644 --- a/test/__snapshots__/cdk-context-json.test.ts.snap +++ b/test/__snapshots__/cdk-context-json.test.ts.snap @@ -16,7 +16,7 @@ export class GitHubActionsOIDCCdkContextLookupRole extends core.Stack { })(); } constructor(scope: Construct, props: core.StackProps) { - const projectName = 'foo'; + const projectName = 'test'; // NOTE: you should never deploy this anywhere but the cdkPipelines account // And the GitHubActionsOIDCPermissions class for cdk-diff should never be deployed // in the cdkPipelines account. Name collision is intentional here. @@ -80,7 +80,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v2 with: aws-region: us-west-2 - role-to-assume: arn:aws:iam::123412341234:role/foo-github-actions-role + role-to-assume: arn:aws:iam::123412341234:role/test-github-actions-role role-duration-seconds: 900 - name: Checkout uses: actions/checkout@v4 diff --git a/test/__snapshots__/clickup-cdk.test.ts.snap b/test/__snapshots__/clickup-cdk.test.ts.snap index 841e2513..ccff9da2 100644 --- a/test/__snapshots__/clickup-cdk.test.ts.snap +++ b/test/__snapshots__/clickup-cdk.test.ts.snap @@ -13,7 +13,7 @@ exports[`ClickUpCdkConstructLibrary defaults package.json 1`] = ` "@types/node": "^18", "@typescript-eslint/eslint-plugin": "^6", "@typescript-eslint/parser": "^6", - "aws-cdk-lib": "2.91.0", + "aws-cdk-lib": "2.135.0", "constructs": "10.0.5", "esbuild": "*", "eslint": "^8", @@ -99,7 +99,7 @@ exports[`ClickUpCdkConstructLibrary defaults package.json 1`] = ` "main": "lib/index.js", "name": "@time-loop/test", "peerDependencies": { - "aws-cdk-lib": "^2.91.0", + "aws-cdk-lib": "^2.135.0", "constructs": "^10.0.5", }, "publishConfig": { @@ -509,7 +509,7 @@ exports[`ClickUpCdkTypeScriptApp defaults package.json 1`] = ` "@time-loop/cdk-library": "*", "@time-loop/cdk-named-environments": "*", "@time-loop/clickup-projen": "*", - "aws-cdk-lib": "^2.91.0", + "aws-cdk-lib": "^2.137.0", "cdk-constants": "*", "constructs": "^10.0.5", "multi-convention-namer": "*", @@ -520,7 +520,7 @@ exports[`ClickUpCdkTypeScriptApp defaults package.json 1`] = ` "@types/node": "^18", "@typescript-eslint/eslint-plugin": "^6", "@typescript-eslint/parser": "^6", - "aws-cdk": "^2.91.0", + "aws-cdk": "^2.137.0", "esbuild": "*", "eslint": "^8", "eslint-config-prettier": "*", @@ -971,7 +971,7 @@ exports[`ClickUpCdkTypeScriptApp options node20 package.json 1`] = ` "@time-loop/cdk-library": "*", "@time-loop/cdk-named-environments": "*", "@time-loop/clickup-projen": "*", - "aws-cdk-lib": "^2.91.0", + "aws-cdk-lib": "^2.137.0", "cdk-constants": "*", "constructs": "^10.0.5", "multi-convention-namer": "*", @@ -982,7 +982,7 @@ exports[`ClickUpCdkTypeScriptApp options node20 package.json 1`] = ` "@types/node": "^20", "@typescript-eslint/eslint-plugin": "^6", "@typescript-eslint/parser": "^6", - "aws-cdk": "^2.91.0", + "aws-cdk": "^2.137.0", "esbuild": "*", "eslint": "^8", "eslint-config-prettier": "*", @@ -1095,7 +1095,7 @@ exports[`cdk-diff additions - ClickUpCdkTypeScriptApp package.json 1`] = ` "@time-loop/cdk-library": "*", "@time-loop/cdk-named-environments": "*", "@time-loop/clickup-projen": "*", - "aws-cdk-lib": "^2.91.0", + "aws-cdk-lib": "^2.137.0", "cdk-constants": "*", "constructs": "^10.0.5", "multi-convention-namer": "*", @@ -1107,7 +1107,7 @@ exports[`cdk-diff additions - ClickUpCdkTypeScriptApp package.json 1`] = ` "@types/node": "^18", "@typescript-eslint/eslint-plugin": "^6", "@typescript-eslint/parser": "^6", - "aws-cdk": "^2.91.0", + "aws-cdk": "^2.137.0", "esbuild": "*", "eslint": "^8", "eslint-config-prettier": "*", diff --git a/test/cdk-context-json.test.ts b/test/cdk-context-json.test.ts index 3aed0119..3bff4853 100644 --- a/test/cdk-context-json.test.ts +++ b/test/cdk-context-json.test.ts @@ -1,12 +1,9 @@ import { awscdk, Testing } from 'projen'; +import { requiredParams } from './requiredParams'; import { cdkContextJson } from '../src/cdk-context-json'; describe('injectAwsAuthIntoBuild', () => { - const project = new awscdk.AwsCdkTypeScriptApp({ - cdkVersion: '2.1.0', - defaultReleaseBranch: 'main', - name: 'foo', - }); + const project = new awscdk.AwsCdkTypeScriptApp(requiredParams); const lookupAccountId = '123412341234'; cdkContextJson.injectAwsAuthIntoBuild(project, { lookupAccountId, @@ -23,11 +20,7 @@ describe('injectAwsAuthIntoBuild', () => { }); describe('addOidcRoleStack', () => { - const project = new awscdk.AwsCdkTypeScriptApp({ - cdkVersion: '2.1.0', - defaultReleaseBranch: 'main', - name: 'foo', - }); + const project = new awscdk.AwsCdkTypeScriptApp(requiredParams); cdkContextJson.addOidcRoleStack(project); const synth = Testing.synth(project); test('adds stack definition', () => { diff --git a/test/cdk-diff-workflow.test.ts b/test/cdk-diff-workflow.test.ts index 8f380104..21bfc7ba 100644 --- a/test/cdk-diff-workflow.test.ts +++ b/test/cdk-diff-workflow.test.ts @@ -1,16 +1,13 @@ import { Testing } from 'projen'; // import * as Yaml from 'yaml'; +import { requiredParams } from './requiredParams'; import { cdkDiffWorkflow } from '../src/cdk-diff-workflow'; import { clickupCdk } from '../src/clickup-cdk'; describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => { test('a single env to diff', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); cdkDiffWorkflow.addCdkDiffWorkflowYml(project, { envsToDiff: [ { @@ -26,11 +23,7 @@ describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => { }); test('diff with roleDuration value set', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); cdkDiffWorkflow.addCdkDiffWorkflowYml(project, { envsToDiff: [ { @@ -48,9 +41,7 @@ describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => { test('node20', () => { const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', + ...requiredParams, workflowNodeVersion: '20.5.1', }); cdkDiffWorkflow.addCdkDiffWorkflowYml(project, { @@ -68,11 +59,7 @@ describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => { }); test('a single env to diff - single explicit stack given to diff', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); cdkDiffWorkflow.addCdkDiffWorkflowYml(project, { envsToDiff: [ { @@ -88,11 +75,7 @@ describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => { }); test('a single env to diff - multiple stacks given to diff', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); cdkDiffWorkflow.addCdkDiffWorkflowYml(project, { envsToDiff: [ { @@ -108,11 +91,7 @@ describe('addCdkDiffWorkflowYml - cdk diff.yml file added', () => { }); test('multiple envs to diff', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); cdkDiffWorkflow.addCdkDiffWorkflowYml(project, { envsToDiff: [ { diff --git a/test/clickup-cdk.test.ts b/test/clickup-cdk.test.ts index 337bb539..2ef1d419 100644 --- a/test/clickup-cdk.test.ts +++ b/test/clickup-cdk.test.ts @@ -1,14 +1,9 @@ import path from 'path'; import { Testing, javascript } from 'projen'; +import { requiredParams } from './requiredParams'; import { clickupCdk } from '../src'; import { datadogServiceCatalog } from '../src/datadog-service-catalog'; -const requiredParams = { - name: 'test', - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', -}; - describe('ClickUpCdkTypeScriptApp', () => { describe('defaults', () => { const p = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); diff --git a/test/codecov-bypass-workflow.test.ts b/test/codecov-bypass-workflow.test.ts index 6ec86552..c63bf11a 100644 --- a/test/codecov-bypass-workflow.test.ts +++ b/test/codecov-bypass-workflow.test.ts @@ -1,26 +1,19 @@ import { Testing } from 'projen'; +import { requiredParams } from './requiredParams'; import { clickupCdk } from '../src/clickup-cdk'; import { codecovBypassWorkflow } from '../src/codecov-bypass-workflow'; describe('addCodecovBypassWorkflowYml - codecov-bypass .yml file added', () => { test('all default options', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); codecovBypassWorkflow.addCodecovBypassWorkflowYml(project); const synth = Testing.synth(project); expect(synth['.github/workflows/codecov-bypass.yml']).toMatchSnapshot(); }); test('all options provided', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); codecovBypassWorkflow.addCodecovBypassWorkflowYml(project, { workflowName: 'workflowName', githubAppId: '${{ vars.GH_APP_ID_VAR_NAME }}', @@ -35,11 +28,7 @@ describe('addCodecovBypassWorkflowYml - codecov-bypass .yml file added', () => { }); test('disabled', () => { - const project = new clickupCdk.ClickUpCdkTypeScriptApp({ - cdkVersion: '2.91.0', - defaultReleaseBranch: 'main', - name: 'test', - }); + const project = new clickupCdk.ClickUpCdkTypeScriptApp(requiredParams); codecovBypassWorkflow.addCodecovBypassWorkflowYml(project, { disabled: true, }); diff --git a/test/requiredParams.ts b/test/requiredParams.ts new file mode 100644 index 00000000..fac23ba5 --- /dev/null +++ b/test/requiredParams.ts @@ -0,0 +1,5 @@ +export const requiredParams = { + name: 'test', + cdkVersion: '2.135.0', + defaultReleaseBranch: 'main', +};