File tree Expand file tree Collapse file tree 3 files changed +54
-3
lines changed
Expand file tree Collapse file tree 3 files changed +54
-3
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,15 @@ vendors.forEach(function (vendor) {
3535 break
3636 case 'object' :
3737 if ( 'env' in vendor . pr ) {
38- // "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
39- exports . isPR = vendor . pr . env in env && env [ vendor . pr . env ] !== vendor . pr . ne
38+ if ( 'any' in vendor . pr ) {
39+ // "pr": { "env": "CODEBUILD_WEBHOOK_EVENT", "any": ["PULL_REQUEST_CREATED", "PULL_REQUEST_UPDATED"] }
40+ exports . isPR = vendor . pr . any . some ( function ( key ) {
41+ return env [ vendor . pr . env ] === key
42+ } )
43+ } else {
44+ // "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
45+ exports . isPR = vendor . pr . env in env && env [ vendor . pr . env ] !== vendor . pr . ne
46+ }
4047 } else if ( 'any' in vendor . pr ) {
4148 // "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
4249 exports . isPR = vendor . pr . any . some ( function ( key ) {
@@ -79,11 +86,13 @@ function checkEnv (obj) {
7986 return env [ obj . env ] && env [ obj . env ] . includes ( obj . includes )
8087 // }
8188 }
89+
8290 if ( 'any' in obj ) {
8391 return obj . any . some ( function ( k ) {
8492 return ! ! env [ k ]
8593 } )
8694 }
95+
8796 return Object . keys ( obj ) . every ( function ( k ) {
8897 return env [ k ] === obj [ k ]
8998 } )
Original file line number Diff line number Diff line change @@ -1004,6 +1004,40 @@ test('Earthly CI', function (t) {
10041004 t . end ( )
10051005} )
10061006
1007+ test ( 'AWS Codebuild' , function ( t ) {
1008+ process . env . CODEBUILD_BUILD_ARN = 'true'
1009+
1010+ clearModule ( './' )
1011+ const ci = require ( './' )
1012+
1013+ t . equal ( ci . isCI , true )
1014+ t . equal ( ci . name , 'AWS CodeBuild' )
1015+ t . equal ( ci . CODEBUILD , true )
1016+ assertVendorConstants ( 'CODEBUILD' , ci , t )
1017+
1018+ delete process . env . CODEBUILD_BUILD_ARN
1019+
1020+ t . end ( )
1021+ } )
1022+
1023+ test ( 'AWS Codebuild - PR' , function ( t ) {
1024+ process . env . CODEBUILD_BUILD_ARN = 'true'
1025+ process . env . CODEBUILD_WEBHOOK_EVENT = 'PULL_REQUEST_CREATED'
1026+
1027+ clearModule ( './' )
1028+ const ci = require ( './' )
1029+
1030+ t . equal ( ci . isCI , true )
1031+ t . equal ( ci . isPR , true )
1032+ t . equal ( ci . name , 'AWS CodeBuild' )
1033+ t . equal ( ci . CODEBUILD , true )
1034+ assertVendorConstants ( 'CODEBUILD' , ci , t )
1035+
1036+ delete process . env . CODEBUILD_BUILD_ARN
1037+
1038+ t . end ( )
1039+ } )
1040+
10071041function assertVendorConstants ( expect , ci , t ) {
10081042 ci . _vendors . forEach ( function ( constant ) {
10091043 const bool = constant === expect
Original file line number Diff line number Diff line change 1919 {
2020 "name" : " AWS CodeBuild" ,
2121 "constant" : " CODEBUILD" ,
22- "env" : " CODEBUILD_BUILD_ARN"
22+ "env" : " CODEBUILD_BUILD_ARN" ,
23+ "pr" : {
24+ "env" : " CODEBUILD_WEBHOOK_EVENT" ,
25+ "any" : [
26+ " PULL_REQUEST_CREATED" ,
27+ " PULL_REQUEST_UPDATED" ,
28+ " PULL_REQUEST_REOPENED"
29+ ]
30+ }
2331 },
2432 {
2533 "name" : " Azure Pipelines" ,
You can’t perform that action at this time.
0 commit comments