Skip to content

Commit

Permalink
feat(codebuild): add support for small ARM machine type (#16635)
Browse files Browse the repository at this point in the history
closes #16633 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
grusy authored Oct 14, 2021
1 parent 7db5c8c commit 55fbc86
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1656,8 +1656,9 @@ class ArmBuildImage implements IBuildImage {
public validate(buildEnvironment: BuildEnvironment): string[] {
const ret = [];
if (buildEnvironment.computeType &&
buildEnvironment.computeType !== ComputeType.SMALL &&
buildEnvironment.computeType !== ComputeType.LARGE) {
ret.push(`ARM images only support ComputeType '${ComputeType.LARGE}' - ` +
ret.push(`ARM images only support ComputeTypes '${ComputeType.SMALL}' and '${ComputeType.LARGE}' - ` +
`'${buildEnvironment.computeType}' was given`);
}
return ret;
Expand Down
43 changes: 32 additions & 11 deletions packages/@aws-cdk/aws-codebuild/test/codebuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1590,17 +1590,21 @@ describe('ARM image', () => {
});
});

test('cannot be used in conjunction with ComputeType SMALL', () => {
test('can be used with ComputeType SMALL', () => {
const stack = new cdk.Stack();
new codebuild.PipelineProject(stack, 'Project', {
environment: {
computeType: codebuild.ComputeType.SMALL,
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM,
},
});

expect(() => {
new codebuild.PipelineProject(stack, 'Project', {
environment: {
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM,
computeType: codebuild.ComputeType.SMALL,
},
});
}).toThrow(/ARM images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_SMALL' was given/);
expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', {
'Environment': {
'Type': 'ARM_CONTAINER',
'ComputeType': 'BUILD_GENERAL1_SMALL',
},
});
});

test('cannot be used in conjunction with ComputeType MEDIUM', () => {
Expand All @@ -1613,7 +1617,24 @@ describe('ARM image', () => {
computeType: codebuild.ComputeType.MEDIUM,
},
});
}).toThrow(/ARM images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/);
}).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/);
});

test('can be used with ComputeType LARGE', () => {
const stack = new cdk.Stack();
new codebuild.PipelineProject(stack, 'Project', {
environment: {
computeType: codebuild.ComputeType.LARGE,
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM,
},
});

expect(stack).toHaveResourceLike('AWS::CodeBuild::Project', {
'Environment': {
'Type': 'ARM_CONTAINER',
'ComputeType': 'BUILD_GENERAL1_LARGE',
},
});
});

test('cannot be used in conjunction with ComputeType X2_LARGE', () => {
Expand All @@ -1626,7 +1647,7 @@ describe('ARM image', () => {
computeType: codebuild.ComputeType.X2_LARGE,
},
});
}).toThrow(/ARM images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/);
}).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/);
});
});
});
Expand Down

0 comments on commit 55fbc86

Please sign in to comment.