Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codebuild): add support for small ARM machine type #16635

Merged
merged 5 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', () => {
grusy marked this conversation as resolved.
Show resolved Hide resolved
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/);
});

grusy marked this conversation as resolved.
Show resolved Hide resolved
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