Skip to content

Commit

Permalink
fix(pipelines): support new versions of jest
Browse files Browse the repository at this point in the history
fixes aws#9070

This change moves CDK pipelines from standard build image 1.0 to 4.0
  • Loading branch information
justin8 committed Aug 5, 2020
1 parent 7673e48 commit d302fc0
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ yarn-error.log
# Parcel default cache directory
.parcel-cache

# Cloud9
.c9
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export class PublishAssetsAction extends Construct implements codepipeline.IActi

const project = new codebuild.PipelineProject(this, 'Default', {
projectName: this.props.projectName,
environment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_4_0,
privileged: (props.assetType === AssetType.DOCKER_IMAGE) ? true : undefined,
},
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand All @@ -92,8 +96,6 @@ export class PublishAssetsAction extends Construct implements codepipeline.IActi
},
},
}),
// Needed to perform Docker builds
environment: props.assetType === AssetType.DOCKER_IMAGE ? { privileged: true } : undefined,
role: props.role,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class UpdatePipelineAction extends Construct implements codepipeline.IAct

const selfMutationProject = new codebuild.PipelineProject(this, 'SelfMutation', {
projectName: props.projectName,
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_4_0 },
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface SimpleSynthOptions {
/**
* Build environment to use for CodeBuild job
*
* @default BuildEnvironment.LinuxBuildImage.STANDARD_1_0
* @default BuildEnvironment.LinuxBuildImage.STANDARD_4_0
*/
readonly environment?: codebuild.BuildEnvironment;

Expand Down Expand Up @@ -210,7 +210,7 @@ export class SimpleSynthAction implements codepipeline.IAction {

const project = new codebuild.PipelineProject(scope, 'CdkBuildProject', {
projectName: this.props.projectName ?? this.props.projectName,
environment: this.props.environment,
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_4_0, ...this.props.environment },
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class ShellScriptAction implements codepipeline.IAction {
}

this._project = new codebuild.PipelineProject(scope, 'Project', {
environment: { buildImage: codebuild.LinuxBuildImage.STANDARD_4_0 },
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
Expand Down
15 changes: 15 additions & 0 deletions packages/@aws-cdk/pipelines/test/builds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ test.each([['npm'], ['yarn']])('%s build automatically determines artifact base-

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
artifacts: {
Expand All @@ -55,6 +58,9 @@ test.each([['npm'], ['yarn']])('%s build respects subdirectory', (npmYarn) => {

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand All @@ -80,6 +86,9 @@ test.each([['npm'], ['yarn']])('%s assumes no build step by default', (npmYarn)

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand All @@ -106,6 +115,9 @@ test.each([['npm'], ['yarn']])('%s can have its install command overridden', (np

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -141,6 +153,9 @@ test('Standard (NPM) synth can output additional artifacts', () => {

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
artifacts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1087,7 +1087,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1391,7 +1391,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1564,7 +1564,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1594,7 +1594,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -986,7 +986,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down Expand Up @@ -1290,7 +1290,7 @@
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"Image": "aws/codebuild/standard:4.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/@aws-cdk/pipelines/test/pipeline-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ test('command line properly locates assets in subassembly', () => {

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -96,6 +99,9 @@ test('file image asset publishers do not use privilegedmode, have right AssumeRo

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -127,6 +133,9 @@ test('docker image asset publishers use privilegedmode, have right AssumeRole',

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -161,6 +170,9 @@ test('can control fix/CLI version used in pipeline selfupdate', () => {

// THEN
expect(stack2).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/pipelines/test/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ test('pipeline has self-mutation stage', () => {
});

expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand All @@ -200,6 +203,9 @@ test('selfmutation stage correctly identifies nested assembly of pipeline stack'

// THEN
expect(stackTemplate(nestedPipelineStack)).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down
9 changes: 9 additions & 0 deletions packages/@aws-cdk/pipelines/test/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ test('can use stack outputs as validation inputs', () => {
});

expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -113,6 +116,9 @@ test('can use additional files from source', () => {
}),
});
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down Expand Up @@ -149,6 +155,9 @@ test('can use additional files from build', () => {
}),
});
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: {
Image: "aws/codebuild/standard:4.0"
},
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
Expand Down

0 comments on commit d302fc0

Please sign in to comment.