From 69a404072e1b8beb9f699daf64a646b553b05444 Mon Sep 17 00:00:00 2001 From: ialford Date: Mon, 8 Mar 2021 08:56:21 -0500 Subject: [PATCH 1/6] feat(codebuild): allow setting queued timeout --- packages/@aws-cdk/aws-codebuild/lib/project.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/@aws-cdk/aws-codebuild/lib/project.ts b/packages/@aws-cdk/aws-codebuild/lib/project.ts index 2f31bc897f9f8..9477f5be3a246 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/project.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/project.ts @@ -575,6 +575,15 @@ export interface CommonProjectProps { * @default - no log configuration is set */ readonly logging?: LoggingOptions; + + /** + * The number of minutes after which AWS CodeBuild stops the build if it's + * still in queue. For valid values, see the timeoutInMinutes field in the AWS + * CodeBuild User Guide. + * + * @default - no queue timeout is set + */ + readonly queuedTimeout?: Duration } export interface ProjectProps extends CommonProjectProps { @@ -869,6 +878,7 @@ export class Project extends ProjectBase { cache: cache._toCloudFormation(), name: this.physicalName, timeoutInMinutes: props.timeout && props.timeout.toMinutes(), + queuedTimeoutInMinutes: props.queuedTimeout && props.queuedTimeout.toMinutes(), secondarySources: Lazy.any({ produce: () => this.renderSecondarySources() }), secondarySourceVersions: Lazy.any({ produce: () => this.renderSecondarySourceVersions() }), secondaryArtifacts: Lazy.any({ produce: () => this.renderSecondaryArtifacts() }), From 61239ff88b6d377f88ae99078e213f8bd70b41fd Mon Sep 17 00:00:00 2001 From: ialford Date: Mon, 8 Mar 2021 09:45:00 -0500 Subject: [PATCH 2/6] docs(codebuild): add timeout section to README to cover new property --- packages/@aws-cdk/aws-codebuild/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/@aws-cdk/aws-codebuild/README.md b/packages/@aws-cdk/aws-codebuild/README.md index 9f35a81656b56..4f9e43bd18872 100644 --- a/packages/@aws-cdk/aws-codebuild/README.md +++ b/packages/@aws-cdk/aws-codebuild/README.md @@ -617,3 +617,25 @@ if (project.enableBatchBuilds()) { console.log('Batch builds were enabled'); } ``` + +## Timeouts + +There are two types of timeouts that can be set when creating your Project. The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed. The default is 60 minutes. An example of overriding the default follows. + +```ts +import * as codebuild from '@aws-cdk/aws-codebuild'; + +new codebuild.Project(stack, 'MyProject', { + timeout: Duration.minutes(90) +}; +``` + +The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run. There is no default value for this property. As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails, use the following code. + +```ts +import * as codebuild from '@aws-cdk/aws-codebuild'; + +new codebuild.Project(stack, 'MyProject', { + queuedTimeout: Duration.minutes(30) +}; +``` From 04ef119bd15caa963ac666bf88d643f3ed642b26 Mon Sep 17 00:00:00 2001 From: ialford Date: Mon, 8 Mar 2021 09:59:05 -0500 Subject: [PATCH 3/6] test(codebuild): add timeout unit tests --- .../aws-codebuild/test/test.project.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/@aws-cdk/aws-codebuild/test/test.project.ts b/packages/@aws-cdk/aws-codebuild/test/test.project.ts index 2912d832bd2c0..9d8d4823971c3 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.project.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.project.ts @@ -960,4 +960,37 @@ export = { test.done(); }, }, + + 'Timeouts': { + 'can add queued timeout'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + new codebuild.Project(stack, 'Project', { + queuedTimeout: cdk.Duration.minutes(30), + }); + + // THEN + expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', { + QueuedTimeoutInMinutes: 30, + })); + + test.done(); + }, + 'can override build timeout'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + new codebuild.Project(stack, 'Project', { + timeout: cdk.Duration.minutes(30), + }); + + // THEN + expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', { + TimeoutInMinutes: 30, + })); + }, + }, }; From befafd9f31df3ea533bd9d8999237bfc81e73c7c Mon Sep 17 00:00:00 2001 From: ialford Date: Mon, 8 Mar 2021 10:21:51 -0500 Subject: [PATCH 4/6] test(codebuild): fix override unit test --- packages/@aws-cdk/aws-codebuild/test/test.project.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/@aws-cdk/aws-codebuild/test/test.project.ts b/packages/@aws-cdk/aws-codebuild/test/test.project.ts index 9d8d4823971c3..1420840d5dcc1 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.project.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.project.ts @@ -991,6 +991,8 @@ export = { expect(stack).to(haveResourceLike('AWS::CodeBuild::Project', { TimeoutInMinutes: 30, })); + + test.done(); }, }, }; From 7756bed99ce7c38ace02be412dda76b383ff4e53 Mon Sep 17 00:00:00 2001 From: ialford Date: Mon, 8 Mar 2021 10:45:36 -0500 Subject: [PATCH 5/6] test(codebuild): fix noSource error --- packages/@aws-cdk/aws-codebuild/test/test.project.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/@aws-cdk/aws-codebuild/test/test.project.ts b/packages/@aws-cdk/aws-codebuild/test/test.project.ts index 1420840d5dcc1..159511589ead7 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.project.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.project.ts @@ -968,6 +968,10 @@ export = { // WHEN new codebuild.Project(stack, 'Project', { + source: codebuild.Source.s3({ + bucket: new s3.Bucket(stack, 'Bucket'), + path: 'path', + }), queuedTimeout: cdk.Duration.minutes(30), }); @@ -984,6 +988,10 @@ export = { // WHEN new codebuild.Project(stack, 'Project', { + source: codebuild.Source.s3({ + bucket: new s3.Bucket(stack, 'Bucket'), + path: 'path', + }), timeout: cdk.Duration.minutes(30), }); From e05828cc4e2417564818a9f9c1fa716a578fe0fc Mon Sep 17 00:00:00 2001 From: ialford Date: Mon, 8 Mar 2021 14:00:13 -0500 Subject: [PATCH 6/6] docs(codebuild): update README for clarity and missing parens in code block --- packages/@aws-cdk/aws-codebuild/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-codebuild/README.md b/packages/@aws-cdk/aws-codebuild/README.md index 4f9e43bd18872..cdc3d9f59b665 100644 --- a/packages/@aws-cdk/aws-codebuild/README.md +++ b/packages/@aws-cdk/aws-codebuild/README.md @@ -620,22 +620,28 @@ if (project.enableBatchBuilds()) { ## Timeouts -There are two types of timeouts that can be set when creating your Project. The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed. The default is 60 minutes. An example of overriding the default follows. +There are two types of timeouts that can be set when creating your Project. +The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed. +The default is 60 minutes. +An example of overriding the default follows. ```ts import * as codebuild from '@aws-cdk/aws-codebuild'; new codebuild.Project(stack, 'MyProject', { timeout: Duration.minutes(90) -}; +}); ``` -The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run. There is no default value for this property. As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails, use the following code. +The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run. +There is no default value for this property. +As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails, +use the following code. ```ts import * as codebuild from '@aws-cdk/aws-codebuild'; new codebuild.Project(stack, 'MyProject', { queuedTimeout: Duration.minutes(30) -}; +}); ```