@@ -9,6 +9,7 @@ describe('CodeBuildStack', () => {
99 test ( 'synthesizes the way we expect' , ( ) => {
1010 const app = new cdk . App ( ) ;
1111 const codebuildStackArgs : CodeBuildStackArgs = {
12+ project : 'finch' ,
1213 operatingSystem : 'ubuntu' ,
1314 arch : 'x86_64' ,
1415 amiSearchString : 'ubuntu*22.04*' ,
@@ -21,7 +22,8 @@ describe('CodeBuildStack', () => {
2122 account : '123456789012' ,
2223 region : 'us-east-1'
2324 } ,
24- projectName : 'test-project' ,
25+ projectName : codebuildStackArgs . project ,
26+ repo : codebuildStackArgs . project ,
2527 region : 'us-west-2' ,
2628 ...codebuildStackArgs
2729 } ) ;
@@ -38,7 +40,8 @@ describe('CodeBuildStack', () => {
3840 account : '123456789012' ,
3941 region : 'us-east-1'
4042 } ,
41- projectName : 'test-project' ,
43+ projectName : codebuildStackArgs . project ,
44+ repo : codebuildStackArgs . project ,
4245 region : 'us-west-2' ,
4346 ...codebuildStackArgs
4447 } ) ;
@@ -50,27 +53,49 @@ describe('CodeBuildStack', () => {
5053} ) ;
5154
5255const validateTemplate = ( codebuildStack : CodeBuildStackArgs , template : Template ) => {
53- // Assert that the stack creates a Fleet
56+ let imageMatcher ;
57+ if ( codebuildStack . amiSearchString === "" ) {
58+ // For macOS builds, match only the base image versions (14 or 15)
59+ imageMatcher = Match . stringLikeRegexp ( 'aws/codebuild/macos-arm-base:1[45]$' ) ;
60+ } else {
61+ // For regular builds, expect an AMI ID
62+ imageMatcher = Match . stringLikeRegexp ( 'ami-1234' ) ;
63+ }
64+
65+ // Assert that the stack creates a Project
5466 template . hasResourceProperties ( 'AWS::CodeBuild::Project' , {
55- Name : 'test- project' ,
67+ Name : codebuildStack . project ,
5668 Environment : {
5769 Type : codebuildStack . environmentType ,
58- ComputeType : 'BUILD_GENERAL1_MEDIUM' ,
59- Image : Match . stringLikeRegexp ( 'ami-1234' ) ,
70+ ComputeType : codebuildStack . projectEnvironmentProps ?. computeType || 'BUILD_GENERAL1_MEDIUM' ,
71+ Image : imageMatcher ,
6072 } ,
6173 Source : {
6274 Type : 'GITHUB' ,
63- Location : 'https://github.com/runfinch/finch.git' ,
75+ Location : codebuildStack . project === 'finch-daemon'
76+ ? 'https://github.com/runfinch/finch-daemon.git'
77+ : 'https://github.com/runfinch/finch.git' ,
6478 ReportBuildStatus : true
6579 }
6680 } ) ;
6781
6882 // Assert that the stack creates a Fleet
69- template . hasResourceProperties ( 'AWS::CodeBuild::Fleet' , {
70- BaseCapacity : 1 ,
71- ComputeType : 'BUILD_GENERAL1_MEDIUM' ,
72- EnvironmentType : codebuildStack . environmentType
73- } ) ;
83+ if ( codebuildStack . amiSearchString !== "" ) {
84+ // For non-macOS builds, expect ImageId property
85+ template . hasResourceProperties ( 'AWS::CodeBuild::Fleet' , {
86+ BaseCapacity : codebuildStack . fleetProps ?. baseCapacity || 1 ,
87+ ComputeType : codebuildStack . fleetProps ?. computeType || 'BUILD_GENERAL1_MEDIUM' ,
88+ EnvironmentType : codebuildStack . environmentType ,
89+ ImageId : Match . anyValue ( )
90+ } ) ;
91+ } else {
92+ // For macOS builds, ImageId property should not be present
93+ template . hasResourceProperties ( 'AWS::CodeBuild::Fleet' , {
94+ BaseCapacity : codebuildStack . fleetProps ?. baseCapacity || 1 ,
95+ ComputeType : codebuildStack . fleetProps ?. computeType || 'BUILD_GENERAL1_MEDIUM' ,
96+ EnvironmentType : codebuildStack . environmentType
97+ } ) ;
98+ }
7499
75100 // Assert that the stack creates a Fleet service role
76101 template . hasResourceProperties ( 'AWS::IAM::Role' , {
0 commit comments